Class StorageClient (2.43.1)

GitHub RepositoryProduct Reference

Service Description: ## API Overview and Naming Syntax

The Cloud Storage gRPC API allows applications to read and write data through the abstractions of buckets and objects. For a description of these abstractions please see https://cloud.google.com/storage/docs.

Resources are named as follows: - Projects are referred to as they are defined by the Resource Manager API, using strings like projects/123456 or projects/my-string-id. - Buckets are named using string names of the form: projects/{project}/buckets/{bucket} For globally unique buckets, _ may be substituted for the project. - Objects are uniquely identified by their name along with the name of the bucket they belong to, as separate strings in this API. For example:

ReadObjectRequest { bucket: 'projects/_/buckets/my-bucket' object: 'my-object' } Note that object names can contain / characters, which are treated as any other character (no special directory semantics).

This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName name = BucketName.of("[PROJECT]", "[BUCKET]");
   storageClient.deleteBucket(name);
 }
 

Note: close() needs to be called on the StorageClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().

Methods
Method Description Method Variants

DeleteBucket

Permanently deletes an empty bucket.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteBucket(DeleteBucketRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteBucket(BucketName name)

  • deleteBucket(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteBucketCallable()

GetBucket

Returns metadata for the specified bucket.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getBucket(GetBucketRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getBucket(BucketName name)

  • getBucket(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getBucketCallable()

CreateBucket

Creates a new bucket.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createBucket(CreateBucketRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createBucket(ProjectName parent, Bucket bucket, String bucketId)

  • createBucket(String parent, Bucket bucket, String bucketId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createBucketCallable()

ListBuckets

Retrieves a list of buckets for a given project.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listBuckets(ListBucketsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listBuckets(ProjectName parent)

  • listBuckets(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listBucketsPagedCallable()

  • listBucketsCallable()

LockBucketRetentionPolicy

Locks retention policy on a bucket.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • lockBucketRetentionPolicy(LockBucketRetentionPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • lockBucketRetentionPolicy(BucketName bucket)

  • lockBucketRetentionPolicy(String bucket)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • lockBucketRetentionPolicyCallable()

GetIamPolicy

Gets the IAM policy for a specified bucket. The resource field in the request should be projects//buckets/{bucket}.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getIamPolicy(GetIamPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getIamPolicy(ResourceName resource)

  • getIamPolicy(String resource)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getIamPolicyCallable()

SetIamPolicy

Updates an IAM policy for the specified bucket. The resource field in the request should be projects//buckets/{bucket}.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • setIamPolicy(SetIamPolicyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • setIamPolicy(ResourceName resource, Policy policy)

  • setIamPolicy(String resource, Policy policy)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • setIamPolicyCallable()

TestIamPermissions

Tests a set of permissions on the given bucket, object, or managed folder to see which, if any, are held by the caller. The resource field in the request should be projects//buckets/{bucket} for a bucket, projects//buckets/{bucket}/objects/{object} for an object, or projects/_/buckets/{bucket}/managedFolders/{managedFolder} for a managed folder.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • testIamPermissions(TestIamPermissionsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • testIamPermissions(ResourceName resource, List<String> permissions)

  • testIamPermissions(String resource, List<String> permissions)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • testIamPermissionsCallable()

UpdateBucket

Updates a bucket. Equivalent to JSON API's storage.buckets.patch method.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateBucket(UpdateBucketRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateBucket(Bucket bucket, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateBucketCallable()

ComposeObject

Concatenates a list of existing objects into a new object in the same bucket.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • composeObject(ComposeObjectRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • composeObjectCallable()

DeleteObject

Deletes an object and its metadata.

Deletions are normally permanent when versioning is disabled or whenever the generation parameter is used. However, if soft delete is enabled for the bucket, deleted objects can be restored using RestoreObject until the soft delete retention period has passed.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteObject(DeleteObjectRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteObject(BucketName bucket, String object)

  • deleteObject(String bucket, String object)

  • deleteObject(BucketName bucket, String object, long generation)

  • deleteObject(String bucket, String object, long generation)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteObjectCallable()

RestoreObject

Restores a soft-deleted object.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • restoreObject(RestoreObjectRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • restoreObject(BucketName bucket, String object, long generation)

  • restoreObject(String bucket, String object, long generation)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • restoreObjectCallable()

CancelResumableWrite

Cancels an in-progress resumable upload.

Any attempts to write to the resumable upload after cancelling the upload will fail.

The behavior for currently in progress write operations is not guaranteed - they could either complete before the cancellation or fail if the cancellation completes first.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • cancelResumableWrite(CancelResumableWriteRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • cancelResumableWrite(String uploadId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • cancelResumableWriteCallable()

GetObject

Retrieves an object's metadata.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getObject(GetObjectRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getObject(BucketName bucket, String object)

  • getObject(String bucket, String object)

  • getObject(BucketName bucket, String object, long generation)

  • getObject(String bucket, String object, long generation)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getObjectCallable()

ReadObject

Reads an object's data.

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • readObjectCallable()

UpdateObject

Updates an object's metadata. Equivalent to JSON API's storage.objects.patch.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateObject(UpdateObjectRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateObject(Object object, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateObjectCallable()

WriteObject

Stores a new object and metadata.

An object can be written either in a single message stream or in a resumable sequence of message streams. To write using a single stream, the client should include in the first message of the stream an WriteObjectSpec describing the destination bucket, object, and any preconditions. Additionally, the final message must set 'finish_write' to true, or else it is an error.

For a resumable write, the client should instead call StartResumableWrite(), populating a WriteObjectSpec into that request. They should then attach the returned upload_id to the first message of each following call to WriteObject. If the stream is closed before finishing the upload (either explicitly by the client or due to a network error or an error response from the server), the client should do as follows: - Check the result Status of the stream, to determine if writing can be resumed on this stream or must be restarted from scratch (by calling StartResumableWrite()). The resumable errors are DEADLINE_EXCEEDED, INTERNAL, and UNAVAILABLE. For each case, the client should use binary exponential backoff before retrying. Additionally, writes can be resumed after RESOURCE_EXHAUSTED errors, but only after taking appropriate measures, which may include reducing aggregate send rate across clients and/or requesting a quota increase for your project. - If the call to WriteObject returns ABORTED, that indicates concurrent attempts to update the resumable write, caused either by multiple racing clients or by a single client where the previous request was timed out on the client side but nonetheless reached the server. In this case the client should take steps to prevent further concurrent writes (e.g., increase the timeouts, stop using more than one process to perform the upload, etc.), and then should follow the steps below for resuming the upload. - For resumable errors, the client should call QueryWriteStatus() and then continue writing from the returned persisted_size. This may be less than the amount of data the client previously sent. Note also that it is acceptable to send data starting at an offset earlier than the returned persisted_size; in this case, the service will skip data at offsets that were already persisted (without checking that it matches the previously written data), and write only the data starting from the persisted offset. Even though the data isn't written, it may still incur a performance cost over resuming at the correct write offset. This behavior can make client-side handling simpler in some cases. - Clients must only send data that is a multiple of 256 KiB per message, unless the object is being finished with finish_write set to true.

The service will not view the object as complete until the client has sent a WriteObjectRequest with finish_write set to true. Sending any requests on a stream after sending a request with finish_write set to true will cause an error. The client **should** check the response it receives to determine how much data the service was able to commit and whether the service views the object as complete.

Attempting to resume an already finalized object will result in an OK status, with a WriteObjectResponse containing the finalized object's metadata.

Alternatively, the BidiWriteObject operation may be used to write an object with controls over flushing and the ability to fetch the ability to determine the current persisted size.

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • writeObjectCallable()

BidiWriteObject

Stores a new object and metadata.

This is similar to the WriteObject call with the added support for manual flushing of persisted state, and the ability to determine current persisted size without closing the stream.

The client may specify one or both of the state_lookup and flush fields in each BidiWriteObjectRequest. If flush is specified, the data written so far will be persisted to storage. If state_lookup is specified, the service will respond with a BidiWriteObjectResponse that contains the persisted size. If both flush and state_lookup are specified, the flush will always occur before a state_lookup, so that both may be set in the same request and the returned state will be the state of the object post-flush. When the stream is closed, a BidiWriteObjectResponse will always be sent to the client, regardless of the value of state_lookup.

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • bidiWriteObjectCallable()

ListObjects

Retrieves a list of objects matching the criteria.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listObjects(ListObjectsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listObjects(BucketName parent)

  • listObjects(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listObjectsPagedCallable()

  • listObjectsCallable()

RewriteObject

Rewrites a source object to a destination object. Optionally overrides metadata.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • rewriteObject(RewriteObjectRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • rewriteObjectCallable()

StartResumableWrite

Starts a resumable write. How long the write operation remains valid, and what happens when the write operation becomes invalid, are service-dependent.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • startResumableWrite(StartResumableWriteRequest request)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • startResumableWriteCallable()

QueryWriteStatus

Determines the persisted_size for an object that is being written, which can then be used as the write_offset for the next Write() call.

If the object does not exist (i.e., the object has been deleted, or the first Write() has not yet reached the service), this method returns the error NOT_FOUND.

The client **may** call QueryWriteStatus() at any time to determine how much data has been processed for this object. This is useful if the client is buffering data and needs to know which data can be safely evicted. For any sequence of QueryWriteStatus() calls for a given object name, the sequence of returned persisted_size values will be non-decreasing.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • queryWriteStatus(QueryWriteStatusRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • queryWriteStatus(String uploadId)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • queryWriteStatusCallable()

GetServiceAccount

Retrieves the name of a project's Google Cloud Storage service account.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getServiceAccount(GetServiceAccountRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getServiceAccount(ProjectName project)

  • getServiceAccount(String project)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getServiceAccountCallable()

CreateHmacKey

Creates a new HMAC key for the given service account.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createHmacKey(CreateHmacKeyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createHmacKey(ProjectName project, String serviceAccountEmail)

  • createHmacKey(String project, String serviceAccountEmail)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createHmacKeyCallable()

DeleteHmacKey

Deletes a given HMAC key. Key must be in an INACTIVE state.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteHmacKey(DeleteHmacKeyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteHmacKey(String accessId, ProjectName project)

  • deleteHmacKey(String accessId, String project)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteHmacKeyCallable()

GetHmacKey

Gets an existing HMAC key metadata for the given id.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getHmacKey(GetHmacKeyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getHmacKey(String accessId, ProjectName project)

  • getHmacKey(String accessId, String project)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getHmacKeyCallable()

ListHmacKeys

Lists HMAC keys under a given project with the additional filters provided.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listHmacKeys(ListHmacKeysRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listHmacKeys(ProjectName project)

  • listHmacKeys(String project)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listHmacKeysPagedCallable()

  • listHmacKeysCallable()

UpdateHmacKey

Updates a given HMAC key state between ACTIVE and INACTIVE.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • updateHmacKey(UpdateHmacKeyRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • updateHmacKey(HmacKeyMetadata hmacKey, FieldMask updateMask)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • updateHmacKeyCallable()

DeleteNotificationConfig

Permanently deletes a NotificationConfig.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • deleteNotificationConfig(DeleteNotificationConfigRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • deleteNotificationConfig(NotificationConfigName name)

  • deleteNotificationConfig(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • deleteNotificationConfigCallable()

GetNotificationConfig

View a NotificationConfig.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • getNotificationConfig(GetNotificationConfigRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • getNotificationConfig(NotificationConfigName name)

  • getNotificationConfig(String name)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • getNotificationConfigCallable()

CreateNotificationConfig

Creates a NotificationConfig for a given bucket. These NotificationConfigs, when triggered, publish messages to the specified Pub/Sub topics. See https://cloud.google.com/storage/docs/pubsub-notifications.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • createNotificationConfig(CreateNotificationConfigRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • createNotificationConfig(BucketName parent, NotificationConfig notificationConfig)

  • createNotificationConfig(String parent, NotificationConfig notificationConfig)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • createNotificationConfigCallable()

ListNotificationConfigs

Retrieves a list of NotificationConfigs for a given bucket.

Request object method variants only take one parameter, a request object, which must be constructed before the call.

  • listNotificationConfigs(ListNotificationConfigsRequest request)

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

  • listNotificationConfigs(BucketName parent)

  • listNotificationConfigs(String parent)

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

  • listNotificationConfigsPagedCallable()

  • listNotificationConfigsCallable()

See the individual methods for example code.

Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.

This class can be customized by passing in a custom instance of StorageSettings to create(). For example:

To customize credentials:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 StorageSettings storageSettings =
     StorageSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 StorageClient storageClient = StorageClient.create(storageSettings);
 

To customize the endpoint:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 StorageSettings storageSettings = StorageSettings.newBuilder().setEndpoint(myEndpoint).build();
 StorageClient storageClient = StorageClient.create(storageSettings);
 

Please refer to the GitHub repository's samples for more quickstart code snippets.

Inheritance

java.lang.Object > StorageClient

Static Methods

create()

public static final StorageClient create()

Constructs an instance of StorageClient with default settings.

Returns
Type Description
StorageClient
Exceptions
Type Description
IOException

create(StorageSettings settings)

public static final StorageClient create(StorageSettings settings)

Constructs an instance of StorageClient, using the given settings. The channels are created based on the settings passed in, or defaults for any settings that are not set.

Parameter
Name Description
settings StorageSettings
Returns
Type Description
StorageClient
Exceptions
Type Description
IOException

create(StorageStub stub)

public static final StorageClient create(StorageStub stub)

Constructs an instance of StorageClient, using the given stub for making calls. This is for advanced usage - prefer using create(StorageSettings).

Parameter
Name Description
stub StorageStub
Returns
Type Description
StorageClient

Constructors

StorageClient(StorageSettings settings)

protected StorageClient(StorageSettings settings)

Constructs an instance of StorageClient, using the given settings. This is protected so that it is easy to make a subclass, but otherwise, the static factory methods should be preferred.

Parameter
Name Description
settings StorageSettings

StorageClient(StorageStub stub)

protected StorageClient(StorageStub stub)
Parameter
Name Description
stub StorageStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
Name Description
duration long
unit TimeUnit
Returns
Type Description
boolean
Exceptions
Type Description
InterruptedException

bidiWriteObjectCallable()

public final BidiStreamingCallable<BidiWriteObjectRequest,BidiWriteObjectResponse> bidiWriteObjectCallable()

Stores a new object and metadata.

This is similar to the WriteObject call with the added support for manual flushing of persisted state, and the ability to determine current persisted size without closing the stream.

The client may specify one or both of the state_lookup and flush fields in each BidiWriteObjectRequest. If flush is specified, the data written so far will be persisted to storage. If state_lookup is specified, the service will respond with a BidiWriteObjectResponse that contains the persisted size. If both flush and state_lookup are specified, the flush will always occur before a state_lookup, so that both may be set in the same request and the returned state will be the state of the object post-flush. When the stream is closed, a BidiWriteObjectResponse will always be sent to the client, regardless of the value of state_lookup.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BidiStream<BidiWriteObjectRequest, BidiWriteObjectResponse> bidiStream =
       storageClient.bidiWriteObjectCallable().call();
   BidiWriteObjectRequest request =
       BidiWriteObjectRequest.newBuilder()
           .setWriteOffset(-1559543565)
           .setObjectChecksums(ObjectChecksums.newBuilder().build())
           .setStateLookup(true)
           .setFlush(true)
           .setFinishWrite(true)
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .build();
   bidiStream.send(request);
   for (BidiWriteObjectResponse response : bidiStream) {
     // Do something when a response is received.
   }
 }
 
Returns
Type Description
BidiStreamingCallable<BidiWriteObjectRequest,BidiWriteObjectResponse>

cancelResumableWrite(CancelResumableWriteRequest request)

public final CancelResumableWriteResponse cancelResumableWrite(CancelResumableWriteRequest request)

Cancels an in-progress resumable upload.

Any attempts to write to the resumable upload after cancelling the upload will fail.

The behavior for currently in progress write operations is not guaranteed - they could either complete before the cancellation or fail if the cancellation completes first.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   CancelResumableWriteRequest request =
       CancelResumableWriteRequest.newBuilder().setUploadId("uploadId1563990780").build();
   CancelResumableWriteResponse response = storageClient.cancelResumableWrite(request);
 }
 
Parameter
Name Description
request CancelResumableWriteRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
CancelResumableWriteResponse

cancelResumableWrite(String uploadId)

public final CancelResumableWriteResponse cancelResumableWrite(String uploadId)

Cancels an in-progress resumable upload.

Any attempts to write to the resumable upload after cancelling the upload will fail.

The behavior for currently in progress write operations is not guaranteed - they could either complete before the cancellation or fail if the cancellation completes first.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String uploadId = "uploadId1563990780";
   CancelResumableWriteResponse response = storageClient.cancelResumableWrite(uploadId);
 }
 
Parameter
Name Description
uploadId String

Required. The upload_id of the resumable upload to cancel. This should be copied from the upload_id field of StartResumableWriteResponse.

Returns
Type Description
CancelResumableWriteResponse

cancelResumableWriteCallable()

public final UnaryCallable<CancelResumableWriteRequest,CancelResumableWriteResponse> cancelResumableWriteCallable()

Cancels an in-progress resumable upload.

Any attempts to write to the resumable upload after cancelling the upload will fail.

The behavior for currently in progress write operations is not guaranteed - they could either complete before the cancellation or fail if the cancellation completes first.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   CancelResumableWriteRequest request =
       CancelResumableWriteRequest.newBuilder().setUploadId("uploadId1563990780").build();
   ApiFuture<CancelResumableWriteResponse> future =
       storageClient.cancelResumableWriteCallable().futureCall(request);
   // Do something.
   CancelResumableWriteResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CancelResumableWriteRequest,CancelResumableWriteResponse>

close()

public final void close()

composeObject(ComposeObjectRequest request)

public final Object composeObject(ComposeObjectRequest request)

Concatenates a list of existing objects into a new object in the same bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ComposeObjectRequest request =
       ComposeObjectRequest.newBuilder()
           .setDestination(Object.newBuilder().build())
           .addAllSourceObjects(new ArrayList<ComposeObjectRequest.SourceObject>())
           .setDestinationPredefinedAcl("destinationPredefinedAcl1111125814")
           .setIfGenerationMatch(-1086241088)
           .setIfMetagenerationMatch(1043427781)
           .setKmsKey(
               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                   .toString())
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .setObjectChecksums(ObjectChecksums.newBuilder().build())
           .build();
   Object response = storageClient.composeObject(request);
 }
 
Parameter
Name Description
request ComposeObjectRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Object

composeObjectCallable()

public final UnaryCallable<ComposeObjectRequest,Object> composeObjectCallable()

Concatenates a list of existing objects into a new object in the same bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ComposeObjectRequest request =
       ComposeObjectRequest.newBuilder()
           .setDestination(Object.newBuilder().build())
           .addAllSourceObjects(new ArrayList<ComposeObjectRequest.SourceObject>())
           .setDestinationPredefinedAcl("destinationPredefinedAcl1111125814")
           .setIfGenerationMatch(-1086241088)
           .setIfMetagenerationMatch(1043427781)
           .setKmsKey(
               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                   .toString())
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .setObjectChecksums(ObjectChecksums.newBuilder().build())
           .build();
   ApiFuture<Object> future = storageClient.composeObjectCallable().futureCall(request);
   // Do something.
   Object response = future.get();
 }
 
Returns
Type Description
UnaryCallable<ComposeObjectRequest,Object>

createBucket(CreateBucketRequest request)

public final Bucket createBucket(CreateBucketRequest request)

Creates a new bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   CreateBucketRequest request =
       CreateBucketRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setBucket(Bucket.newBuilder().build())
           .setBucketId("bucketId-1603305307")
           .setPredefinedAcl("predefinedAcl1207041188")
           .setPredefinedDefaultObjectAcl("predefinedDefaultObjectAcl2109168048")
           .build();
   Bucket response = storageClient.createBucket(request);
 }
 
Parameter
Name Description
request CreateBucketRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Bucket

createBucket(ProjectName parent, Bucket bucket, String bucketId)

public final Bucket createBucket(ProjectName parent, Bucket bucket, String bucketId)

Creates a new bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   Bucket bucket = Bucket.newBuilder().build();
   String bucketId = "bucketId-1603305307";
   Bucket response = storageClient.createBucket(parent, bucket, bucketId);
 }
 
Parameters
Name Description
parent ProjectName

Required. The project to which this bucket will belong.

bucket Bucket

Properties of the new bucket being inserted. The name of the bucket is specified in the bucket_id field. Populating bucket.name field will result in an error. The project of the bucket must be specified in the bucket.project field. This field must be in projects/{projectIdentifier} format, {projectIdentifier} can be the project ID or project number. The parent field must be either empty or projects/_.

bucketId String

Required. The ID to use for this bucket, which will become the final component of the bucket's resource name. For example, the value foo might result in a bucket with the name projects/123456/buckets/foo.

Returns
Type Description
Bucket

createBucket(String parent, Bucket bucket, String bucketId)

public final Bucket createBucket(String parent, Bucket bucket, String bucketId)

Creates a new bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   Bucket bucket = Bucket.newBuilder().build();
   String bucketId = "bucketId-1603305307";
   Bucket response = storageClient.createBucket(parent, bucket, bucketId);
 }
 
Parameters
Name Description
parent String

Required. The project to which this bucket will belong.

bucket Bucket

Properties of the new bucket being inserted. The name of the bucket is specified in the bucket_id field. Populating bucket.name field will result in an error. The project of the bucket must be specified in the bucket.project field. This field must be in projects/{projectIdentifier} format, {projectIdentifier} can be the project ID or project number. The parent field must be either empty or projects/_.

bucketId String

Required. The ID to use for this bucket, which will become the final component of the bucket's resource name. For example, the value foo might result in a bucket with the name projects/123456/buckets/foo.

Returns
Type Description
Bucket

createBucketCallable()

public final UnaryCallable<CreateBucketRequest,Bucket> createBucketCallable()

Creates a new bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   CreateBucketRequest request =
       CreateBucketRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setBucket(Bucket.newBuilder().build())
           .setBucketId("bucketId-1603305307")
           .setPredefinedAcl("predefinedAcl1207041188")
           .setPredefinedDefaultObjectAcl("predefinedDefaultObjectAcl2109168048")
           .build();
   ApiFuture<Bucket> future = storageClient.createBucketCallable().futureCall(request);
   // Do something.
   Bucket response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateBucketRequest,Bucket>

createHmacKey(CreateHmacKeyRequest request) (deprecated)

public final CreateHmacKeyResponse createHmacKey(CreateHmacKeyRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

Creates a new HMAC key for the given service account.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   CreateHmacKeyRequest request =
       CreateHmacKeyRequest.newBuilder()
           .setProject(ProjectName.of("[PROJECT]").toString())
           .setServiceAccountEmail("serviceAccountEmail1825953988")
           .build();
   CreateHmacKeyResponse response = storageClient.createHmacKey(request);
 }
 
Parameter
Name Description
request CreateHmacKeyRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
CreateHmacKeyResponse

createHmacKey(ProjectName project, String serviceAccountEmail) (deprecated)

public final CreateHmacKeyResponse createHmacKey(ProjectName project, String serviceAccountEmail)

Deprecated. This method is deprecated and will be removed in the next major version update.

Creates a new HMAC key for the given service account.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ProjectName project = ProjectName.of("[PROJECT]");
   String serviceAccountEmail = "serviceAccountEmail1825953988";
   CreateHmacKeyResponse response = storageClient.createHmacKey(project, serviceAccountEmail);
 }
 
Parameters
Name Description
project ProjectName

Required. The project that the HMAC-owning service account lives in, in the format of "projects/{projectIdentifier}". {projectIdentifier} can be the project ID or project number.

serviceAccountEmail String

Required. The service account to create the HMAC for.

Returns
Type Description
CreateHmacKeyResponse

createHmacKey(String project, String serviceAccountEmail) (deprecated)

public final CreateHmacKeyResponse createHmacKey(String project, String serviceAccountEmail)

Deprecated. This method is deprecated and will be removed in the next major version update.

Creates a new HMAC key for the given service account.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String project = ProjectName.of("[PROJECT]").toString();
   String serviceAccountEmail = "serviceAccountEmail1825953988";
   CreateHmacKeyResponse response = storageClient.createHmacKey(project, serviceAccountEmail);
 }
 
Parameters
Name Description
project String

Required. The project that the HMAC-owning service account lives in, in the format of "projects/{projectIdentifier}". {projectIdentifier} can be the project ID or project number.

serviceAccountEmail String

Required. The service account to create the HMAC for.

Returns
Type Description
CreateHmacKeyResponse

createHmacKeyCallable() (deprecated)

public final UnaryCallable<CreateHmacKeyRequest,CreateHmacKeyResponse> createHmacKeyCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Creates a new HMAC key for the given service account.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   CreateHmacKeyRequest request =
       CreateHmacKeyRequest.newBuilder()
           .setProject(ProjectName.of("[PROJECT]").toString())
           .setServiceAccountEmail("serviceAccountEmail1825953988")
           .build();
   ApiFuture<CreateHmacKeyResponse> future =
       storageClient.createHmacKeyCallable().futureCall(request);
   // Do something.
   CreateHmacKeyResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateHmacKeyRequest,CreateHmacKeyResponse>

createNotificationConfig(BucketName parent, NotificationConfig notificationConfig) (deprecated)

public final NotificationConfig createNotificationConfig(BucketName parent, NotificationConfig notificationConfig)

Deprecated. This method is deprecated and will be removed in the next major version update.

Creates a NotificationConfig for a given bucket. These NotificationConfigs, when triggered, publish messages to the specified Pub/Sub topics. See https://cloud.google.com/storage/docs/pubsub-notifications.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName parent = BucketName.of("[PROJECT]", "[BUCKET]");
   NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
   NotificationConfig response =
       storageClient.createNotificationConfig(parent, notificationConfig);
 }
 
Parameters
Name Description
parent BucketName

Required. The bucket to which this NotificationConfig belongs.

notificationConfig NotificationConfig

Required. Properties of the NotificationConfig to be inserted.

Returns
Type Description
NotificationConfig

createNotificationConfig(CreateNotificationConfigRequest request) (deprecated)

public final NotificationConfig createNotificationConfig(CreateNotificationConfigRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

Creates a NotificationConfig for a given bucket. These NotificationConfigs, when triggered, publish messages to the specified Pub/Sub topics. See https://cloud.google.com/storage/docs/pubsub-notifications.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   CreateNotificationConfigRequest request =
       CreateNotificationConfigRequest.newBuilder()
           .setParent(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setNotificationConfig(NotificationConfig.newBuilder().build())
           .build();
   NotificationConfig response = storageClient.createNotificationConfig(request);
 }
 
Parameter
Name Description
request CreateNotificationConfigRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
NotificationConfig

createNotificationConfig(String parent, NotificationConfig notificationConfig) (deprecated)

public final NotificationConfig createNotificationConfig(String parent, NotificationConfig notificationConfig)

Deprecated. This method is deprecated and will be removed in the next major version update.

Creates a NotificationConfig for a given bucket. These NotificationConfigs, when triggered, publish messages to the specified Pub/Sub topics. See https://cloud.google.com/storage/docs/pubsub-notifications.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String parent = BucketName.of("[PROJECT]", "[BUCKET]").toString();
   NotificationConfig notificationConfig = NotificationConfig.newBuilder().build();
   NotificationConfig response =
       storageClient.createNotificationConfig(parent, notificationConfig);
 }
 
Parameters
Name Description
parent String

Required. The bucket to which this NotificationConfig belongs.

notificationConfig NotificationConfig

Required. Properties of the NotificationConfig to be inserted.

Returns
Type Description
NotificationConfig

createNotificationConfigCallable() (deprecated)

public final UnaryCallable<CreateNotificationConfigRequest,NotificationConfig> createNotificationConfigCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Creates a NotificationConfig for a given bucket. These NotificationConfigs, when triggered, publish messages to the specified Pub/Sub topics. See https://cloud.google.com/storage/docs/pubsub-notifications.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   CreateNotificationConfigRequest request =
       CreateNotificationConfigRequest.newBuilder()
           .setParent(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setNotificationConfig(NotificationConfig.newBuilder().build())
           .build();
   ApiFuture<NotificationConfig> future =
       storageClient.createNotificationConfigCallable().futureCall(request);
   // Do something.
   NotificationConfig response = future.get();
 }
 
Returns
Type Description
UnaryCallable<CreateNotificationConfigRequest,NotificationConfig>

deleteBucket(BucketName name)

public final void deleteBucket(BucketName name)

Permanently deletes an empty bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName name = BucketName.of("[PROJECT]", "[BUCKET]");
   storageClient.deleteBucket(name);
 }
 
Parameter
Name Description
name BucketName

Required. Name of a bucket to delete.

deleteBucket(DeleteBucketRequest request)

public final void deleteBucket(DeleteBucketRequest request)

Permanently deletes an empty bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   DeleteBucketRequest request =
       DeleteBucketRequest.newBuilder()
           .setName(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .build();
   storageClient.deleteBucket(request);
 }
 
Parameter
Name Description
request DeleteBucketRequest

The request object containing all of the parameters for the API call.

deleteBucket(String name)

public final void deleteBucket(String name)

Permanently deletes an empty bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String name = BucketName.of("[PROJECT]", "[BUCKET]").toString();
   storageClient.deleteBucket(name);
 }
 
Parameter
Name Description
name String

Required. Name of a bucket to delete.

deleteBucketCallable()

public final UnaryCallable<DeleteBucketRequest,Empty> deleteBucketCallable()

Permanently deletes an empty bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   DeleteBucketRequest request =
       DeleteBucketRequest.newBuilder()
           .setName(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .build();
   ApiFuture<Empty> future = storageClient.deleteBucketCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteBucketRequest,Empty>

deleteHmacKey(DeleteHmacKeyRequest request) (deprecated)

public final void deleteHmacKey(DeleteHmacKeyRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

Deletes a given HMAC key. Key must be in an INACTIVE state.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   DeleteHmacKeyRequest request =
       DeleteHmacKeyRequest.newBuilder()
           .setAccessId("accessId-2146437729")
           .setProject(ProjectName.of("[PROJECT]").toString())
           .build();
   storageClient.deleteHmacKey(request);
 }
 
Parameter
Name Description
request DeleteHmacKeyRequest

The request object containing all of the parameters for the API call.

deleteHmacKey(String accessId, ProjectName project) (deprecated)

public final void deleteHmacKey(String accessId, ProjectName project)

Deprecated. This method is deprecated and will be removed in the next major version update.

Deletes a given HMAC key. Key must be in an INACTIVE state.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String accessId = "accessId-2146437729";
   ProjectName project = ProjectName.of("[PROJECT]");
   storageClient.deleteHmacKey(accessId, project);
 }
 
Parameters
Name Description
accessId String

Required. The identifying key for the HMAC to delete.

project ProjectName

Required. The project that owns the HMAC key, in the format of "projects/{projectIdentifier}". {projectIdentifier} can be the project ID or project number.

deleteHmacKey(String accessId, String project) (deprecated)

public final void deleteHmacKey(String accessId, String project)

Deprecated. This method is deprecated and will be removed in the next major version update.

Deletes a given HMAC key. Key must be in an INACTIVE state.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String accessId = "accessId-2146437729";
   String project = ProjectName.of("[PROJECT]").toString();
   storageClient.deleteHmacKey(accessId, project);
 }
 
Parameters
Name Description
accessId String

Required. The identifying key for the HMAC to delete.

project String

Required. The project that owns the HMAC key, in the format of "projects/{projectIdentifier}". {projectIdentifier} can be the project ID or project number.

deleteHmacKeyCallable() (deprecated)

public final UnaryCallable<DeleteHmacKeyRequest,Empty> deleteHmacKeyCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Deletes a given HMAC key. Key must be in an INACTIVE state.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   DeleteHmacKeyRequest request =
       DeleteHmacKeyRequest.newBuilder()
           .setAccessId("accessId-2146437729")
           .setProject(ProjectName.of("[PROJECT]").toString())
           .build();
   ApiFuture<Empty> future = storageClient.deleteHmacKeyCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteHmacKeyRequest,Empty>

deleteNotificationConfig(DeleteNotificationConfigRequest request) (deprecated)

public final void deleteNotificationConfig(DeleteNotificationConfigRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

Permanently deletes a NotificationConfig.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   DeleteNotificationConfigRequest request =
       DeleteNotificationConfigRequest.newBuilder()
           .setName(
               NotificationConfigName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION_CONFIG]")
                   .toString())
           .build();
   storageClient.deleteNotificationConfig(request);
 }
 
Parameter
Name Description
request DeleteNotificationConfigRequest

The request object containing all of the parameters for the API call.

deleteNotificationConfig(NotificationConfigName name) (deprecated)

public final void deleteNotificationConfig(NotificationConfigName name)

Deprecated. This method is deprecated and will be removed in the next major version update.

Permanently deletes a NotificationConfig.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   NotificationConfigName name =
       NotificationConfigName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION_CONFIG]");
   storageClient.deleteNotificationConfig(name);
 }
 
Parameter
Name Description
name NotificationConfigName

Required. The parent bucket of the NotificationConfig.

deleteNotificationConfig(String name) (deprecated)

public final void deleteNotificationConfig(String name)

Deprecated. This method is deprecated and will be removed in the next major version update.

Permanently deletes a NotificationConfig.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String name =
       NotificationConfigName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION_CONFIG]").toString();
   storageClient.deleteNotificationConfig(name);
 }
 
Parameter
Name Description
name String

Required. The parent bucket of the NotificationConfig.

deleteNotificationConfigCallable() (deprecated)

public final UnaryCallable<DeleteNotificationConfigRequest,Empty> deleteNotificationConfigCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Permanently deletes a NotificationConfig.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   DeleteNotificationConfigRequest request =
       DeleteNotificationConfigRequest.newBuilder()
           .setName(
               NotificationConfigName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION_CONFIG]")
                   .toString())
           .build();
   ApiFuture<Empty> future =
       storageClient.deleteNotificationConfigCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteNotificationConfigRequest,Empty>

deleteObject(BucketName bucket, String object)

public final void deleteObject(BucketName bucket, String object)

Deletes an object and its metadata.

Deletions are normally permanent when versioning is disabled or whenever the generation parameter is used. However, if soft delete is enabled for the bucket, deleted objects can be restored using RestoreObject until the soft delete retention period has passed.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName bucket = BucketName.of("[PROJECT]", "[BUCKET]");
   String object = "object-1023368385";
   storageClient.deleteObject(bucket, object);
 }
 
Parameters
Name Description
bucket BucketName

Required. Name of the bucket in which the object resides.

object String

Required. The name of the finalized object to delete. Note: If you want to delete an unfinalized resumable upload please use CancelResumableWrite.

deleteObject(BucketName bucket, String object, long generation)

public final void deleteObject(BucketName bucket, String object, long generation)

Deletes an object and its metadata.

Deletions are normally permanent when versioning is disabled or whenever the generation parameter is used. However, if soft delete is enabled for the bucket, deleted objects can be restored using RestoreObject until the soft delete retention period has passed.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName bucket = BucketName.of("[PROJECT]", "[BUCKET]");
   String object = "object-1023368385";
   long generation = 305703192;
   storageClient.deleteObject(bucket, object, generation);
 }
 
Parameters
Name Description
bucket BucketName

Required. Name of the bucket in which the object resides.

object String

Required. The name of the finalized object to delete. Note: If you want to delete an unfinalized resumable upload please use CancelResumableWrite.

generation long

If present, permanently deletes a specific revision of this object (as opposed to the latest version, the default).

deleteObject(DeleteObjectRequest request)

public final void deleteObject(DeleteObjectRequest request)

Deletes an object and its metadata.

Deletions are normally permanent when versioning is disabled or whenever the generation parameter is used. However, if soft delete is enabled for the bucket, deleted objects can be restored using RestoreObject until the soft delete retention period has passed.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   DeleteObjectRequest request =
       DeleteObjectRequest.newBuilder()
           .setBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setObject("object-1023368385")
           .setGeneration(305703192)
           .setIfGenerationMatch(-1086241088)
           .setIfGenerationNotMatch(1475720404)
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .build();
   storageClient.deleteObject(request);
 }
 
Parameter
Name Description
request DeleteObjectRequest

The request object containing all of the parameters for the API call.

deleteObject(String bucket, String object)

public final void deleteObject(String bucket, String object)

Deletes an object and its metadata.

Deletions are normally permanent when versioning is disabled or whenever the generation parameter is used. However, if soft delete is enabled for the bucket, deleted objects can be restored using RestoreObject until the soft delete retention period has passed.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String bucket = BucketName.of("[PROJECT]", "[BUCKET]").toString();
   String object = "object-1023368385";
   storageClient.deleteObject(bucket, object);
 }
 
Parameters
Name Description
bucket String

Required. Name of the bucket in which the object resides.

object String

Required. The name of the finalized object to delete. Note: If you want to delete an unfinalized resumable upload please use CancelResumableWrite.

deleteObject(String bucket, String object, long generation)

public final void deleteObject(String bucket, String object, long generation)

Deletes an object and its metadata.

Deletions are normally permanent when versioning is disabled or whenever the generation parameter is used. However, if soft delete is enabled for the bucket, deleted objects can be restored using RestoreObject until the soft delete retention period has passed.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String bucket = BucketName.of("[PROJECT]", "[BUCKET]").toString();
   String object = "object-1023368385";
   long generation = 305703192;
   storageClient.deleteObject(bucket, object, generation);
 }
 
Parameters
Name Description
bucket String

Required. Name of the bucket in which the object resides.

object String

Required. The name of the finalized object to delete. Note: If you want to delete an unfinalized resumable upload please use CancelResumableWrite.

generation long

If present, permanently deletes a specific revision of this object (as opposed to the latest version, the default).

deleteObjectCallable()

public final UnaryCallable<DeleteObjectRequest,Empty> deleteObjectCallable()

Deletes an object and its metadata.

Deletions are normally permanent when versioning is disabled or whenever the generation parameter is used. However, if soft delete is enabled for the bucket, deleted objects can be restored using RestoreObject until the soft delete retention period has passed.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   DeleteObjectRequest request =
       DeleteObjectRequest.newBuilder()
           .setBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setObject("object-1023368385")
           .setGeneration(305703192)
           .setIfGenerationMatch(-1086241088)
           .setIfGenerationNotMatch(1475720404)
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .build();
   ApiFuture<Empty> future = storageClient.deleteObjectCallable().futureCall(request);
   // Do something.
   future.get();
 }
 
Returns
Type Description
UnaryCallable<DeleteObjectRequest,Empty>

getBucket(BucketName name)

public final Bucket getBucket(BucketName name)

Returns metadata for the specified bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName name = BucketName.of("[PROJECT]", "[BUCKET]");
   Bucket response = storageClient.getBucket(name);
 }
 
Parameter
Name Description
name BucketName

Required. Name of a bucket.

Returns
Type Description
Bucket

getBucket(GetBucketRequest request)

public final Bucket getBucket(GetBucketRequest request)

Returns metadata for the specified bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetBucketRequest request =
       GetBucketRequest.newBuilder()
           .setName(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setReadMask(FieldMask.newBuilder().build())
           .build();
   Bucket response = storageClient.getBucket(request);
 }
 
Parameter
Name Description
request GetBucketRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Bucket

getBucket(String name)

public final Bucket getBucket(String name)

Returns metadata for the specified bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String name = BucketName.of("[PROJECT]", "[BUCKET]").toString();
   Bucket response = storageClient.getBucket(name);
 }
 
