- 2.56.0 (latest)
- 2.55.0
- 2.54.0
- 2.53.3
- 2.52.3
- 2.50.0
- 2.49.0
- 2.48.2
- 2.47.0
- 2.46.0
- 2.45.0
- 2.44.1
- 2.43.2
- 2.42.0
- 2.41.0
- 2.40.1
- 2.39.0
- 2.38.0
- 2.37.0
- 2.36.1
- 2.34.0
- 2.33.0
- 2.32.1
- 2.30.1
- 2.29.1
- 2.28.0
- 2.27.1
- 2.24.0
- 2.23.0
- 2.22.6
- 2.21.0
- 2.20.2
- 2.19.0
- 2.18.0
- 2.17.2
- 2.16.0
- 2.15.1
- 2.14.0
- 2.13.1
- 2.12.0
- 2.11.3
- 2.10.0
- 2.9.3
- 2.8.1
- 2.7.1
- 2.6.1
- 2.5.1
- 2.4.5
- 2.3.0
- 2.2.3
- 2.1.10
public class StorageClient implements BackgroundResource
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().
The surface of this class includes several types of Java methods for each of the API's methods:
- A "flattened" method. With this type of method, the fields of the request type have been converted into function parameters. It may be the case that not all fields are available as parameters, and not every API method will have a flattened method entry point.
- A "request object" method. This type of method only takes one parameter, a request object, which must be constructed before the call. Not every API method will have a request object method.
- A "callable" method. This type of method takes no parameters and returns an immutable API callable object, which can be used to initiate calls to the service.
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.
Implements
BackgroundResourceStatic Methods
create()
public static final StorageClient create()
Constructs an instance of StorageClient with default settings.
Type | Description |
StorageClient |
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.
Name | Description |
settings |
StorageSettings |
Type | Description |
StorageClient |
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).
Name | Description |
stub |
StorageStub |
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.
Name | Description |
settings |
StorageSettings |
StorageClient(StorageStub stub)
protected StorageClient(StorageStub stub)
Name | Description |
stub |
StorageStub |
Methods
awaitTermination(long duration, TimeUnit unit)
public boolean awaitTermination(long duration, TimeUnit unit)
Name | Description |
duration |
long |
unit |
TimeUnit |
Type | Description |
boolean |
Type | Description |
InterruptedException |
cancelResumableWrite(CancelResumableWriteRequest request)
public final CancelResumableWriteResponse cancelResumableWrite(CancelResumableWriteRequest request)
Cancels an in-progress resumable upload.
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);
}
Name | Description |
request |
CancelResumableWriteRequest The request object containing all of the parameters for the API call. |
Type | Description |
CancelResumableWriteResponse |
cancelResumableWrite(String uploadId)
public final CancelResumableWriteResponse cancelResumableWrite(String uploadId)
Cancels an in-progress resumable upload.
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);
}
Name | Description |
uploadId |
String Required. The upload_id of the resumable upload to cancel. This should be
copied from the |
Type | Description |
CancelResumableWriteResponse |
cancelResumableWriteCallable()
public final UnaryCallable<CancelResumableWriteRequest,CancelResumableWriteResponse> cancelResumableWriteCallable()
Cancels an in-progress resumable upload.
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();
}
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);
}
Name | Description |
request |
ComposeObjectRequest The request object containing all of the parameters for the API call. |
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();
}
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);
}
Name | Description |
request |
CreateBucketRequest The request object containing all of the parameters for the API call. |
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);
}
Name | Description |
parent |
ProjectName Required. The project to which this bucket will belong. |
bucket |
Bucket Properties of the new bucket being inserted. The project and name of the bucket
are specified in the parent and bucket_id fields, respectively. Populating those fields in
|
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 |
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);
}
Name | Description |
parent |
String Required. The project to which this bucket will belong. |
bucket |
Bucket Properties of the new bucket being inserted. The project and name of the bucket
are specified in the parent and bucket_id fields, respectively. Populating those fields in
|
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 |
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();
}
Type | Description |
UnaryCallable<CreateBucketRequest,Bucket> |
createHmacKey(CreateHmacKeyRequest request)
public final CreateHmacKeyResponse createHmacKey(CreateHmacKeyRequest request)
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);
}
Name | Description |
request |
CreateHmacKeyRequest The request object containing all of the parameters for the API call. |
Type | Description |
CreateHmacKeyResponse |
createHmacKey(ProjectName project, String serviceAccountEmail)
public final CreateHmacKeyResponse createHmacKey(ProjectName project, String serviceAccountEmail)
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);
}
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. |
Type | Description |
CreateHmacKeyResponse |
createHmacKey(String project, String serviceAccountEmail)
public final CreateHmacKeyResponse createHmacKey(String project, String serviceAccountEmail)
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);
}
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. |
Type | Description |
CreateHmacKeyResponse |
createHmacKeyCallable()
public final UnaryCallable<CreateHmacKeyRequest,CreateHmacKeyResponse> createHmacKeyCallable()
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();
}
Type | Description |
UnaryCallable<CreateHmacKeyRequest,CreateHmacKeyResponse> |
createNotification(CreateNotificationRequest request)
public final Notification createNotification(CreateNotificationRequest request)
Creates a notification subscription for a given bucket. These notifications, 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()) {
CreateNotificationRequest request =
CreateNotificationRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setNotification(Notification.newBuilder().build())
.build();
Notification response = storageClient.createNotification(request);
}
Name | Description |
request |
CreateNotificationRequest The request object containing all of the parameters for the API call. |
Type | Description |
Notification |
createNotification(ProjectName parent, Notification notification)
public final Notification createNotification(ProjectName parent, Notification notification)
Creates a notification subscription for a given bucket. These notifications, 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()) {
ProjectName parent = ProjectName.of("[PROJECT]");
Notification notification = Notification.newBuilder().build();
Notification response = storageClient.createNotification(parent, notification);
}
Name | Description |
parent |
ProjectName Required. The bucket to which this notification belongs. |
notification |
Notification Required. Properties of the notification to be inserted. |
Type | Description |
Notification |
createNotification(String parent, Notification notification)
public final Notification createNotification(String parent, Notification notification)
Creates a notification subscription for a given bucket. These notifications, 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 = ProjectName.of("[PROJECT]").toString();
Notification notification = Notification.newBuilder().build();
Notification response = storageClient.createNotification(parent, notification);
}
Name | Description |
parent |
String Required. The bucket to which this notification belongs. |
notification |
Notification Required. Properties of the notification to be inserted. |
Type | Description |
Notification |
createNotificationCallable()
public final UnaryCallable<CreateNotificationRequest,Notification> createNotificationCallable()
Creates a notification subscription for a given bucket. These notifications, 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()) {
CreateNotificationRequest request =
CreateNotificationRequest.newBuilder()
.setParent(ProjectName.of("[PROJECT]").toString())
.setNotification(Notification.newBuilder().build())
.build();
ApiFuture<Notification> future =
storageClient.createNotificationCallable().futureCall(request);
// Do something.
Notification response = future.get();
}
Type | Description |
UnaryCallable<CreateNotificationRequest,Notification> |
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);
}
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);
}
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);
}
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();
}
Type | Description |
UnaryCallable<DeleteBucketRequest,Empty> |
deleteHmacKey(DeleteHmacKeyRequest request)
public final void deleteHmacKey(DeleteHmacKeyRequest request)
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);
}
Name | Description |
request |
DeleteHmacKeyRequest The request object containing all of the parameters for the API call. |
deleteHmacKey(String accessId, ProjectName project)
public final void deleteHmacKey(String accessId, ProjectName project)
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);
}
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)
public final void deleteHmacKey(String accessId, String project)
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);
}
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()
public final UnaryCallable<DeleteHmacKeyRequest,Empty> deleteHmacKeyCallable()
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();
}
Type | Description |
UnaryCallable<DeleteHmacKeyRequest,Empty> |
deleteNotification(DeleteNotificationRequest request)
public final void deleteNotification(DeleteNotificationRequest request)
Permanently deletes a notification subscription.
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()) {
DeleteNotificationRequest request =
DeleteNotificationRequest.newBuilder()
.setName(NotificationName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION]").toString())
.build();
storageClient.deleteNotification(request);
}
Name | Description |
request |
DeleteNotificationRequest The request object containing all of the parameters for the API call. |
deleteNotification(NotificationName name)
public final void deleteNotification(NotificationName name)
Permanently deletes a notification subscription.
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()) {
NotificationName name = NotificationName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION]");
storageClient.deleteNotification(name);
}
Name | Description |
name |
NotificationName Required. The parent bucket of the notification. |
deleteNotification(String name)
public final void deleteNotification(String name)
Permanently deletes a notification subscription.
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 = NotificationName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION]").toString();
storageClient.deleteNotification(name);
}
Name | Description |
name |
String Required. The parent bucket of the notification. |
deleteNotificationCallable()
public final UnaryCallable<DeleteNotificationRequest,Empty> deleteNotificationCallable()
Permanently deletes a notification subscription.
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()) {
DeleteNotificationRequest request =
DeleteNotificationRequest.newBuilder()
.setName(NotificationName.of("[PROJECT]", "[BUCKET]", "[NOTIFICATION]").toString())
.build();
ApiFuture<Empty> future = storageClient.deleteNotificationCallable().futureCall(request);
// Do something.
future.get();
}
Type | Description |
UnaryCallable<DeleteNotificationRequest,Empty> |
deleteObject(DeleteObjectRequest request)
public final void deleteObject(DeleteObjectRequest request)
Deletes an object and its metadata. Deletions are permanent if versioning is not enabled for
the bucket, or if the generation
parameter is used.
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("bucket-1378203158")
.setObject("object-1023368385")
.setGeneration(305703192)
.setIfGenerationMatch(-1086241088)
.setIfGenerationNotMatch(1475720404)
.setIfMetagenerationMatch(1043427781)
.setIfMetagenerationNotMatch(1025430873)
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
.build();
storageClient.deleteObject(request);
}
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 permanent if versioning is not enabled for
the bucket, or if the generation
parameter is used.
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 = "bucket-1378203158";
String object = "object-1023368385";
storageClient.deleteObject(bucket, object);
}
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 |
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 permanent if versioning is not enabled for
the bucket, or if the generation
parameter is used.
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 = "bucket-1378203158";
String object = "object-1023368385";
long generation = 305703192;
storageClient.deleteObject(bucket, object, generation);
}
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 |
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 permanent if versioning is not enabled for
the bucket, or if the generation
parameter is used.
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("bucket-1378203158")
.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();
}
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);
}
Name | Description |
name |
BucketName Required. Name of a bucket. |
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);
}
Name | Description |
request |
GetBucketRequest The request object containing all of the parameters for the API call. |
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);
}
Name | Description |
name |
String Required. Name of a bucket. |
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();
}
Type | Description |
UnaryCallable<GetBucketRequest,Bucket> |
getHmacKey(GetHmacKeyRequest request)
public final HmacKeyMetadata getHmacKey(GetHmacKeyRequest request)
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);
}
Name | Description |
request |
GetHmacKeyRequest The request object containing all of the parameters for the API call. |
Type | Description |
HmacKeyMetadata |
getHmacKey(String accessId, ProjectName project)
public final HmacKeyMetadata getHmacKey(String accessId, ProjectName project)
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);
}
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. |
Type | Description |
HmacKeyMetadata |
getHmacKey(String accessId, String project)
public final HmacKeyMetadata getHmacKey(String accessId, String project)
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);
}
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. |
Type | Description |
HmacKeyMetadata |
getHmacKeyCallable()
public final UnaryCallable<GetHmacKeyRequest,HmacKeyMetadata> getHmacKeyCallable()
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();
}
Type | Description |
UnaryCallable<GetHmacKeyRequest,HmacKeyMetadata> |
getIamPolicy(ResourceName resource)
public final Policy getIamPolicy(ResourceName resource)
Gets the IAM policy for a specified bucket or object. The resource
field in the request
should be projects//buckets/<bucket_name> for a bucket or
projects//buckets/<bucket_name>/objects/<object_name> for an 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()) {
ResourceName resource =
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]");
Policy response = storageClient.getIamPolicy(resource);
}
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. |
Type | Description |
com.google.iam.v1.Policy |
getIamPolicy(GetIamPolicyRequest request)
public final Policy getIamPolicy(GetIamPolicyRequest request)
Gets the IAM policy for a specified bucket or object. The resource
field in the request
should be projects//buckets/<bucket_name> for a bucket or
projects//buckets/<bucket_name>/objects/<object_name> for an 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()) {
GetIamPolicyRequest request =
GetIamPolicyRequest.newBuilder()
.setResource(
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]")
.toString())
.setOptions(GetPolicyOptions.newBuilder().build())
.build();
Policy response = storageClient.getIamPolicy(request);
}
Name | Description |
request |
com.google.iam.v1.GetIamPolicyRequest The request object containing all of the parameters for the API call. |
Type | Description |
com.google.iam.v1.Policy |
getIamPolicy(String resource)
public final Policy getIamPolicy(String resource)
Gets the IAM policy for a specified bucket or object. The resource
field in the request
should be projects//buckets/<bucket_name> for a bucket or
projects//buckets/<bucket_name>/objects/<object_name> for an 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 resource =
CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString();
Policy response = storageClient.getIamPolicy(resource);
}
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. |
Type | Description |
com.google.iam.v1.Policy |
getIamPolicyCallable()
public final UnaryCallable<GetIamPolicyRequest,Policy> getIamPolicyCallable()
Gets the IAM policy for a specified bucket or object. The resource
field in the request
should be projects//buckets/<bucket_name> for a bucket or
projects//buckets/<bucket_name>/objects/<object_name> for an 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()) {
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();
}
Type | Description |
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getNotification(BucketName name)
public final Notification getNotification(BucketName name)
View a notification config.
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]");
Notification response = storageClient.getNotification(name);
}
Name | Description |
name |
BucketName Required. The parent bucket of the notification. Format:
|
Type | Description |
Notification |
getNotification(GetNotificationRequest request)
public final Notification getNotification(GetNotificationRequest request)
View a notification config.
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()) {
GetNotificationRequest request =
GetNotificationRequest.newBuilder()
.setName(BucketName.of("[PROJECT]", "[BUCKET]").toString())
.build();
Notification response = storageClient.getNotification(request);
}
Name | Description |
request |
GetNotificationRequest The request object containing all of the parameters for the API call. |
Type | Description |
Notification |
getNotification(String name)
public final Notification getNotification(String name)
View a notification config.
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();
Notification response = storageClient.getNotification(name);
}
Name | Description |
name |
String Required. The parent bucket of the notification. Format:
|
Type | Description |
Notification |
getNotificationCallable()
public final UnaryCallable<GetNotificationRequest,Notification> getNotificationCallable()
View a notification config.
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()) {
GetNotificationRequest request =
GetNotificationRequest.newBuilder()
.setName(BucketName.of("[PROJECT]", "[BUCKET]").toString())
.build();
ApiFuture<Notification> future = storageClient.getNotificationCallable().futureCall(request);
// Do something.
Notification response = future.get();
}
Type | Description |
UnaryCallable<GetNotificationRequest,Notification> |
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("bucket-1378203158")
.setObject("object-1023368385")
.setGeneration(305703192)
.setIfGenerationMatch(-1086241088)
.setIfGenerationNotMatch(1475720404)
.setIfMetagenerationMatch(1043427781)
.setIfMetagenerationNotMatch(1025430873)
.setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build())
.setReadMask(FieldMask.newBuilder().build())
.build();
Object response = storageClient.getObject(request);
}
Name | Description |
request |
GetObjectRequest The request object containing all of the parameters for the API call. |
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 = "bucket-1378203158";
String object = "object-1023368385";
Object response = storageClient.getObject(bucket, object);
}
Name | Description |
bucket |
String Required. Name of the bucket in which the object resides. |
object |
String Required. Name of the object. |
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 = "bucket-1378203158";
String object = "object-1023368385";
long generation = 305703192;
Object response = storageClient.getObject(bucket, object, generation);
}
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). |
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("bucket-1378203158")
.setObject("object-1023368385")
.setGeneration(305703192)
.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();
}
Type | Description |
UnaryCallable<GetObjectRequest,Object> |
getServiceAccount(GetServiceAccountRequest request)
public final ServiceAccount getServiceAccount(GetServiceAccountRequest request)
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);
}
Name | Description |
request |
GetServiceAccountRequest The request object containing all of the parameters for the API call. |
Type | Description |
|