Class SnapshotsClient (1.17.0)

public class SnapshotsClient implements BackgroundResource

Service Description: The Snapshots 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   String project = "project-309310695";
   String snapshot = "snapshot284874180";
   Snapshot response = snapshotsClient.get(project, snapshot);
 }
 

Note: close() needs to be called on the SnapshotsClient 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:

  1. 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.
  2. 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.
  3. 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 SnapshotsSettings 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
 SnapshotsSettings snapshotsSettings =
     SnapshotsSettings.newBuilder()
         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
         .build();
 SnapshotsClient snapshotsClient = SnapshotsClient.create(snapshotsSettings);
 

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
 SnapshotsSettings snapshotsSettings =
     SnapshotsSettings.newBuilder().setEndpoint(myEndpoint).build();
 SnapshotsClient snapshotsClient = SnapshotsClient.create(snapshotsSettings);
 

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

Inheritance

java.lang.Object > SnapshotsClient

Implements

BackgroundResource

Static Methods

create()

public static final SnapshotsClient create()

Constructs an instance of SnapshotsClient with default settings.

Returns
TypeDescription
SnapshotsClient
Exceptions
TypeDescription
IOException

create(SnapshotsSettings settings)

public static final SnapshotsClient create(SnapshotsSettings settings)

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

Parameter
NameDescription
settingsSnapshotsSettings
Returns
TypeDescription
SnapshotsClient
Exceptions
TypeDescription
IOException

create(SnapshotsStub stub)

public static final SnapshotsClient create(SnapshotsStub stub)

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

Parameter
NameDescription
stubSnapshotsStub
Returns
TypeDescription
SnapshotsClient

Constructors

SnapshotsClient(SnapshotsSettings settings)

protected SnapshotsClient(SnapshotsSettings settings)

Constructs an instance of SnapshotsClient, 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
NameDescription
settingsSnapshotsSettings

SnapshotsClient(SnapshotsStub stub)

protected SnapshotsClient(SnapshotsStub stub)
Parameter
NameDescription
stubSnapshotsStub

Methods

awaitTermination(long duration, TimeUnit unit)

public boolean awaitTermination(long duration, TimeUnit unit)
Parameters
NameDescription
durationlong
unitTimeUnit
Returns
TypeDescription
boolean
Exceptions
TypeDescription
InterruptedException

close()

public final void close()

deleteAsync(DeleteSnapshotRequest request)

public final OperationFuture<Operation,Operation> deleteAsync(DeleteSnapshotRequest 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, see Deleting 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   DeleteSnapshotRequest request =
       DeleteSnapshotRequest.newBuilder()
           .setProject("project-309310695")
           .setRequestId("requestId693933066")
           .setSnapshot("snapshot284874180")
           .build();
   Operation response = snapshotsClient.deleteAsync(request).get();
 }
 
Parameter
NameDescription
requestDeleteSnapshotRequest

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

Returns
TypeDescription
OperationFuture<Operation,Operation>

deleteAsync(String project, String snapshot)

public final OperationFuture<Operation,Operation> deleteAsync(String project, 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, see Deleting 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   String project = "project-309310695";
   String snapshot = "snapshot284874180";
   Operation response = snapshotsClient.deleteAsync(project, snapshot).get();
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

snapshotString

Name of the Snapshot resource to delete.

Returns
TypeDescription
OperationFuture<Operation,Operation>

deleteCallable()

public final UnaryCallable<DeleteSnapshotRequest,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, see Deleting 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   DeleteSnapshotRequest request =
       DeleteSnapshotRequest.newBuilder()
           .setProject("project-309310695")
           .setRequestId("requestId693933066")
           .setSnapshot("snapshot284874180")
           .build();
   ApiFuture<Operation> future = snapshotsClient.deleteCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<DeleteSnapshotRequest,Operation>

deleteOperationCallable()

public final OperationCallable<DeleteSnapshotRequest,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, see Deleting 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   DeleteSnapshotRequest request =
       DeleteSnapshotRequest.newBuilder()
           .setProject("project-309310695")
           .setRequestId("requestId693933066")
           .setSnapshot("snapshot284874180")
           .build();
   OperationFuture<Operation, Operation> future =
       snapshotsClient.deleteOperationCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<DeleteSnapshotRequest,Operation,Operation>

get(GetSnapshotRequest request)

public final Snapshot get(GetSnapshotRequest request)

Returns the specified Snapshot resource. Gets a list of available snapshots by making a list() 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   GetSnapshotRequest request =
       GetSnapshotRequest.newBuilder()
           .setProject("project-309310695")
           .setSnapshot("snapshot284874180")
           .build();
   Snapshot response = snapshotsClient.get(request);
 }
 
Parameter
NameDescription
requestGetSnapshotRequest

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

Returns
TypeDescription
Snapshot