Parameter
Name Description
name String

Required. Name of a bucket.

Returns
Type Description
Bucket

getBucketCallable()

public final UnaryCallable<GetBucketRequest,Bucket> getBucketCallable()

Returns metadata for the specified bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetBucketRequest request =
       GetBucketRequest.newBuilder()
           .setName(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setReadMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Bucket> future = storageClient.getBucketCallable().futureCall(request);
   // Do something.
   Bucket response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetBucketRequest,Bucket>

getHmacKey(GetHmacKeyRequest request) (deprecated)

public final HmacKeyMetadata getHmacKey(GetHmacKeyRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

Gets an existing HMAC key metadata for the given id.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetHmacKeyRequest request =
       GetHmacKeyRequest.newBuilder()
           .setAccessId("accessId-2146437729")
           .setProject(ProjectName.of("[PROJECT]").toString())
           .build();
   HmacKeyMetadata response = storageClient.getHmacKey(request);
 }
 
Parameter
Name Description
request GetHmacKeyRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
HmacKeyMetadata

getHmacKey(String accessId, ProjectName project) (deprecated)

public final HmacKeyMetadata getHmacKey(String accessId, ProjectName project)

Deprecated. This method is deprecated and will be removed in the next major version update.

Gets an existing HMAC key metadata for the given id.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String accessId = "accessId-2146437729";
   ProjectName project = ProjectName.of("[PROJECT]");
   HmacKeyMetadata response = storageClient.getHmacKey(accessId, project);
 }
 
