Class SnapshotsClient (1.47.0)

GitHub RepositoryProduct Reference

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().

Methods
MethodDescriptionMethod 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, see Deleting snapshots.

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

  • deleteAsync(DeleteSnapshotRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • deleteAsync(String project, String snapshot)

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

  • deleteOperationCallable()

  • deleteCallable()

Get

Returns the specified Snapshot resource.

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

  • get(GetSnapshotRequest request)

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

  • get(String project, String snapshot)

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

  • getCallable()

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.

  • getIamPolicy(GetIamPolicySnapshotRequest request)

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

  • getIamPolicy(String project, String resource)

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

  • getIamPolicyCallable()

Insert

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.

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

  • insertAsync(InsertSnapshotRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • insertAsync(String project, Snapshot snapshotResource)

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

  • insertOperationCallable()

  • insertCallable()

List

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

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

  • list(ListSnapshotsRequest request)

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

  • list(String project)

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

  • listPagedCallable()

  • listCallable()

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.

  • setIamPolicy(SetIamPolicySnapshotRequest request)

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

  • setIamPolicy(String project, String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)

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

  • setIamPolicyCallable()

SetLabels

Sets the labels on a 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.

  • setLabelsAsync(SetLabelsSnapshotRequest request)

Methods that return long-running operations have "Async" method variants that return OperationFuture, which is used to track polling of the service.

  • setLabelsAsync(String project, String resource, GlobalSetLabelsRequest globalSetLabelsRequestResource)

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

  • setLabelsOperationCallable()

  • setLabelsCallable()

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.

  • testIamPermissions(TestIamPermissionsSnapshotRequest request)

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

  • testIamPermissions(String project, String resource, TestPermissionsRequest testPermissionsRequestResource)

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

  • testIamPermissionsCallable()

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

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.

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.

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.

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>