get(String project, String snapshot)

public final Snapshot get(String project, String snapshot)

Returns the specified Snapshot resource. Gets a list of available snapshots by making a list() 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   String project = "project-309310695";
   String snapshot = "snapshot284874180";
   Snapshot response = snapshotsClient.get(project, snapshot);
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

snapshotString

Name of the Snapshot resource to return.

Returns
TypeDescription
Snapshot

getCallable()

public final UnaryCallable<GetSnapshotRequest,Snapshot> getCallable()

Returns the specified Snapshot resource. Gets a list of available snapshots by making a list() 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   GetSnapshotRequest request =
       GetSnapshotRequest.newBuilder()
           .setProject("project-309310695")
           .setSnapshot("snapshot284874180")
           .build();
   ApiFuture<Snapshot> future = snapshotsClient.getCallable().futureCall(request);
   // Do something.
   Snapshot response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetSnapshotRequest,Snapshot>

getIamPolicy(GetIamPolicySnapshotRequest request)

public final Policy getIamPolicy(GetIamPolicySnapshotRequest 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   GetIamPolicySnapshotRequest request =
       GetIamPolicySnapshotRequest.newBuilder()
           .setOptionsRequestedPolicyVersion(-574521795)
           .setProject("project-309310695")
           .setResource("resource-341064690")
           .build();
   Policy response = snapshotsClient.getIamPolicy(request);
 }
 
Parameter
NameDescription
requestGetIamPolicySnapshotRequest

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

Returns
TypeDescription
Policy

getIamPolicy(String project, String resource)

public final Policy getIamPolicy(String project, 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   String project = "project-309310695";
   String resource = "resource-341064690";
   Policy response = snapshotsClient.getIamPolicy(project, resource);
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

resourceString

Name or id of the resource for this request.

Returns
TypeDescription
Policy

getIamPolicyCallable()

public final UnaryCallable<GetIamPolicySnapshotRequest,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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   GetIamPolicySnapshotRequest request =
       GetIamPolicySnapshotRequest.newBuilder()
           .setOptionsRequestedPolicyVersion(-574521795)
           .setProject("project-309310695")
           .setResource("resource-341064690")
           .build();
   ApiFuture<Policy> future = snapshotsClient.getIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<GetIamPolicySnapshotRequest,Policy>

getSettings()

public final SnapshotsSettings getSettings()
Returns
TypeDescription
SnapshotsSettings

getStub()

public SnapshotsStub getStub()
Returns
TypeDescription
SnapshotsStub

insertAsync(InsertSnapshotRequest request)

public final OperationFuture<Operation,Operation> insertAsync(InsertSnapshotRequest request)

Creates a snapshot in the specified project using the data included in the request. For regular snapshot creation, consider using this method instead of disks.createSnapshot, as this method supports more features, such as creating snapshots in a project different from the source disk project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   InsertSnapshotRequest request =
       InsertSnapshotRequest.newBuilder()
           .setProject("project-309310695")
           .setRequestId("requestId693933066")
           .setSnapshotResource(Snapshot.newBuilder().build())
           .build();
   Operation response = snapshotsClient.insertAsync(request).get();
 }
 
Parameter
NameDescription
requestInsertSnapshotRequest

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

Returns
TypeDescription
OperationFuture<Operation,Operation>

insertAsync(String project, Snapshot snapshotResource)

public final OperationFuture<Operation,Operation> insertAsync(String project, Snapshot snapshotResource)

Creates a snapshot in the specified project using the data included in the request. For regular snapshot creation, consider using this method instead of disks.createSnapshot, as this method supports more features, such as creating snapshots in a project different from the source disk project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   String project = "project-309310695";
   Snapshot snapshotResource = Snapshot.newBuilder().build();
   Operation response = snapshotsClient.insertAsync(project, snapshotResource).get();
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

snapshotResourceSnapshot

The body resource for this request

Returns
TypeDescription
OperationFuture<Operation,Operation>

insertCallable()

public final UnaryCallable<InsertSnapshotRequest,Operation> insertCallable()

Creates a snapshot in the specified project using the data included in the request. For regular snapshot creation, consider using this method instead of disks.createSnapshot, as this method supports more features, such as creating snapshots in a project different from the source disk project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   InsertSnapshotRequest request =
       InsertSnapshotRequest.newBuilder()
           .setProject("project-309310695")
           .setRequestId("requestId693933066")
           .setSnapshotResource(Snapshot.newBuilder().build())
           .build();
   ApiFuture<Operation> future = snapshotsClient.insertCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<InsertSnapshotRequest,Operation>

insertOperationCallable()

public final OperationCallable<InsertSnapshotRequest,Operation,Operation> insertOperationCallable()