Parameters
Name Description
accessId String

Required. The identifying key for the HMAC to delete.

project ProjectName

Required. The project the HMAC key lies in, in the format of "projects/{projectIdentifier}". {projectIdentifier} can be the project ID or project number.

Returns
Type Description
HmacKeyMetadata

getHmacKey(String accessId, String project) (deprecated)

public final HmacKeyMetadata getHmacKey(String accessId, String project)

Deprecated. This method is deprecated and will be removed in the next major version update.

Gets an existing HMAC key metadata for the given id.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String accessId = "accessId-2146437729";
   String project = ProjectName.of("[PROJECT]").toString();
   HmacKeyMetadata response = storageClient.getHmacKey(accessId, project);
 }
 
Parameters
Name Description
accessId String

Required. The identifying key for the HMAC to delete.

project String

Required. The project the HMAC key lies in, in the format of "projects/{projectIdentifier}". {projectIdentifier} can be the project ID or project number.

Returns
Type Description
HmacKeyMetadata

getHmacKeyCallable() (deprecated)

public final UnaryCallable<GetHmacKeyRequest,HmacKeyMetadata> getHmacKeyCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Gets an existing HMAC key metadata for the given id.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetHmacKeyRequest request =
       GetHmacKeyRequest.newBuilder()
           .setAccessId("accessId-2146437729")
           .setProject(ProjectName.of("[PROJECT]").toString())
           .build();
   ApiFuture<HmacKeyMetadata> future = storageClient.getHmacKeyCallable().futureCall(request);
   // Do something.
   HmacKeyMetadata response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetHmacKeyRequest,HmacKeyMetadata>

