| GitHub Repository | Product Reference |
Service Description: The RegionSnapshots API.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
String project = "project-309310695";
String region = "region-934795532";
String snapshot = "snapshot284874180";
Snapshot response = regionSnapshotsClient.get(project, region, snapshot);
}
Note: close() needs to be called on the RegionSnapshotsClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
| Method | Description | Method Variants |
|---|---|---|
Delete |
Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot. For more information, seeDeleting snapshots. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
Get |
Returns the specified Snapshot resource. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
GetIamPolicy |
Gets the access control policy for a resource. May be empty if no such policy or resource exists. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
Insert |
Creates a snapshot in the specified region using the data included in the request. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
List |
Retrieves the list of Snapshot resources contained within the specified region. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
SetIamPolicy |
Sets the access control policy on the specified resource. Replaces any existing policy. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
SetLabels |
Sets the labels on a regional snapshot. To learn more about labels, read the Labeling Resources documentation. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
TestIamPermissions |
Returns permissions that a caller has on the specified resource. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.
Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.
|
UpdateKmsKey |
Rotates the customer-managed encryption key to the latest version for the specified snapshot. |
Request object method variants only take one parameter, a request object, which must be constructed before the call.
Methods that return long-running operations have "Async" method variants that return
Callable method variants take no parameters and return 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 RegionSnapshotsSettings 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
RegionSnapshotsSettings regionSnapshotsSettings =
RegionSnapshotsSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
RegionSnapshotsClient regionSnapshotsClient =
RegionSnapshotsClient.create(regionSnapshotsSettings);
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
RegionSnapshotsSettings regionSnapshotsSettings =
RegionSnapshotsSettings.newBuilder().setEndpoint(myEndpoint).build();
RegionSnapshotsClient regionSnapshotsClient =
RegionSnapshotsClient.create(regionSnapshotsSettings);
Please refer to the GitHub repository's samples for more quickstart code snippets.
Static Methods
create()
public static final RegionSnapshotsClient create()Constructs an instance of RegionSnapshotsClient with default settings.
| Returns | |
|---|---|
| Type | Description |
RegionSnapshotsClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(RegionSnapshotsSettings settings)
public static final RegionSnapshotsClient create(RegionSnapshotsSettings settings)Constructs an instance of RegionSnapshotsClient, 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 |
RegionSnapshotsSettings |
| Returns | |
|---|---|
| Type | Description |
RegionSnapshotsClient |
|
| Exceptions | |
|---|---|
| Type | Description |
IOException |
|
create(RegionSnapshotsStub stub)
public static final RegionSnapshotsClient create(RegionSnapshotsStub stub)Constructs an instance of RegionSnapshotsClient, using the given stub for making calls. This is for advanced usage - prefer using create(RegionSnapshotsSettings).
| Parameter | |
|---|---|
| Name | Description |
stub |
RegionSnapshotsStub |
| Returns | |
|---|---|
| Type | Description |
RegionSnapshotsClient |
|
Constructors
RegionSnapshotsClient(RegionSnapshotsSettings settings)
protected RegionSnapshotsClient(RegionSnapshotsSettings settings)Constructs an instance of RegionSnapshotsClient, 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 |
RegionSnapshotsSettings |
RegionSnapshotsClient(RegionSnapshotsStub stub)
protected RegionSnapshotsClient(RegionSnapshotsStub stub)| Parameter | |
|---|---|
| Name | Description |
stub |
RegionSnapshotsStub |
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 |
|
close()
public final void close()deleteAsync(DeleteRegionSnapshotRequest request)
public final OperationFuture<Operation,Operation> deleteAsync(DeleteRegionSnapshotRequest request)Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot.
For more information, seeDeleting snapshots.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
DeleteRegionSnapshotRequest request =
DeleteRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRequestId("requestId693933066")
.setSnapshot("snapshot284874180")
.build();
Operation response = regionSnapshotsClient.deleteAsync(request).get();
}
| Parameter | |
|---|---|
| Name | Description |
request |
DeleteRegionSnapshotRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<Operation,Operation> |
|
deleteAsync(String project, String region, String snapshot)
public final OperationFuture<Operation,Operation> deleteAsync(String project, String region, String snapshot)Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot.
For more information, seeDeleting snapshots.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
String project = "project-309310695";
String region = "region-934795532";
String snapshot = "snapshot284874180";
Operation response = regionSnapshotsClient.deleteAsync(project, region, snapshot).get();
}
| Parameters | |
|---|---|
| Name | Description |
project |
StringProject ID for this request. |
region |
StringThe name of the region for this request. |
snapshot |
StringName of the snapshot resource to delete. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<Operation,Operation> |
|
deleteCallable()
public final UnaryCallable<DeleteRegionSnapshotRequest,Operation> deleteCallable()Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot.
For more information, seeDeleting snapshots.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
DeleteRegionSnapshotRequest request =
DeleteRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRequestId("requestId693933066")
.setSnapshot("snapshot284874180")
.build();
ApiFuture<Operation> future = regionSnapshotsClient.deleteCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<DeleteRegionSnapshotRequest,Operation> |
|
deleteOperationCallable()
public final OperationCallable<DeleteRegionSnapshotRequest,Operation,Operation> deleteOperationCallable()Deletes the specified Snapshot resource. Keep in mind that deleting a single snapshot might not necessarily delete all the data on that snapshot. If any data on the snapshot that is marked for deletion is needed for subsequent snapshots, the data will be moved to the next corresponding snapshot.
For more information, seeDeleting snapshots.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
DeleteRegionSnapshotRequest request =
DeleteRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRequestId("requestId693933066")
.setSnapshot("snapshot284874180")
.build();
OperationFuture<Operation, Operation> future =
regionSnapshotsClient.deleteOperationCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
OperationCallable<DeleteRegionSnapshotRequest,Operation,Operation> |
|
get(GetRegionSnapshotRequest request)
public final Snapshot get(GetRegionSnapshotRequest request)Returns the specified Snapshot resource.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
GetRegionSnapshotRequest request =
GetRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setSnapshot("snapshot284874180")
.build();
Snapshot response = regionSnapshotsClient.get(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
GetRegionSnapshotRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Snapshot |
|
get(String project, String region, String snapshot)
public final Snapshot get(String project, String region, String snapshot)Returns the specified Snapshot resource.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
String project = "project-309310695";
String region = "region-934795532";
String snapshot = "snapshot284874180";
Snapshot response = regionSnapshotsClient.get(project, region, snapshot);
}
| Parameters | |
|---|---|
| Name | Description |
project |
StringProject ID for this request. |
region |
StringName of the region for this request. |
snapshot |
StringName of the Snapshot resource to return. |
| Returns | |
|---|---|
| Type | Description |
Snapshot |
|
getCallable()
public final UnaryCallable<GetRegionSnapshotRequest,Snapshot> getCallable()Returns the specified Snapshot resource.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
GetRegionSnapshotRequest request =
GetRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setSnapshot("snapshot284874180")
.build();
ApiFuture<Snapshot> future = regionSnapshotsClient.getCallable().futureCall(request);
// Do something.
Snapshot response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<GetRegionSnapshotRequest,Snapshot> |
|
getIamPolicy(GetIamPolicyRegionSnapshotRequest request)
public final Policy getIamPolicy(GetIamPolicyRegionSnapshotRequest request)Gets the access control policy for a resource. May be empty if no such policy or resource exists.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
GetIamPolicyRegionSnapshotRequest request =
GetIamPolicyRegionSnapshotRequest.newBuilder()
.setOptionsRequestedPolicyVersion(-574521795)
.setProject("project-309310695")
.setRegion("region-934795532")
.setResource("resource-341064690")
.build();
Policy response = regionSnapshotsClient.getIamPolicy(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
GetIamPolicyRegionSnapshotRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Policy |
|
getIamPolicy(String project, String region, String resource)
public final Policy getIamPolicy(String project, String region, String resource)Gets the access control policy for a resource. May be empty if no such policy or resource exists.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
String project = "project-309310695";
String region = "region-934795532";
String resource = "resource-341064690";
Policy response = regionSnapshotsClient.getIamPolicy(project, region, resource);
}
| Parameters | |
|---|---|
| Name | Description |
project |
StringProject ID for this request. |
region |
StringThe name of the region for this request. |
resource |
StringName or id of the resource for this request. |
| Returns | |
|---|---|
| Type | Description |
Policy |
|
getIamPolicyCallable()
public final UnaryCallable<GetIamPolicyRegionSnapshotRequest,Policy> getIamPolicyCallable()Gets the access control policy for a resource. May be empty if no such policy or resource exists.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
GetIamPolicyRegionSnapshotRequest request =
GetIamPolicyRegionSnapshotRequest.newBuilder()
.setOptionsRequestedPolicyVersion(-574521795)
.setProject("project-309310695")
.setRegion("region-934795532")
.setResource("resource-341064690")
.build();
ApiFuture<Policy> future = regionSnapshotsClient.getIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<GetIamPolicyRegionSnapshotRequest,Policy> |
|
getSettings()
public final @Nullable RegionSnapshotsSettings getSettings()| Returns | |
|---|---|
| Type | Description |
@org.jspecify.annotations.Nullable com.google.cloud.compute.v1.RegionSnapshotsSettings |
|
getStub()
public RegionSnapshotsStub getStub()| Returns | |
|---|---|
| Type | Description |
RegionSnapshotsStub |
|
insertAsync(InsertRegionSnapshotRequest request)
public final OperationFuture<Operation,Operation> insertAsync(InsertRegionSnapshotRequest request)Creates a snapshot in the specified region using the data included in the request.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
InsertRegionSnapshotRequest request =
InsertRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRequestId("requestId693933066")
.setSnapshotResource(Snapshot.newBuilder().build())
.build();
Operation response = regionSnapshotsClient.insertAsync(request).get();
}
| Parameter | |
|---|---|
| Name | Description |
request |
InsertRegionSnapshotRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<Operation,Operation> |
|
insertAsync(String project, String region, Snapshot snapshotResource)
public final OperationFuture<Operation,Operation> insertAsync(String project, String region, Snapshot snapshotResource)Creates a snapshot in the specified region using the data included in the request.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
String project = "project-309310695";
String region = "region-934795532";
Snapshot snapshotResource = Snapshot.newBuilder().build();
Operation response =
regionSnapshotsClient.insertAsync(project, region, snapshotResource).get();
}
| Parameters | |
|---|---|
| Name | Description |
project |
StringProject ID for this request. |
region |
StringName of the region for this request. |
snapshotResource |
SnapshotThe body resource for this request |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<Operation,Operation> |
|
insertCallable()
public final UnaryCallable<InsertRegionSnapshotRequest,Operation> insertCallable()Creates a snapshot in the specified region using the data included in the request.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
InsertRegionSnapshotRequest request =
InsertRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRequestId("requestId693933066")
.setSnapshotResource(Snapshot.newBuilder().build())
.build();
ApiFuture<Operation> future = regionSnapshotsClient.insertCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<InsertRegionSnapshotRequest,Operation> |
|
insertOperationCallable()
public final OperationCallable<InsertRegionSnapshotRequest,Operation,Operation> insertOperationCallable()Creates a snapshot in the specified region using the data included in the request.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
InsertRegionSnapshotRequest request =
InsertRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRequestId("requestId693933066")
.setSnapshotResource(Snapshot.newBuilder().build())
.build();
OperationFuture<Operation, Operation> future =
regionSnapshotsClient.insertOperationCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
OperationCallable<InsertRegionSnapshotRequest,Operation,Operation> |
|
isShutdown()
public boolean isShutdown()| Returns | |
|---|---|
| Type | Description |
boolean |
|
isTerminated()
public boolean isTerminated()| Returns | |
|---|---|
| Type | Description |
boolean |
|
list(ListRegionSnapshotsRequest request)
public final RegionSnapshotsClient.ListPagedResponse list(ListRegionSnapshotsRequest request)Retrieves the list of Snapshot resources contained within the specified region.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
ListRegionSnapshotsRequest request =
ListRegionSnapshotsRequest.newBuilder()
.setFilter("filter-1274492040")
.setMaxResults(1128457243)
.setOrderBy("orderBy-1207110587")
.setPageToken("pageToken873572522")
.setProject("project-309310695")
.setRegion("region-934795532")
.setReturnPartialSuccess(true)
.build();
for (Snapshot element : regionSnapshotsClient.list(request).iterateAll()) {
// doThingsWith(element);
}
}
| Parameter | |
|---|---|
| Name | Description |
request |
ListRegionSnapshotsRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
RegionSnapshotsClient.ListPagedResponse |
|
list(String project, String region)
public final RegionSnapshotsClient.ListPagedResponse list(String project, String region)Retrieves the list of Snapshot resources contained within the specified region.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
String project = "project-309310695";
String region = "region-934795532";
for (Snapshot element : regionSnapshotsClient.list(project, region).iterateAll()) {
// doThingsWith(element);
}
}
| Parameters | |
|---|---|
| Name | Description |
project |
StringProject ID for this request. |
region |
StringName of the region for this request. |
| Returns | |
|---|---|
| Type | Description |
RegionSnapshotsClient.ListPagedResponse |
|
listCallable()
public final UnaryCallable<ListRegionSnapshotsRequest,SnapshotList> listCallable()Retrieves the list of Snapshot resources contained within the specified region.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
ListRegionSnapshotsRequest request =
ListRegionSnapshotsRequest.newBuilder()
.setFilter("filter-1274492040")
.setMaxResults(1128457243)
.setOrderBy("orderBy-1207110587")
.setPageToken("pageToken873572522")
.setProject("project-309310695")
.setRegion("region-934795532")
.setReturnPartialSuccess(true)
.build();
while (true) {
SnapshotList response = regionSnapshotsClient.listCallable().call(request);
for (Snapshot element : response.getItemsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListRegionSnapshotsRequest,SnapshotList> |
|
listPagedCallable()
public final UnaryCallable<ListRegionSnapshotsRequest,RegionSnapshotsClient.ListPagedResponse> listPagedCallable()Retrieves the list of Snapshot resources contained within the specified region.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
ListRegionSnapshotsRequest request =
ListRegionSnapshotsRequest.newBuilder()
.setFilter("filter-1274492040")
.setMaxResults(1128457243)
.setOrderBy("orderBy-1207110587")
.setPageToken("pageToken873572522")
.setProject("project-309310695")
.setRegion("region-934795532")
.setReturnPartialSuccess(true)
.build();
ApiFuture<Snapshot> future = regionSnapshotsClient.listPagedCallable().futureCall(request);
// Do something.
for (Snapshot element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<ListRegionSnapshotsRequest,ListPagedResponse> |
|
setIamPolicy(SetIamPolicyRegionSnapshotRequest request)
public final Policy setIamPolicy(SetIamPolicyRegionSnapshotRequest request)Sets the access control policy on the specified resource. Replaces any existing policy.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
SetIamPolicyRegionSnapshotRequest request =
SetIamPolicyRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRegionSetPolicyRequestResource(RegionSetPolicyRequest.newBuilder().build())
.setResource("resource-341064690")
.build();
Policy response = regionSnapshotsClient.setIamPolicy(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
SetIamPolicyRegionSnapshotRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
Policy |
|
setIamPolicy(String project, String region, String resource, RegionSetPolicyRequest regionSetPolicyRequestResource)
public final Policy setIamPolicy(String project, String region, String resource, RegionSetPolicyRequest regionSetPolicyRequestResource)Sets the access control policy on the specified resource. Replaces any existing policy.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
String project = "project-309310695";
String region = "region-934795532";
String resource = "resource-341064690";
RegionSetPolicyRequest regionSetPolicyRequestResource =
RegionSetPolicyRequest.newBuilder().build();
Policy response =
regionSnapshotsClient.setIamPolicy(
project, region, resource, regionSetPolicyRequestResource);
}
| Parameters | |
|---|---|
| Name | Description |
project |
StringProject ID for this request. |
region |
StringThe name of the region for this request. |
resource |
StringName or id of the resource for this request. |
regionSetPolicyRequestResource |
RegionSetPolicyRequestThe body resource for this request |
| Returns | |
|---|---|
| Type | Description |
Policy |
|
setIamPolicyCallable()
public final UnaryCallable<SetIamPolicyRegionSnapshotRequest,Policy> setIamPolicyCallable()Sets the access control policy on the specified resource. Replaces any existing policy.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
SetIamPolicyRegionSnapshotRequest request =
SetIamPolicyRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRegionSetPolicyRequestResource(RegionSetPolicyRequest.newBuilder().build())
.setResource("resource-341064690")
.build();
ApiFuture<Policy> future = regionSnapshotsClient.setIamPolicyCallable().futureCall(request);
// Do something.
Policy response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<SetIamPolicyRegionSnapshotRequest,Policy> |
|
setLabelsAsync(SetLabelsRegionSnapshotRequest request)
public final OperationFuture<Operation,Operation> setLabelsAsync(SetLabelsRegionSnapshotRequest request)Sets the labels on a regional snapshot. To learn more about labels, read the Labeling Resources documentation.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
SetLabelsRegionSnapshotRequest request =
SetLabelsRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRegionSetLabelsRequestResource(RegionSetLabelsRequest.newBuilder().build())
.setRequestId("requestId693933066")
.setResource("resource-341064690")
.build();
Operation response = regionSnapshotsClient.setLabelsAsync(request).get();
}
| Parameter | |
|---|---|
| Name | Description |
request |
SetLabelsRegionSnapshotRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<Operation,Operation> |
|
setLabelsAsync(String project, String region, String resource, RegionSetLabelsRequest regionSetLabelsRequestResource)
public final OperationFuture<Operation,Operation> setLabelsAsync(String project, String region, String resource, RegionSetLabelsRequest regionSetLabelsRequestResource)Sets the labels on a regional snapshot. To learn more about labels, read the Labeling Resources documentation.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
String project = "project-309310695";
String region = "region-934795532";
String resource = "resource-341064690";
RegionSetLabelsRequest regionSetLabelsRequestResource =
RegionSetLabelsRequest.newBuilder().build();
Operation response =
regionSnapshotsClient
.setLabelsAsync(project, region, resource, regionSetLabelsRequestResource)
.get();
}
| Parameters | |
|---|---|
| Name | Description |
project |
StringProject ID for this request. |
region |
StringThe region for this request. |
resource |
StringName or id of the resource for this request. |
regionSetLabelsRequestResource |
RegionSetLabelsRequestThe body resource for this request |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<Operation,Operation> |
|
setLabelsCallable()
public final UnaryCallable<SetLabelsRegionSnapshotRequest,Operation> setLabelsCallable()Sets the labels on a regional snapshot. To learn more about labels, read the Labeling Resources documentation.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
SetLabelsRegionSnapshotRequest request =
SetLabelsRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRegionSetLabelsRequestResource(RegionSetLabelsRequest.newBuilder().build())
.setRequestId("requestId693933066")
.setResource("resource-341064690")
.build();
ApiFuture<Operation> future = regionSnapshotsClient.setLabelsCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<SetLabelsRegionSnapshotRequest,Operation> |
|
setLabelsOperationCallable()
public final OperationCallable<SetLabelsRegionSnapshotRequest,Operation,Operation> setLabelsOperationCallable()Sets the labels on a regional snapshot. To learn more about labels, read the Labeling Resources documentation.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
SetLabelsRegionSnapshotRequest request =
SetLabelsRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRegionSetLabelsRequestResource(RegionSetLabelsRequest.newBuilder().build())
.setRequestId("requestId693933066")
.setResource("resource-341064690")
.build();
OperationFuture<Operation, Operation> future =
regionSnapshotsClient.setLabelsOperationCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
OperationCallable<SetLabelsRegionSnapshotRequest,Operation,Operation> |
|
shutdown()
public void shutdown()shutdownNow()
public void shutdownNow()testIamPermissions(TestIamPermissionsRegionSnapshotRequest request)
public final TestPermissionsResponse testIamPermissions(TestIamPermissionsRegionSnapshotRequest request)Returns permissions that a caller has on the specified resource.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
TestIamPermissionsRegionSnapshotRequest request =
TestIamPermissionsRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setResource("resource-341064690")
.setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
.build();
TestPermissionsResponse response = regionSnapshotsClient.testIamPermissions(request);
}
| Parameter | |
|---|---|
| Name | Description |
request |
TestIamPermissionsRegionSnapshotRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
TestPermissionsResponse |
|
testIamPermissions(String project, String region, String resource, TestPermissionsRequest testPermissionsRequestResource)
public final TestPermissionsResponse testIamPermissions(String project, String region, String resource, TestPermissionsRequest testPermissionsRequestResource)Returns permissions that a caller has on the specified resource.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
String project = "project-309310695";
String region = "region-934795532";
String resource = "resource-341064690";
TestPermissionsRequest testPermissionsRequestResource =
TestPermissionsRequest.newBuilder().build();
TestPermissionsResponse response =
regionSnapshotsClient.testIamPermissions(
project, region, resource, testPermissionsRequestResource);
}
| Parameters | |
|---|---|
| Name | Description |
project |
StringProject ID for this request. |
region |
StringThe name of the region for this request. |
resource |
StringName or id of the resource for this request. |
testPermissionsRequestResource |
TestPermissionsRequestThe body resource for this request |
| Returns | |
|---|---|
| Type | Description |
TestPermissionsResponse |
|
testIamPermissionsCallable()
public final UnaryCallable<TestIamPermissionsRegionSnapshotRequest,TestPermissionsResponse> testIamPermissionsCallable()Returns permissions that a caller has on the specified resource.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
TestIamPermissionsRegionSnapshotRequest request =
TestIamPermissionsRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setResource("resource-341064690")
.setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
.build();
ApiFuture<TestPermissionsResponse> future =
regionSnapshotsClient.testIamPermissionsCallable().futureCall(request);
// Do something.
TestPermissionsResponse response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<TestIamPermissionsRegionSnapshotRequest,TestPermissionsResponse> |
|
updateKmsKeyAsync(UpdateKmsKeyRegionSnapshotRequest request)
public final OperationFuture<Operation,Operation> updateKmsKeyAsync(UpdateKmsKeyRegionSnapshotRequest request)Rotates the customer-managed encryption key to the latest version for the specified snapshot.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
UpdateKmsKeyRegionSnapshotRequest request =
UpdateKmsKeyRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRegionSnapshotUpdateKmsKeyRequestResource(
RegionSnapshotUpdateKmsKeyRequest.newBuilder().build())
.setRequestId("requestId693933066")
.setSnapshot("snapshot284874180")
.build();
Operation response = regionSnapshotsClient.updateKmsKeyAsync(request).get();
}
| Parameter | |
|---|---|
| Name | Description |
request |
UpdateKmsKeyRegionSnapshotRequestThe request object containing all of the parameters for the API call. |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<Operation,Operation> |
|
updateKmsKeyAsync(String project, String region, String snapshot, RegionSnapshotUpdateKmsKeyRequest regionSnapshotUpdateKmsKeyRequestResource)
public final OperationFuture<Operation,Operation> updateKmsKeyAsync(String project, String region, String snapshot, RegionSnapshotUpdateKmsKeyRequest regionSnapshotUpdateKmsKeyRequestResource)Rotates the customer-managed encryption key to the latest version for the specified snapshot.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
String project = "project-309310695";
String region = "region-934795532";
String snapshot = "snapshot284874180";
RegionSnapshotUpdateKmsKeyRequest regionSnapshotUpdateKmsKeyRequestResource =
RegionSnapshotUpdateKmsKeyRequest.newBuilder().build();
Operation response =
regionSnapshotsClient
.updateKmsKeyAsync(
project, region, snapshot, regionSnapshotUpdateKmsKeyRequestResource)
.get();
}
| Parameters | |
|---|---|
| Name | Description |
project |
StringProject ID for this request. |
region |
StringName of the region for this request. |
snapshot |
StringName of the snapshot resource to update. Should conform to RFC1035. |
regionSnapshotUpdateKmsKeyRequestResource |
RegionSnapshotUpdateKmsKeyRequestThe body resource for this request |
| Returns | |
|---|---|
| Type | Description |
OperationFuture<Operation,Operation> |
|
updateKmsKeyCallable()
public final UnaryCallable<UpdateKmsKeyRegionSnapshotRequest,Operation> updateKmsKeyCallable()Rotates the customer-managed encryption key to the latest version for the specified snapshot.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
UpdateKmsKeyRegionSnapshotRequest request =
UpdateKmsKeyRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRegionSnapshotUpdateKmsKeyRequestResource(
RegionSnapshotUpdateKmsKeyRequest.newBuilder().build())
.setRequestId("requestId693933066")
.setSnapshot("snapshot284874180")
.build();
ApiFuture<Operation> future =
regionSnapshotsClient.updateKmsKeyCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
UnaryCallable<UpdateKmsKeyRegionSnapshotRequest,Operation> |
|
updateKmsKeyOperationCallable()
public final OperationCallable<UpdateKmsKeyRegionSnapshotRequest,Operation,Operation> updateKmsKeyOperationCallable()Rotates the customer-managed encryption key to the latest version for the specified snapshot.
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 (RegionSnapshotsClient regionSnapshotsClient = RegionSnapshotsClient.create()) {
UpdateKmsKeyRegionSnapshotRequest request =
UpdateKmsKeyRegionSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRegion("region-934795532")
.setRegionSnapshotUpdateKmsKeyRequestResource(
RegionSnapshotUpdateKmsKeyRequest.newBuilder().build())
.setRequestId("requestId693933066")
.setSnapshot("snapshot284874180")
.build();
OperationFuture<Operation, Operation> future =
regionSnapshotsClient.updateKmsKeyOperationCallable().futureCall(request);
// Do something.
Operation response = future.get();
}
| Returns | |
|---|---|
| Type | Description |
OperationCallable<UpdateKmsKeyRegionSnapshotRequest,Operation,Operation> |
|