Creates a snapshot in the specified project using the data included in the request. For regular snapshot creation, consider using this method instead of disks.createSnapshot, as this method supports more features, such as creating snapshots in a project different from the source disk project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   InsertSnapshotRequest request =
       InsertSnapshotRequest.newBuilder()
           .setProject("project-309310695")
           .setRequestId("requestId693933066")
           .setSnapshotResource(Snapshot.newBuilder().build())
           .build();
   OperationFuture<Operation, Operation> future =
       snapshotsClient.insertOperationCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<InsertSnapshotRequest,Operation,Operation>

isShutdown()

public boolean isShutdown()
Returns
TypeDescription
boolean

isTerminated()

public boolean isTerminated()
Returns
TypeDescription
boolean

list(ListSnapshotsRequest request)

public final SnapshotsClient.ListPagedResponse list(ListSnapshotsRequest request)

Retrieves the list of Snapshot resources contained within the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   ListSnapshotsRequest request =
       ListSnapshotsRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   for (Snapshot element : snapshotsClient.list(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
requestListSnapshotsRequest

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

Returns
TypeDescription
SnapshotsClient.ListPagedResponse

list(String project)

public final SnapshotsClient.ListPagedResponse list(String project)

Retrieves the list of Snapshot resources contained within the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   String project = "project-309310695";
   for (Snapshot element : snapshotsClient.list(project).iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Parameter
NameDescription
projectString

Project ID for this request.

Returns
TypeDescription
SnapshotsClient.ListPagedResponse

listCallable()

public final UnaryCallable<ListSnapshotsRequest,SnapshotList> listCallable()

Retrieves the list of Snapshot resources contained within the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   ListSnapshotsRequest request =
       ListSnapshotsRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   while (true) {
     SnapshotList response = snapshotsClient.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
TypeDescription
UnaryCallable<ListSnapshotsRequest,SnapshotList>

listPagedCallable()

public final UnaryCallable<ListSnapshotsRequest,SnapshotsClient.ListPagedResponse> listPagedCallable()

Retrieves the list of Snapshot resources contained within the specified project.

Sample code:


 // This snippet has been automatically generated and should be regarded as a code template only.
 // It will require modifications to work:
 // - It may require correct/in-range values for request initialization.
 // - It may require specifying regional endpoints when creating the service client as shown in
 // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
 try (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   ListSnapshotsRequest request =
       ListSnapshotsRequest.newBuilder()
           .setFilter("filter-1274492040")
           .setMaxResults(1128457243)
           .setOrderBy("orderBy-1207110587")
           .setPageToken("pageToken873572522")
           .setProject("project-309310695")
           .setReturnPartialSuccess(true)
           .build();
   ApiFuture<Snapshot> future = snapshotsClient.listPagedCallable().futureCall(request);
   // Do something.
   for (Snapshot element : future.get().iterateAll()) {
     // doThingsWith(element);
   }
 }
 
Returns
TypeDescription
UnaryCallable<ListSnapshotsRequest,ListPagedResponse>

setIamPolicy(SetIamPolicySnapshotRequest request)

public final Policy setIamPolicy(SetIamPolicySnapshotRequest 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   SetIamPolicySnapshotRequest request =
       SetIamPolicySnapshotRequest.newBuilder()
           .setGlobalSetPolicyRequestResource(GlobalSetPolicyRequest.newBuilder().build())
           .setProject("project-309310695")
           .setResource("resource-341064690")
           .build();
   Policy response = snapshotsClient.setIamPolicy(request);
 }
 
Parameter
NameDescription
requestSetIamPolicySnapshotRequest

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

Returns
TypeDescription
Policy

setIamPolicy(String project, String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)

public final Policy setIamPolicy(String project, String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)

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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   String project = "project-309310695";
   String resource = "resource-341064690";
   GlobalSetPolicyRequest globalSetPolicyRequestResource =
       GlobalSetPolicyRequest.newBuilder().build();
   Policy response =
       snapshotsClient.setIamPolicy(project, resource, globalSetPolicyRequestResource);
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

resourceString

Name or id of the resource for this request.

globalSetPolicyRequestResourceGlobalSetPolicyRequest

The body resource for this request

Returns
TypeDescription
Policy

setIamPolicyCallable()

public final UnaryCallable<SetIamPolicySnapshotRequest,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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   SetIamPolicySnapshotRequest request =
       SetIamPolicySnapshotRequest.newBuilder()
           .setGlobalSetPolicyRequestResource(GlobalSetPolicyRequest.newBuilder().build())
           .setProject("project-309310695")
           .setResource("resource-341064690")
           .build();
   ApiFuture<Policy> future = snapshotsClient.setIamPolicyCallable().futureCall(request);
   // Do something.
   Policy response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<SetIamPolicySnapshotRequest,Policy>

setLabelsAsync(SetLabelsSnapshotRequest request)

public final OperationFuture<Operation,Operation> setLabelsAsync(SetLabelsSnapshotRequest request)

Sets the labels on a 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   SetLabelsSnapshotRequest request =
       SetLabelsSnapshotRequest.newBuilder()
           .setGlobalSetLabelsRequestResource(GlobalSetLabelsRequest.newBuilder().build())
           .setProject("project-309310695")
           .setResource("resource-341064690")
           .build();
   Operation response = snapshotsClient.setLabelsAsync(request).get();
 }
 
Parameter
NameDescription
requestSetLabelsSnapshotRequest

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

Returns
TypeDescription
OperationFuture<Operation,Operation>

setLabelsAsync(String project, String resource, GlobalSetLabelsRequest globalSetLabelsRequestResource)

public final OperationFuture<Operation,Operation> setLabelsAsync(String project, String resource, GlobalSetLabelsRequest globalSetLabelsRequestResource)

Sets the labels on a 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   String project = "project-309310695";
   String resource = "resource-341064690";
   GlobalSetLabelsRequest globalSetLabelsRequestResource =
       GlobalSetLabelsRequest.newBuilder().build();
   Operation response =
       snapshotsClient.setLabelsAsync(project, resource, globalSetLabelsRequestResource).get();
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

resourceString

Name or id of the resource for this request.

globalSetLabelsRequestResourceGlobalSetLabelsRequest

The body resource for this request

Returns
TypeDescription
OperationFuture<Operation,Operation>

setLabelsCallable()

public final UnaryCallable<SetLabelsSnapshotRequest,Operation> setLabelsCallable()

Sets the labels on a 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   SetLabelsSnapshotRequest request =
       SetLabelsSnapshotRequest.newBuilder()
           .setGlobalSetLabelsRequestResource(GlobalSetLabelsRequest.newBuilder().build())
           .setProject("project-309310695")
           .setResource("resource-341064690")
           .build();
   ApiFuture<Operation> future = snapshotsClient.setLabelsCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<SetLabelsSnapshotRequest,Operation>

setLabelsOperationCallable()

public final OperationCallable<SetLabelsSnapshotRequest,Operation,Operation> setLabelsOperationCallable()

Sets the labels on a 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   SetLabelsSnapshotRequest request =
       SetLabelsSnapshotRequest.newBuilder()
           .setGlobalSetLabelsRequestResource(GlobalSetLabelsRequest.newBuilder().build())
           .setProject("project-309310695")
           .setResource("resource-341064690")
           .build();
   OperationFuture<Operation, Operation> future =
       snapshotsClient.setLabelsOperationCallable().futureCall(request);
   // Do something.
   Operation response = future.get();
 }
 
Returns
TypeDescription
OperationCallable<SetLabelsSnapshotRequest,Operation,Operation>

shutdown()

public void shutdown()

shutdownNow()

public void shutdownNow()

testIamPermissions(TestIamPermissionsSnapshotRequest request)

public final TestPermissionsResponse testIamPermissions(TestIamPermissionsSnapshotRequest 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   TestIamPermissionsSnapshotRequest request =
       TestIamPermissionsSnapshotRequest.newBuilder()
           .setProject("project-309310695")
           .setResource("resource-341064690")
           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
           .build();
   TestPermissionsResponse response = snapshotsClient.testIamPermissions(request);
 }
 
Parameter
NameDescription
requestTestIamPermissionsSnapshotRequest

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

Returns
TypeDescription
TestPermissionsResponse

testIamPermissions(String project, String resource, TestPermissionsRequest testPermissionsRequestResource)

public final TestPermissionsResponse testIamPermissions(String project, 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   String project = "project-309310695";
   String resource = "resource-341064690";
   TestPermissionsRequest testPermissionsRequestResource =
       TestPermissionsRequest.newBuilder().build();
   TestPermissionsResponse response =
       snapshotsClient.testIamPermissions(project, resource, testPermissionsRequestResource);
 }
 
Parameters
NameDescription
projectString

Project ID for this request.

resourceString

Name or id of the resource for this request.

testPermissionsRequestResourceTestPermissionsRequest

The body resource for this request

Returns
TypeDescription
TestPermissionsResponse

testIamPermissionsCallable()

public final UnaryCallable<TestIamPermissionsSnapshotRequest,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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
   TestIamPermissionsSnapshotRequest request =
       TestIamPermissionsSnapshotRequest.newBuilder()
           .setProject("project-309310695")
           .setResource("resource-341064690")
           .setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
           .build();
   ApiFuture<TestPermissionsResponse> future =
       snapshotsClient.testIamPermissionsCallable().futureCall(request);
   // Do something.
   TestPermissionsResponse response = future.get();
 }
 
Returns
TypeDescription
UnaryCallable<TestIamPermissionsSnapshotRequest,TestPermissionsResponse>