getIamPolicy(ResourceName resource)

public final Policy getIamPolicy(ResourceName resource)

Gets the IAM policy for a specified bucket. The resource field in the request should be projects/_/buckets/{bucket}.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ResourceName resource =
       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
   Policy response = storageClient.getIamPolicy(resource);
 }
 
Parameter
Name Description
resource com.google.api.resourcenames.ResourceName

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

Returns
Type Description
com.google.iam.v1.Policy

getIamPolicy(GetIamPolicyRequest request)

public final Policy getIamPolicy(GetIamPolicyRequest request)

Gets the IAM policy for a specified bucket. The resource field in the request should be projects/_/buckets/{bucket}.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetIamPolicyRequest request =
       GetIamPolicyRequest.newBuilder()
           .setResource(
               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                   .toString())
           .setOptions(GetPolicyOptions.newBuilder().build())
           .build();
   Policy response = storageClient.getIamPolicy(request);
 }
 
Parameter
Name Description
request com.google.iam.v1.GetIamPolicyRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
com.google.iam.v1.Policy

getIamPolicy(String resource)

public final Policy getIamPolicy(String resource)

Gets the IAM policy for a specified bucket. The resource field in the request should be projects/_/buckets/{bucket}.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String resource =
       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
   Policy response = storageClient.getIamPolicy(resource);
 }
 
Parameter
Name Description
resource String

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

Returns
Type Description
com.google.iam.v1.Policy

getIamPolicyCallable()

public final UnaryCallable<GetIamPolicyRequest,Policy> getIamPolicyCallable()

Gets the IAM policy for a specified bucket. The resource field in the request should be projects/_/buckets/{bucket}.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetIamPolicyRequest request =
       GetIamPolicyRequest.newBuilder()
           .setResource(
               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                   .toString())
           .setOptions(GetPolicyOptions.newBuilder().build())
           .build();
   ApiFuture<Policy> future = storageClient.getIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
Type Description
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy>

getNotificationConfig(GetNotificationConfigRequest request) (deprecated)

public final NotificationConfig getNotificationConfig(GetNotificationConfigRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

View a NotificationConfig.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetNotificationConfigRequest request =
       GetNotificationConfigRequest.newBuilder()
           .setName(
               NotificationConfigName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION_CONFIG]")
                   .toString())
           .build();
   NotificationConfig response = storageClient.getNotificationConfig(request);
 }
 
Parameter
Name Description
request GetNotificationConfigRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
NotificationConfig

getNotificationConfig(NotificationConfigName name) (deprecated)

public final NotificationConfig getNotificationConfig(NotificationConfigName name)

Deprecated. This method is deprecated and will be removed in the next major version update.

View a NotificationConfig.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   NotificationConfigName name =
       NotificationConfigName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION_CONFIG]");
   NotificationConfig response = storageClient.getNotificationConfig(name);
 }
 
Parameter
Name Description
name NotificationConfigName

Required. The parent bucket of the NotificationConfig. Format: projects/{project}/buckets/{bucket}/notificationConfigs/{notificationConfig}

Returns
Type Description
NotificationConfig

getNotificationConfig(String name) (deprecated)

public final NotificationConfig getNotificationConfig(String name)

Deprecated. This method is deprecated and will be removed in the next major version update.

View a NotificationConfig.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String name =
       NotificationConfigName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION_CONFIG]").toString();
   NotificationConfig response = storageClient.getNotificationConfig(name);
 }
 
Parameter
Name Description
name String

Required. The parent bucket of the NotificationConfig. Format: projects/{project}/buckets/{bucket}/notificationConfigs/{notificationConfig}

Returns
Type Description
NotificationConfig

getNotificationConfigCallable() (deprecated)

public final UnaryCallable<GetNotificationConfigRequest,NotificationConfig> getNotificationConfigCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

View a NotificationConfig.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetNotificationConfigRequest request =
       GetNotificationConfigRequest.newBuilder()
           .setName(
               NotificationConfigName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION_CONFIG]")
                   .toString())
           .build();
   ApiFuture<NotificationConfig> future =
       storageClient.getNotificationConfigCallable().futureCall(request);
   // Do something.
   NotificationConfig response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetNotificationConfigRequest,NotificationConfig>

getObject(BucketName bucket, String object)

public final Object getObject(BucketName bucket, String object)

Retrieves an object's metadata.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName bucket = BucketName.of("[PROJECT]", "[BUCKET]");
   String object = "object-1023368385";
   Object response = storageClient.getObject(bucket, object);
 }
 
Parameters
Name Description
bucket BucketName

Required. Name of the bucket in which the object resides.

object String

Required. Name of the object.

Returns
Type Description
Object

getObject(BucketName bucket, String object, long generation)

public final Object getObject(BucketName bucket, String object, long generation)

Retrieves an object's metadata.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName bucket = BucketName.of("[PROJECT]", "[BUCKET]");
   String object = "object-1023368385";
   long generation = 305703192;
   Object response = storageClient.getObject(bucket, object, generation);
 }
 
Parameters
Name Description
bucket BucketName

Required. Name of the bucket in which the object resides.

object String

Required. Name of the object.

generation long

If present, selects a specific revision of this object (as opposed to the latest version, the default).

Returns
Type Description
Object

getObject(GetObjectRequest request)

public final Object getObject(GetObjectRequest request)

Retrieves an object's metadata.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetObjectRequest request =
       GetObjectRequest.newBuilder()
           .setBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setObject("object-1023368385")
           .setGeneration(305703192)
           .setSoftDeleted(true)
           .setIfGenerationMatch(-1086241088)
           .setIfGenerationNotMatch(1475720404)
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .setReadMask(FieldMask.newBuilder().build())
           .build();
   Object response = storageClient.getObject(request);
 }
 
Parameter
Name Description
request GetObjectRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Object

getObject(String bucket, String object)

public final Object getObject(String bucket, String object)

Retrieves an object's metadata.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String bucket = BucketName.of("[PROJECT]", "[BUCKET]").toString();
   String object = "object-1023368385";
   Object response = storageClient.getObject(bucket, object);
 }
 
Parameters
Name Description
bucket String

Required. Name of the bucket in which the object resides.

object String

Required. Name of the object.

Returns
Type Description
Object

getObject(String bucket, String object, long generation)

public final Object getObject(String bucket, String object, long generation)

Retrieves an object's metadata.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String bucket = BucketName.of("[PROJECT]", "[BUCKET]").toString();
   String object = "object-1023368385";
   long generation = 305703192;
   Object response = storageClient.getObject(bucket, object, generation);
 }
 
Parameters
Name Description
bucket String

Required. Name of the bucket in which the object resides.

object String

Required. Name of the object.

generation long

If present, selects a specific revision of this object (as opposed to the latest version, the default).

Returns
Type Description
Object

getObjectCallable()

public final UnaryCallable<GetObjectRequest,Object> getObjectCallable()

Retrieves an object's metadata.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetObjectRequest request =
       GetObjectRequest.newBuilder()
           .setBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setObject("object-1023368385")
           .setGeneration(305703192)
           .setSoftDeleted(true)
           .setIfGenerationMatch(-1086241088)
           .setIfGenerationNotMatch(1475720404)
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .setReadMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Object> future = storageClient.getObjectCallable().futureCall(request);
   // Do something.
   Object response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetObjectRequest,Object>

getServiceAccount(GetServiceAccountRequest request) (deprecated)

public final ServiceAccount getServiceAccount(GetServiceAccountRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

Retrieves the name of a project's Google Cloud Storage service account.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetServiceAccountRequest request =
       GetServiceAccountRequest.newBuilder()
           .setProject(ProjectName.of("[PROJECT]").toString())
           .build();
   ServiceAccount response = storageClient.getServiceAccount(request);
 }
 
Parameter
Name Description
request GetServiceAccountRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
ServiceAccount

getServiceAccount(ProjectName project) (deprecated)

public final ServiceAccount getServiceAccount(ProjectName project)

Deprecated. This method is deprecated and will be removed in the next major version update.

Retrieves the name of a project's Google Cloud Storage service account.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ProjectName project = ProjectName.of("[PROJECT]");
   ServiceAccount response = storageClient.getServiceAccount(project);
 }
 
Parameter
Name Description
project ProjectName

Required. Project ID, in the format of "projects/{projectIdentifier}". {projectIdentifier} can be the project ID or project number.

Returns
Type Description
ServiceAccount

getServiceAccount(String project) (deprecated)

public final ServiceAccount getServiceAccount(String project)

Deprecated. This method is deprecated and will be removed in the next major version update.

Retrieves the name of a project's Google Cloud Storage service account.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String project = ProjectName.of("[PROJECT]").toString();
   ServiceAccount response = storageClient.getServiceAccount(project);
 }
 
Parameter
Name Description
project String

Required. Project ID, in the format of "projects/{projectIdentifier}". {projectIdentifier} can be the project ID or project number.

Returns
Type Description
ServiceAccount

getServiceAccountCallable() (deprecated)

public final UnaryCallable<GetServiceAccountRequest,ServiceAccount> getServiceAccountCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Retrieves the name of a project's Google Cloud Storage service account.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   GetServiceAccountRequest request =
       GetServiceAccountRequest.newBuilder()
           .setProject(ProjectName.of("[PROJECT]").toString())
           .build();
   ApiFuture<ServiceAccount> future =
       storageClient.getServiceAccountCallable().futureCall(request);
   // Do something.
   ServiceAccount response = future.get();
 }
 
Returns
Type Description
UnaryCallable<GetServiceAccountRequest,ServiceAccount>

getSettings()

public final StorageSettings getSettings()
Returns
Type Description
StorageSettings

getStub()

public StorageStub getStub()
Returns
Type Description
StorageStub

isShutdown()

public boolean isShutdown()
Returns
Type Description
boolean

isTerminated()

public boolean isTerminated()
Returns
Type Description
boolean

listBuckets(ListBucketsRequest request)

public final StorageClient.ListBucketsPagedResponse listBuckets(ListBucketsRequest request)

Retrieves a list of buckets for a given project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListBucketsRequest request =
       ListBucketsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setPrefix("prefix-980110702")
           .setReadMask(FieldMask.newBuilder().build())
           .build();
   for (Bucket element : storageClient.listBuckets(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListBucketsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
StorageClient.ListBucketsPagedResponse

listBuckets(ProjectName parent)

public final StorageClient.ListBucketsPagedResponse listBuckets(ProjectName parent)

Retrieves a list of buckets for a given project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ProjectName parent = ProjectName.of("[PROJECT]");
   for (Bucket element : storageClient.listBuckets(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent ProjectName

Required. The project whose buckets we are listing.

Returns
Type Description
StorageClient.ListBucketsPagedResponse

listBuckets(String parent)

public final StorageClient.ListBucketsPagedResponse listBuckets(String parent)

Retrieves a list of buckets for a given project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String parent = ProjectName.of("[PROJECT]").toString();
   for (Bucket element : storageClient.listBuckets(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. The project whose buckets we are listing.

Returns
Type Description
StorageClient.ListBucketsPagedResponse

listBucketsCallable()

public final UnaryCallable<ListBucketsRequest,ListBucketsResponse> listBucketsCallable()

Retrieves a list of buckets for a given project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListBucketsRequest request =
       ListBucketsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setPrefix("prefix-980110702")
           .setReadMask(FieldMask.newBuilder().build())
           .build();
   while (true) {
     ListBucketsResponse response = storageClient.listBucketsCallable().call(request);
     for (Bucket element : response.getBucketsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListBucketsRequest,ListBucketsResponse>

listBucketsPagedCallable()

public final UnaryCallable<ListBucketsRequest,StorageClient.ListBucketsPagedResponse> listBucketsPagedCallable()

Retrieves a list of buckets for a given project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListBucketsRequest request =
       ListBucketsRequest.newBuilder()
           .setParent(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setPrefix("prefix-980110702")
           .setReadMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Bucket> future = storageClient.listBucketsPagedCallable().futureCall(request);
   // Do something.
   for (Bucket element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListBucketsRequest,ListBucketsPagedResponse>

listHmacKeys(ListHmacKeysRequest request) (deprecated)

public final StorageClient.ListHmacKeysPagedResponse listHmacKeys(ListHmacKeysRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

Lists HMAC keys under a given project with the additional filters provided.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListHmacKeysRequest request =
       ListHmacKeysRequest.newBuilder()
           .setProject(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setServiceAccountEmail("serviceAccountEmail1825953988")
           .setShowDeletedKeys(true)
           .build();
   for (HmacKeyMetadata element : storageClient.listHmacKeys(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListHmacKeysRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
StorageClient.ListHmacKeysPagedResponse

listHmacKeys(ProjectName project) (deprecated)

public final StorageClient.ListHmacKeysPagedResponse listHmacKeys(ProjectName project)

Deprecated. This method is deprecated and will be removed in the next major version update.

Lists HMAC keys under a given project with the additional filters provided.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ProjectName project = ProjectName.of("[PROJECT]");
   for (HmacKeyMetadata element : storageClient.listHmacKeys(project).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
project ProjectName

Required. The project to list HMAC keys for, in the format of "projects/{projectIdentifier}". {projectIdentifier} can be the project ID or project number.

Returns
Type Description
StorageClient.ListHmacKeysPagedResponse

listHmacKeys(String project) (deprecated)

public final StorageClient.ListHmacKeysPagedResponse listHmacKeys(String project)

Deprecated. This method is deprecated and will be removed in the next major version update.

Lists HMAC keys under a given project with the additional filters provided.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String project = ProjectName.of("[PROJECT]").toString();
   for (HmacKeyMetadata element : storageClient.listHmacKeys(project).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
project String

Required. The project to list HMAC keys for, in the format of "projects/{projectIdentifier}". {projectIdentifier} can be the project ID or project number.

Returns
Type Description
StorageClient.ListHmacKeysPagedResponse

listHmacKeysCallable() (deprecated)

public final UnaryCallable<ListHmacKeysRequest,ListHmacKeysResponse> listHmacKeysCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Lists HMAC keys under a given project with the additional filters provided.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListHmacKeysRequest request =
       ListHmacKeysRequest.newBuilder()
           .setProject(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setServiceAccountEmail("serviceAccountEmail1825953988")
           .setShowDeletedKeys(true)
           .build();
   while (true) {
     ListHmacKeysResponse response = storageClient.listHmacKeysCallable().call(request);
     for (HmacKeyMetadata element : response.getHmacKeysList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListHmacKeysRequest,ListHmacKeysResponse>

listHmacKeysPagedCallable() (deprecated)

public final UnaryCallable<ListHmacKeysRequest,StorageClient.ListHmacKeysPagedResponse> listHmacKeysPagedCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Lists HMAC keys under a given project with the additional filters provided.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListHmacKeysRequest request =
       ListHmacKeysRequest.newBuilder()
           .setProject(ProjectName.of("[PROJECT]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setServiceAccountEmail("serviceAccountEmail1825953988")
           .setShowDeletedKeys(true)
           .build();
   ApiFuture<HmacKeyMetadata> future =
       storageClient.listHmacKeysPagedCallable().futureCall(request);
   // Do something.
   for (HmacKeyMetadata element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListHmacKeysRequest,ListHmacKeysPagedResponse>

listNotificationConfigs(BucketName parent) (deprecated)

public final StorageClient.ListNotificationConfigsPagedResponse listNotificationConfigs(BucketName parent)

Deprecated. This method is deprecated and will be removed in the next major version update.

Retrieves a list of NotificationConfigs for a given bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName parent = BucketName.of("[PROJECT]", "[BUCKET]");
   for (NotificationConfig element :
       storageClient.listNotificationConfigs(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent BucketName

Required. Name of a Google Cloud Storage bucket.

Returns
Type Description
StorageClient.ListNotificationConfigsPagedResponse

listNotificationConfigs(ListNotificationConfigsRequest request) (deprecated)

public final StorageClient.ListNotificationConfigsPagedResponse listNotificationConfigs(ListNotificationConfigsRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

Retrieves a list of NotificationConfigs for a given bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListNotificationConfigsRequest request =
       ListNotificationConfigsRequest.newBuilder()
           .setParent(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   for (NotificationConfig element :
       storageClient.listNotificationConfigs(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListNotificationConfigsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
StorageClient.ListNotificationConfigsPagedResponse

listNotificationConfigs(String parent) (deprecated)

public final StorageClient.ListNotificationConfigsPagedResponse listNotificationConfigs(String parent)

Deprecated. This method is deprecated and will be removed in the next major version update.

Retrieves a list of NotificationConfigs for a given bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String parent = BucketName.of("[PROJECT]", "[BUCKET]").toString();
   for (NotificationConfig element :
       storageClient.listNotificationConfigs(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. Name of a Google Cloud Storage bucket.

Returns
Type Description
StorageClient.ListNotificationConfigsPagedResponse

listNotificationConfigsCallable() (deprecated)

public final UnaryCallable<ListNotificationConfigsRequest,ListNotificationConfigsResponse> listNotificationConfigsCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Retrieves a list of NotificationConfigs for a given bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListNotificationConfigsRequest request =
       ListNotificationConfigsRequest.newBuilder()
           .setParent(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   while (true) {
     ListNotificationConfigsResponse response =
         storageClient.listNotificationConfigsCallable().call(request);
     for (NotificationConfig element : response.getNotificationConfigsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListNotificationConfigsRequest,ListNotificationConfigsResponse>

listNotificationConfigsPagedCallable() (deprecated)

public final UnaryCallable<ListNotificationConfigsRequest,StorageClient.ListNotificationConfigsPagedResponse> listNotificationConfigsPagedCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Retrieves a list of NotificationConfigs for a given bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListNotificationConfigsRequest request =
       ListNotificationConfigsRequest.newBuilder()
           .setParent(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .build();
   ApiFuture<NotificationConfig> future =
       storageClient.listNotificationConfigsPagedCallable().futureCall(request);
   // Do something.
   for (NotificationConfig element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListNotificationConfigsRequest,ListNotificationConfigsPagedResponse>

listObjects(BucketName parent)

public final StorageClient.ListObjectsPagedResponse listObjects(BucketName parent)

Retrieves a list of objects matching the criteria.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName parent = BucketName.of("[PROJECT]", "[BUCKET]");
   for (Object element : storageClient.listObjects(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent BucketName

Required. Name of the bucket in which to look for objects.

Returns
Type Description
StorageClient.ListObjectsPagedResponse

listObjects(ListObjectsRequest request)

public final StorageClient.ListObjectsPagedResponse listObjects(ListObjectsRequest request)

Retrieves a list of objects matching the criteria.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListObjectsRequest request =
       ListObjectsRequest.newBuilder()
           .setParent(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setDelimiter("delimiter-250518009")
           .setIncludeTrailingDelimiter(true)
           .setPrefix("prefix-980110702")
           .setVersions(true)
           .setReadMask(FieldMask.newBuilder().build())
           .setLexicographicStart("lexicographicStart-2093413008")
           .setLexicographicEnd("lexicographicEnd1646968169")
           .setSoftDeleted(true)
           .setIncludeFoldersAsPrefixes(true)
           .setMatchGlob("matchGlob613636317")
           .build();
   for (Object element : storageClient.listObjects(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
request ListObjectsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
StorageClient.ListObjectsPagedResponse

listObjects(String parent)

public final StorageClient.ListObjectsPagedResponse listObjects(String parent)

Retrieves a list of objects matching the criteria.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String parent = BucketName.of("[PROJECT]", "[BUCKET]").toString();
   for (Object element : storageClient.listObjects(parent).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
Name Description
parent String

Required. Name of the bucket in which to look for objects.

Returns
Type Description
StorageClient.ListObjectsPagedResponse

listObjectsCallable()

public final UnaryCallable<ListObjectsRequest,ListObjectsResponse> listObjectsCallable()

Retrieves a list of objects matching the criteria.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListObjectsRequest request =
       ListObjectsRequest.newBuilder()
           .setParent(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setDelimiter("delimiter-250518009")
           .setIncludeTrailingDelimiter(true)
           .setPrefix("prefix-980110702")
           .setVersions(true)
           .setReadMask(FieldMask.newBuilder().build())
           .setLexicographicStart("lexicographicStart-2093413008")
           .setLexicographicEnd("lexicographicEnd1646968169")
           .setSoftDeleted(true)
           .setIncludeFoldersAsPrefixes(true)
           .setMatchGlob("matchGlob613636317")
           .build();
   while (true) {
     ListObjectsResponse response = storageClient.listObjectsCallable().call(request);
     for (Object element : response.getObjectsList()) {
       // doThingsWith(element);
     }
     String nextPageToken = response.getNextPageToken();
     if (!Strings.isNullOrEmpty(nextPageToken)) {
       request = request.toBuilder().setPageToken(nextPageToken).build();
     } else {
       break;
     }
   }
 }
 
Returns
Type Description
UnaryCallable<ListObjectsRequest,ListObjectsResponse>

listObjectsPagedCallable()

public final UnaryCallable<ListObjectsRequest,StorageClient.ListObjectsPagedResponse> listObjectsPagedCallable()

Retrieves a list of objects matching the criteria.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ListObjectsRequest request =
       ListObjectsRequest.newBuilder()
           .setParent(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setPageSize(883849137)
           .setPageToken("pageToken873572522")
           .setDelimiter("delimiter-250518009")
           .setIncludeTrailingDelimiter(true)
           .setPrefix("prefix-980110702")
           .setVersions(true)
           .setReadMask(FieldMask.newBuilder().build())
           .setLexicographicStart("lexicographicStart-2093413008")
           .setLexicographicEnd("lexicographicEnd1646968169")
           .setSoftDeleted(true)
           .setIncludeFoldersAsPrefixes(true)
           .setMatchGlob("matchGlob613636317")
           .build();
   ApiFuture<Object> future = storageClient.listObjectsPagedCallable().futureCall(request);
   // Do something.
   for (Object element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
Type Description
UnaryCallable<ListObjectsRequest,ListObjectsPagedResponse>

lockBucketRetentionPolicy(BucketName bucket)

public final Bucket lockBucketRetentionPolicy(BucketName bucket)

Locks retention policy on a bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName bucket = BucketName.of("[PROJECT]", "[BUCKET]");
   Bucket response = storageClient.lockBucketRetentionPolicy(bucket);
 }
 
Parameter
Name Description
bucket BucketName

Required. Name of a bucket.

Returns
Type Description
Bucket

lockBucketRetentionPolicy(LockBucketRetentionPolicyRequest request)

public final Bucket lockBucketRetentionPolicy(LockBucketRetentionPolicyRequest request)

Locks retention policy on a bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   LockBucketRetentionPolicyRequest request =
       LockBucketRetentionPolicyRequest.newBuilder()
           .setBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setIfMetagenerationMatch(1043427781)
           .build();
   Bucket response = storageClient.lockBucketRetentionPolicy(request);
 }
 
Parameter
Name Description
request LockBucketRetentionPolicyRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Bucket

lockBucketRetentionPolicy(String bucket)

public final Bucket lockBucketRetentionPolicy(String bucket)

Locks retention policy on a bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String bucket = BucketName.of("[PROJECT]", "[BUCKET]").toString();
   Bucket response = storageClient.lockBucketRetentionPolicy(bucket);
 }
 
Parameter
Name Description
bucket String

Required. Name of a bucket.

Returns
Type Description
Bucket

lockBucketRetentionPolicyCallable()

public final UnaryCallable<LockBucketRetentionPolicyRequest,Bucket> lockBucketRetentionPolicyCallable()

Locks retention policy on a bucket.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   LockBucketRetentionPolicyRequest request =
       LockBucketRetentionPolicyRequest.newBuilder()
           .setBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setIfMetagenerationMatch(1043427781)
           .build();
   ApiFuture<Bucket> future =
       storageClient.lockBucketRetentionPolicyCallable().futureCall(request);
   // Do something.
   Bucket response = future.get();
 }
 
Returns
Type Description
UnaryCallable<LockBucketRetentionPolicyRequest,Bucket>

queryWriteStatus(QueryWriteStatusRequest request)

public final QueryWriteStatusResponse queryWriteStatus(QueryWriteStatusRequest request)

Determines the persisted_size for an object that is being written, which can then be used as the write_offset for the next Write() call.

If the object does not exist (i.e., the object has been deleted, or the first Write() has not yet reached the service), this method returns the error NOT_FOUND.

The client **may** call QueryWriteStatus() at any time to determine how much data has been processed for this object. This is useful if the client is buffering data and needs to know which data can be safely evicted. For any sequence of QueryWriteStatus() calls for a given object name, the sequence of returned persisted_size values will be non-decreasing.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   QueryWriteStatusRequest request =
       QueryWriteStatusRequest.newBuilder()
           .setUploadId("uploadId1563990780")
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .build();
   QueryWriteStatusResponse response = storageClient.queryWriteStatus(request);
 }
 
Parameter
Name Description
request QueryWriteStatusRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
QueryWriteStatusResponse

queryWriteStatus(String uploadId)

public final QueryWriteStatusResponse queryWriteStatus(String uploadId)

Determines the persisted_size for an object that is being written, which can then be used as the write_offset for the next Write() call.

If the object does not exist (i.e., the object has been deleted, or the first Write() has not yet reached the service), this method returns the error NOT_FOUND.

The client **may** call QueryWriteStatus() at any time to determine how much data has been processed for this object. This is useful if the client is buffering data and needs to know which data can be safely evicted. For any sequence of QueryWriteStatus() calls for a given object name, the sequence of returned persisted_size values will be non-decreasing.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String uploadId = "uploadId1563990780";
   QueryWriteStatusResponse response = storageClient.queryWriteStatus(uploadId);
 }
 
Parameter
Name Description
uploadId String

Required. The name of the resume token for the object whose write status is being requested.

Returns
Type Description
QueryWriteStatusResponse

queryWriteStatusCallable()

public final UnaryCallable<QueryWriteStatusRequest,QueryWriteStatusResponse> queryWriteStatusCallable()

Determines the persisted_size for an object that is being written, which can then be used as the write_offset for the next Write() call.

If the object does not exist (i.e., the object has been deleted, or the first Write() has not yet reached the service), this method returns the error NOT_FOUND.

The client **may** call QueryWriteStatus() at any time to determine how much data has been processed for this object. This is useful if the client is buffering data and needs to know which data can be safely evicted. For any sequence of QueryWriteStatus() calls for a given object name, the sequence of returned persisted_size values will be non-decreasing.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   QueryWriteStatusRequest request =
       QueryWriteStatusRequest.newBuilder()
           .setUploadId("uploadId1563990780")
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .build();
   ApiFuture<QueryWriteStatusResponse> future =
       storageClient.queryWriteStatusCallable().futureCall(request);
   // Do something.
   QueryWriteStatusResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<QueryWriteStatusRequest,QueryWriteStatusResponse>

readObjectCallable()

public final ServerStreamingCallable<ReadObjectRequest,ReadObjectResponse> readObjectCallable()

Reads an object's data.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ReadObjectRequest request =
       ReadObjectRequest.newBuilder()
           .setBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setObject("object-1023368385")
           .setGeneration(305703192)
           .setReadOffset(-715377828)
           .setReadLimit(-164298798)
           .setIfGenerationMatch(-1086241088)
           .setIfGenerationNotMatch(1475720404)
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .setReadMask(FieldMask.newBuilder().build())
           .build();
   ServerStream<ReadObjectResponse> stream = storageClient.readObjectCallable().call(request);
   for (ReadObjectResponse response : stream) {
     // Do something when a response is received.
   }
 }
 
Returns
Type Description
ServerStreamingCallable<ReadObjectRequest,ReadObjectResponse>

restoreObject(BucketName bucket, String object, long generation)

public final Object restoreObject(BucketName bucket, String object, long generation)

Restores a soft-deleted object.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   BucketName bucket = BucketName.of("[PROJECT]", "[BUCKET]");
   String object = "object-1023368385";
   long generation = 305703192;
   Object response = storageClient.restoreObject(bucket, object, generation);
 }
 
Parameters
Name Description
bucket BucketName

Required. Name of the bucket in which the object resides.

object String

Required. The name of the object to restore.

generation long

Required. The specific revision of the object to restore.

Returns
Type Description
Object

restoreObject(RestoreObjectRequest request)

public final Object restoreObject(RestoreObjectRequest request)

Restores a soft-deleted object.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   RestoreObjectRequest request =
       RestoreObjectRequest.newBuilder()
           .setBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setObject("object-1023368385")
           .setGeneration(305703192)
           .setIfGenerationMatch(-1086241088)
           .setIfGenerationNotMatch(1475720404)
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setCopySourceAcl(true)
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .build();
   Object response = storageClient.restoreObject(request);
 }
 
Parameter
Name Description
request RestoreObjectRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Object

restoreObject(String bucket, String object, long generation)

public final Object restoreObject(String bucket, String object, long generation)

Restores a soft-deleted object.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String bucket = BucketName.of("[PROJECT]", "[BUCKET]").toString();
   String object = "object-1023368385";
   long generation = 305703192;
   Object response = storageClient.restoreObject(bucket, object, generation);
 }
 
Parameters
Name Description
bucket String

Required. Name of the bucket in which the object resides.

object String

Required. The name of the object to restore.

generation long

Required. The specific revision of the object to restore.

Returns
Type Description
Object

restoreObjectCallable()

public final UnaryCallable<RestoreObjectRequest,Object> restoreObjectCallable()

Restores a soft-deleted object.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   RestoreObjectRequest request =
       RestoreObjectRequest.newBuilder()
           .setBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setObject("object-1023368385")
           .setGeneration(305703192)
           .setIfGenerationMatch(-1086241088)
           .setIfGenerationNotMatch(1475720404)
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setCopySourceAcl(true)
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .build();
   ApiFuture<Object> future = storageClient.restoreObjectCallable().futureCall(request);
   // Do something.
   Object response = future.get();
 }
 
Returns
Type Description
UnaryCallable<RestoreObjectRequest,Object>

rewriteObject(RewriteObjectRequest request)

public final RewriteResponse rewriteObject(RewriteObjectRequest request)

Rewrites a source object to a destination object. Optionally overrides metadata.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   RewriteObjectRequest request =
       RewriteObjectRequest.newBuilder()
           .setDestinationName("destinationName-1762755655")
           .setDestinationBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setDestinationKmsKey(
               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                   .toString())
           .setDestination(Object.newBuilder().build())
           .setSourceBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setSourceObject("sourceObject1196439354")
           .setSourceGeneration(1232209852)
           .setRewriteToken("rewriteToken80654285")
           .setDestinationPredefinedAcl("destinationPredefinedAcl1111125814")
           .setIfGenerationMatch(-1086241088)
           .setIfGenerationNotMatch(1475720404)
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setIfSourceGenerationMatch(-1427877280)
           .setIfSourceGenerationNotMatch(1575612532)
           .setIfSourceMetagenerationMatch(1143319909)
           .setIfSourceMetagenerationNotMatch(1900822777)
           .setMaxBytesRewrittenPerCall(1178170730)
           .setCopySourceEncryptionAlgorithm("copySourceEncryptionAlgorithm-1524952548")
           .setCopySourceEncryptionKeyBytes(ByteString.EMPTY)
           .setCopySourceEncryptionKeySha256Bytes(ByteString.EMPTY)
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .setObjectChecksums(ObjectChecksums.newBuilder().build())
           .build();
   RewriteResponse response = storageClient.rewriteObject(request);
 }
 
Parameter
Name Description
request RewriteObjectRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
RewriteResponse

rewriteObjectCallable()

public final UnaryCallable<RewriteObjectRequest,RewriteResponse> rewriteObjectCallable()

Rewrites a source object to a destination object. Optionally overrides metadata.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   RewriteObjectRequest request =
       RewriteObjectRequest.newBuilder()
           .setDestinationName("destinationName-1762755655")
           .setDestinationBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setDestinationKmsKey(
               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                   .toString())
           .setDestination(Object.newBuilder().build())
           .setSourceBucket(BucketName.of("[PROJECT]", "[BUCKET]").toString())
           .setSourceObject("sourceObject1196439354")
           .setSourceGeneration(1232209852)
           .setRewriteToken("rewriteToken80654285")
           .setDestinationPredefinedAcl("destinationPredefinedAcl1111125814")
           .setIfGenerationMatch(-1086241088)
           .setIfGenerationNotMatch(1475720404)
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setIfSourceGenerationMatch(-1427877280)
           .setIfSourceGenerationNotMatch(1575612532)
           .setIfSourceMetagenerationMatch(1143319909)
           .setIfSourceMetagenerationNotMatch(1900822777)
           .setMaxBytesRewrittenPerCall(1178170730)
           .setCopySourceEncryptionAlgorithm("copySourceEncryptionAlgorithm-1524952548")
           .setCopySourceEncryptionKeyBytes(ByteString.EMPTY)
           .setCopySourceEncryptionKeySha256Bytes(ByteString.EMPTY)
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .setObjectChecksums(ObjectChecksums.newBuilder().build())
           .build();
   ApiFuture<RewriteResponse> future = storageClient.rewriteObjectCallable().futureCall(request);
   // Do something.
   RewriteResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<RewriteObjectRequest,RewriteResponse>

setIamPolicy(ResourceName resource, Policy policy)

public final Policy setIamPolicy(ResourceName resource, Policy policy)

Updates an IAM policy for the specified bucket. The resource field in the request should be projects/_/buckets/{bucket}.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ResourceName resource =
       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
   Policy policy = Policy.newBuilder().build();
   Policy response = storageClient.setIamPolicy(resource, policy);
 }
 
Parameters
Name Description
resource com.google.api.resourcenames.ResourceName

REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

policy com.google.iam.v1.Policy

REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

Returns
Type Description
com.google.iam.v1.Policy

setIamPolicy(SetIamPolicyRequest request)

public final Policy setIamPolicy(SetIamPolicyRequest request)

Updates an IAM policy for the specified bucket. The resource field in the request should be projects/_/buckets/{bucket}.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   SetIamPolicyRequest request =
       SetIamPolicyRequest.newBuilder()
           .setResource(
               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                   .toString())
           .setPolicy(Policy.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Policy response = storageClient.setIamPolicy(request);
 }
 
Parameter
Name Description
request com.google.iam.v1.SetIamPolicyRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
com.google.iam.v1.Policy

setIamPolicy(String resource, Policy policy)

public final Policy setIamPolicy(String resource, Policy policy)

Updates an IAM policy for the specified bucket. The resource field in the request should be projects/_/buckets/{bucket}.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String resource =
       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
   Policy policy = Policy.newBuilder().build();
   Policy response = storageClient.setIamPolicy(resource, policy);
 }
 
Parameters
Name Description
resource String

REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

policy com.google.iam.v1.Policy

REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.

Returns
Type Description
com.google.iam.v1.Policy

setIamPolicyCallable()

public final UnaryCallable<SetIamPolicyRequest,Policy> setIamPolicyCallable()

Updates an IAM policy for the specified bucket. The resource field in the request should be projects/_/buckets/{bucket}.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   SetIamPolicyRequest request =
       SetIamPolicyRequest.newBuilder()
           .setResource(
               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                   .toString())
           .setPolicy(Policy.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Policy> future = storageClient.setIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
Type Description
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

startResumableWrite(StartResumableWriteRequest request)

public final StartResumableWriteResponse startResumableWrite(StartResumableWriteRequest request)

Starts a resumable write. How long the write operation remains valid, and what happens when the write operation becomes invalid, are service-dependent.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   StartResumableWriteRequest request =
       StartResumableWriteRequest.newBuilder()
           .setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .setObjectChecksums(ObjectChecksums.newBuilder().build())
           .build();
   StartResumableWriteResponse response = storageClient.startResumableWrite(request);
 }
 
Parameter
Name Description
request StartResumableWriteRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
StartResumableWriteResponse

startResumableWriteCallable()

public final UnaryCallable<StartResumableWriteRequest,StartResumableWriteResponse> startResumableWriteCallable()

Starts a resumable write. How long the write operation remains valid, and what happens when the write operation becomes invalid, are service-dependent.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   StartResumableWriteRequest request =
       StartResumableWriteRequest.newBuilder()
           .setWriteObjectSpec(WriteObjectSpec.newBuilder().build())
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .setObjectChecksums(ObjectChecksums.newBuilder().build())
           .build();
   ApiFuture<StartResumableWriteResponse> future =
       storageClient.startResumableWriteCallable().futureCall(request);
   // Do something.
   StartResumableWriteResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<StartResumableWriteRequest,StartResumableWriteResponse>

testIamPermissions(ResourceName resource, List<String> permissions)

public final TestIamPermissionsResponse testIamPermissions(ResourceName resource, List<String> permissions)

Tests a set of permissions on the given bucket, object, or managed folder to see which, if any, are held by the caller. The resource field in the request should be projects//buckets/{bucket} for a bucket, projects//buckets/{bucket}/objects/{object} for an object, or projects/_/buckets/{bucket}/managedFolders/{managedFolder} for a managed folder.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ResourceName resource =
       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
   List<String> permissions = new ArrayList<>();
   TestIamPermissionsResponse response = storageClient.testIamPermissions(resource, permissions);
 }
 
Parameters
Name Description
resource com.google.api.resourcenames.ResourceName

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissions List<String>

The set of permissions to check for the resource. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see IAM Overview.

Returns
Type Description
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissions(TestIamPermissionsRequest request)

public final TestIamPermissionsResponse testIamPermissions(TestIamPermissionsRequest request)

Tests a set of permissions on the given bucket, object, or managed folder to see which, if any, are held by the caller. The resource field in the request should be projects//buckets/{bucket} for a bucket, projects//buckets/{bucket}/objects/{object} for an object, or projects/_/buckets/{bucket}/managedFolders/{managedFolder} for a managed folder.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   TestIamPermissionsRequest request =
       TestIamPermissionsRequest.newBuilder()
           .setResource(
               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                   .toString())
           .addAllPermissions(new ArrayList<String>())
           .build();
   TestIamPermissionsResponse response = storageClient.testIamPermissions(request);
 }
 
Parameter
Name Description
request com.google.iam.v1.TestIamPermissionsRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissions(String resource, List<String> permissions)

public final TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions)

Tests a set of permissions on the given bucket, object, or managed folder to see which, if any, are held by the caller. The resource field in the request should be projects//buckets/{bucket} for a bucket, projects//buckets/{bucket}/objects/{object} for an object, or projects/_/buckets/{bucket}/managedFolders/{managedFolder} for a managed folder.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   String resource =
       CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
   List<String> permissions = new ArrayList<>();
   TestIamPermissionsResponse response = storageClient.testIamPermissions(resource, permissions);
 }
 
Parameters
Name Description
resource String

REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.

permissions List<String>

The set of permissions to check for the resource. Permissions with wildcards (such as '*' or 'storage.*') are not allowed. For more information see IAM Overview.

Returns
Type Description
com.google.iam.v1.TestIamPermissionsResponse

testIamPermissionsCallable()

public final UnaryCallable<TestIamPermissionsRequest,TestIamPermissionsResponse> testIamPermissionsCallable()

Tests a set of permissions on the given bucket, object, or managed folder to see which, if any, are held by the caller. The resource field in the request should be projects//buckets/{bucket} for a bucket, projects//buckets/{bucket}/objects/{object} for an object, or projects/_/buckets/{bucket}/managedFolders/{managedFolder} for a managed folder.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   TestIamPermissionsRequest request =
       TestIamPermissionsRequest.newBuilder()
           .setResource(
               CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
                   .toString())
           .addAllPermissions(new ArrayList<String>())
           .build();
   ApiFuture<TestIamPermissionsResponse> future =
       storageClient.testIamPermissionsCallable().futureCall(request);
   // Do something.
   TestIamPermissionsResponse response = future.get();
 }
 
Returns
Type Description
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse>

updateBucket(Bucket bucket, FieldMask updateMask)

public final Bucket updateBucket(Bucket bucket, FieldMask updateMask)

Updates a bucket. Equivalent to JSON API's storage.buckets.patch method.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   Bucket bucket = Bucket.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Bucket response = storageClient.updateBucket(bucket, updateMask);
 }
 
Parameters
Name Description
bucket Bucket

Required. The bucket to update. The bucket's name field will be used to identify the bucket.

updateMask FieldMask

Required. List of fields to be updated.

To specify ALL fields, equivalent to the JSON API's "update" function, specify a single field with the value *. Note: not recommended. If a new field is introduced at a later time, an older client updating with the * may accidentally reset the new field's value.

Not specifying any fields is an error.

Returns
Type Description
Bucket

updateBucket(UpdateBucketRequest request)

public final Bucket updateBucket(UpdateBucketRequest request)

Updates a bucket. Equivalent to JSON API's storage.buckets.patch method.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   UpdateBucketRequest request =
       UpdateBucketRequest.newBuilder()
           .setBucket(Bucket.newBuilder().build())
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setPredefinedAcl("predefinedAcl1207041188")
           .setPredefinedDefaultObjectAcl("predefinedDefaultObjectAcl2109168048")
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   Bucket response = storageClient.updateBucket(request);
 }
 
Parameter
Name Description
request UpdateBucketRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Bucket

updateBucketCallable()

public final UnaryCallable<UpdateBucketRequest,Bucket> updateBucketCallable()

Updates a bucket. Equivalent to JSON API's storage.buckets.patch method.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   UpdateBucketRequest request =
       UpdateBucketRequest.newBuilder()
           .setBucket(Bucket.newBuilder().build())
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setPredefinedAcl("predefinedAcl1207041188")
           .setPredefinedDefaultObjectAcl("predefinedDefaultObjectAcl2109168048")
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<Bucket> future = storageClient.updateBucketCallable().futureCall(request);
   // Do something.
   Bucket response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateBucketRequest,Bucket>

updateHmacKey(HmacKeyMetadata hmacKey, FieldMask updateMask) (deprecated)

public final HmacKeyMetadata updateHmacKey(HmacKeyMetadata hmacKey, FieldMask updateMask)

Deprecated. This method is deprecated and will be removed in the next major version update.

Updates a given HMAC key state between ACTIVE and INACTIVE.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   HmacKeyMetadata hmacKey = HmacKeyMetadata.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   HmacKeyMetadata response = storageClient.updateHmacKey(hmacKey, updateMask);
 }
 
Parameters
Name Description
hmacKey HmacKeyMetadata

Required. The HMAC key to update. If present, the hmac_key's id field will be used to identify the key. Otherwise, the hmac_key's access_id and project fields will be used to identify the key.

updateMask FieldMask

Update mask for hmac_key. Not specifying any fields will mean only the state field is updated to the value specified in hmac_key.

Returns
Type Description
HmacKeyMetadata

updateHmacKey(UpdateHmacKeyRequest request) (deprecated)

public final HmacKeyMetadata updateHmacKey(UpdateHmacKeyRequest request)

Deprecated. This method is deprecated and will be removed in the next major version update.

Updates a given HMAC key state between ACTIVE and INACTIVE.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   UpdateHmacKeyRequest request =
       UpdateHmacKeyRequest.newBuilder()
           .setHmacKey(HmacKeyMetadata.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   HmacKeyMetadata response = storageClient.updateHmacKey(request);
 }
 
Parameter
Name Description
request UpdateHmacKeyRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
HmacKeyMetadata

updateHmacKeyCallable() (deprecated)

public final UnaryCallable<UpdateHmacKeyRequest,HmacKeyMetadata> updateHmacKeyCallable()

Deprecated. This method is deprecated and will be removed in the next major version update.

Updates a given HMAC key state between ACTIVE and INACTIVE.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   UpdateHmacKeyRequest request =
       UpdateHmacKeyRequest.newBuilder()
           .setHmacKey(HmacKeyMetadata.newBuilder().build())
           .setUpdateMask(FieldMask.newBuilder().build())
           .build();
   ApiFuture<HmacKeyMetadata> future = storageClient.updateHmacKeyCallable().futureCall(request);
   // Do something.
   HmacKeyMetadata response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateHmacKeyRequest,HmacKeyMetadata>

updateObject(Object object, FieldMask updateMask)

public final Object updateObject(Object object, FieldMask updateMask)

Updates an object's metadata. Equivalent to JSON API's storage.objects.patch.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   Object object = Object.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Object response = storageClient.updateObject(object, updateMask);
 }
 
Parameters
Name Description
object Object

Required. The object to update. The object's bucket and name fields are used to identify the object to update. If present, the object's generation field selects a specific revision of this object whose metadata should be updated. Otherwise, assumes the live version of the object.

updateMask FieldMask

Required. List of fields to be updated.

To specify ALL fields, equivalent to the JSON API's "update" function, specify a single field with the value *. Note: not recommended. If a new field is introduced at a later time, an older client updating with the * may accidentally reset the new field's value.

Not specifying any fields is an error.

Returns
Type Description
Object

updateObject(UpdateObjectRequest request)

public final Object updateObject(UpdateObjectRequest request)

Updates an object's metadata. Equivalent to JSON API's storage.objects.patch.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   UpdateObjectRequest request =
       UpdateObjectRequest.newBuilder()
           .setObject(Object.newBuilder().build())
           .setIfGenerationMatch(-1086241088)
           .setIfGenerationNotMatch(1475720404)
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setPredefinedAcl("predefinedAcl1207041188")
           .setUpdateMask(FieldMask.newBuilder().build())
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .build();
   Object response = storageClient.updateObject(request);
 }
 
Parameter
Name Description
request UpdateObjectRequest

The request object containing all of the parameters for the API call.

Returns
Type Description
Object

updateObjectCallable()

public final UnaryCallable<UpdateObjectRequest,Object> updateObjectCallable()

Updates an object's metadata. Equivalent to JSON API's storage.objects.patch.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   UpdateObjectRequest request =
       UpdateObjectRequest.newBuilder()
           .setObject(Object.newBuilder().build())
           .setIfGenerationMatch(-1086241088)
           .setIfGenerationNotMatch(1475720404)
           .setIfMetagenerationMatch(1043427781)
           .setIfMetagenerationNotMatch(1025430873)
           .setPredefinedAcl("predefinedAcl1207041188")
           .setUpdateMask(FieldMask.newBuilder().build())
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .build();
   ApiFuture<Object> future = storageClient.updateObjectCallable().futureCall(request);
   // Do something.
   Object response = future.get();
 }
 
Returns
Type Description
UnaryCallable<UpdateObjectRequest,Object>

writeObjectCallable()

public final ClientStreamingCallable<WriteObjectRequest,WriteObjectResponse> writeObjectCallable()

Stores a new object and metadata.

An object can be written either in a single message stream or in a resumable sequence of message streams. To write using a single stream, the client should include in the first message of the stream an WriteObjectSpec describing the destination bucket, object, and any preconditions. Additionally, the final message must set 'finish_write' to true, or else it is an error.

For a resumable write, the client should instead call StartResumableWrite(), populating a WriteObjectSpec into that request. They should then attach the returned upload_id to the first message of each following call to WriteObject. If the stream is closed before finishing the upload (either explicitly by the client or due to a network error or an error response from the server), the client should do as follows: - Check the result Status of the stream, to determine if writing can be resumed on this stream or must be restarted from scratch (by calling StartResumableWrite()). The resumable errors are DEADLINE_EXCEEDED, INTERNAL, and UNAVAILABLE. For each case, the client should use binary exponential backoff before retrying. Additionally, writes can be resumed after RESOURCE_EXHAUSTED errors, but only after taking appropriate measures, which may include reducing aggregate send rate across clients and/or requesting a quota increase for your project. - If the call to WriteObject returns ABORTED, that indicates concurrent attempts to update the resumable write, caused either by multiple racing clients or by a single client where the previous request was timed out on the client side but nonetheless reached the server. In this case the client should take steps to prevent further concurrent writes (e.g., increase the timeouts, stop using more than one process to perform the upload, etc.), and then should follow the steps below for resuming the upload. - For resumable errors, the client should call QueryWriteStatus() and then continue writing from the returned persisted_size. This may be less than the amount of data the client previously sent. Note also that it is acceptable to send data starting at an offset earlier than the returned persisted_size; in this case, the service will skip data at offsets that were already persisted (without checking that it matches the previously written data), and write only the data starting from the persisted offset. Even though the data isn't written, it may still incur a performance cost over resuming at the correct write offset. This behavior can make client-side handling simpler in some cases. - Clients must only send data that is a multiple of 256 KiB per message, unless the object is being finished with finish_write set to true.

The service will not view the object as complete until the client has sent a WriteObjectRequest with finish_write set to true. Sending any requests on a stream after sending a request with finish_write set to true will cause an error. The client **should** check the response it receives to determine how much data the service was able to commit and whether the service views the object as complete.

Attempting to resume an already finalized object will result in an OK status, with a WriteObjectResponse containing the finalized object's metadata.

Alternatively, the BidiWriteObject operation may be used to write an object with controls over flushing and the ability to fetch the ability to determine the current persisted size.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (StorageClient storageClient = StorageClient.create()) {
   ApiStreamObserver<WriteObjectRequest> responseObserver =
       new ApiStreamObserver<WriteObjectRequest>() {
         {@literal @}Override
         public void onNext(WriteObjectResponse response) {
           // Do something when a response is received.
         }

         {@literal @}Override
         public void onError(Throwable t) {
           // Add error-handling
         }

         {@literal @}Override
         public void onCompleted() {
           // Do something when complete.
         }
       };
   ApiStreamObserver<WriteObjectRequest> requestObserver =
       storageClient.writeObject().clientStreamingCall(responseObserver);
   WriteObjectRequest request =
       WriteObjectRequest.newBuilder()
           .setWriteOffset(-1559543565)
           .setObjectChecksums(ObjectChecksums.newBuilder().build())
           .setFinishWrite(true)
           .setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
           .build();
   requestObserver.onNext(request);
 }
 
Returns
Type Description
ClientStreamingCallable<WriteObjectRequest,WriteObjectResponse>