@Generated(value="by gapic-generator-java") public class SnapshotsClient extends Object implements com.google.api.gax.core.BackgroundResource
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().
| 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, see Deleting 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 `OperationFuture`, which is used to track polling of the service.
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 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.
Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.
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 project. |
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 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 `OperationFuture`, which is used to track polling of the service.
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.
|
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
SnapshotsClient.ListFixedSizeCollection |
static class |
SnapshotsClient.ListPage |
static class |
SnapshotsClient.ListPagedResponse |
| Modifier | Constructor and Description |
|---|---|
protected |
SnapshotsClient(SnapshotsSettings settings)
Constructs an instance of SnapshotsClient, using the given settings.
|
protected |
SnapshotsClient(SnapshotsStub stub) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static SnapshotsClient |
create()
Constructs an instance of SnapshotsClient with default settings.
|
static SnapshotsClient |
create(SnapshotsSettings settings)
Constructs an instance of SnapshotsClient, using the given settings.
|
static SnapshotsClient |
create(SnapshotsStub stub)
Constructs an instance of SnapshotsClient, using the given stub for making calls.
|
com.google.api.gax.longrunning.OperationFuture<Operation,Operation> |
deleteAsync(DeleteSnapshotRequest request)
Deletes the specified Snapshot resource.
|
com.google.api.gax.longrunning.OperationFuture<Operation,Operation> |
deleteAsync(String project,
String snapshot)
Deletes the specified Snapshot resource.
|
com.google.api.gax.rpc.UnaryCallable<DeleteSnapshotRequest,Operation> |
deleteCallable()
Deletes the specified Snapshot resource.
|
com.google.api.gax.rpc.OperationCallable<DeleteSnapshotRequest,Operation,Operation> |
deleteOperationCallable()
Deletes the specified Snapshot resource.
|
Snapshot |
get(GetSnapshotRequest request)
Returns the specified Snapshot resource.
|
Snapshot |
get(String project,
String snapshot)
Returns the specified Snapshot resource.
|
com.google.api.gax.rpc.UnaryCallable<GetSnapshotRequest,Snapshot> |
getCallable()
Returns the specified Snapshot resource.
|
Policy |
getIamPolicy(GetIamPolicySnapshotRequest request)
Gets the access control policy for a resource.
|
Policy |
getIamPolicy(String project,
String resource)
Gets the access control policy for a resource.
|
com.google.api.gax.rpc.UnaryCallable<GetIamPolicySnapshotRequest,Policy> |
getIamPolicyCallable()
Gets the access control policy for a resource.
|
SnapshotsSettings |
getSettings() |
SnapshotsStub |
getStub() |
com.google.api.gax.longrunning.OperationFuture<Operation,Operation> |
insertAsync(InsertSnapshotRequest request)
Creates a snapshot in the specified project using the data included in the request.
|
com.google.api.gax.longrunning.OperationFuture<Operation,Operation> |
insertAsync(String project,
Snapshot snapshotResource)
Creates a snapshot in the specified project using the data included in the request.
|
com.google.api.gax.rpc.UnaryCallable<InsertSnapshotRequest,Operation> |
insertCallable()
Creates a snapshot in the specified project using the data included in the request.
|
com.google.api.gax.rpc.OperationCallable<InsertSnapshotRequest,Operation,Operation> |
insertOperationCallable()
Creates a snapshot in the specified project using the data included in the request.
|
boolean |
isShutdown() |
boolean |
isTerminated() |
SnapshotsClient.ListPagedResponse |
list(ListSnapshotsRequest request)
Retrieves the list of Snapshot resources contained within the specified project.
|
SnapshotsClient.ListPagedResponse |
list(String project)
Retrieves the list of Snapshot resources contained within the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListSnapshotsRequest,SnapshotList> |
listCallable()
Retrieves the list of Snapshot resources contained within the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListSnapshotsRequest,SnapshotsClient.ListPagedResponse> |
listPagedCallable()
Retrieves the list of Snapshot resources contained within the specified project.
|
Policy |
setIamPolicy(SetIamPolicySnapshotRequest request)
Sets the access control policy on the specified resource.
|
Policy |
setIamPolicy(String project,
String resource,
GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sets the access control policy on the specified resource.
|
com.google.api.gax.rpc.UnaryCallable<SetIamPolicySnapshotRequest,Policy> |
setIamPolicyCallable()
Sets the access control policy on the specified resource.
|
com.google.api.gax.longrunning.OperationFuture<Operation,Operation> |
setLabelsAsync(SetLabelsSnapshotRequest request)
Sets the labels on a snapshot.
|
com.google.api.gax.longrunning.OperationFuture<Operation,Operation> |
setLabelsAsync(String project,
String resource,
GlobalSetLabelsRequest globalSetLabelsRequestResource)
Sets the labels on a snapshot.
|
com.google.api.gax.rpc.UnaryCallable<SetLabelsSnapshotRequest,Operation> |
setLabelsCallable()
Sets the labels on a snapshot.
|
com.google.api.gax.rpc.OperationCallable<SetLabelsSnapshotRequest,Operation,Operation> |
setLabelsOperationCallable()
Sets the labels on a snapshot.
|
void |
shutdown() |
void |
shutdownNow() |
TestPermissionsResponse |
testIamPermissions(String project,
String resource,
TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
|
TestPermissionsResponse |
testIamPermissions(TestIamPermissionsSnapshotRequest request)
Returns permissions that a caller has on the specified resource.
|
com.google.api.gax.rpc.UnaryCallable<TestIamPermissionsSnapshotRequest,TestPermissionsResponse> |
testIamPermissionsCallable()
Returns permissions that a caller has on the specified resource.
|
protected SnapshotsClient(SnapshotsSettings settings) throws IOException
IOExceptionprotected SnapshotsClient(SnapshotsStub stub)
public static final SnapshotsClient create() throws IOException
IOExceptionpublic static final SnapshotsClient create(SnapshotsSettings settings) throws IOException
IOExceptionpublic static final SnapshotsClient create(SnapshotsStub stub)
public final SnapshotsSettings getSettings()
public SnapshotsStub getStub()
public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> deleteAsync(String project, String 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
String project = "project-309310695";
String snapshot = "snapshot284874180";
Operation response = snapshotsClient.deleteAsync(project, snapshot).get();
}
project - Project ID for this request.snapshot - Name of the Snapshot resource to delete.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> deleteAsync(DeleteSnapshotRequest 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()) {
DeleteSnapshotRequest request =
DeleteSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRequestId("requestId693933066")
.setSnapshot("snapshot284874180")
.build();
Operation response = snapshotsClient.deleteAsync(request).get();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<DeleteSnapshotRequest,Operation,Operation> deleteOperationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
public final com.google.api.gax.rpc.UnaryCallable<DeleteSnapshotRequest,Operation> deleteCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
public final Snapshot get(String project, String 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 (SnapshotsClient snapshotsClient = SnapshotsClient.create()) {
String project = "project-309310695";
String snapshot = "snapshot284874180";
Snapshot response = snapshotsClient.get(project, snapshot);
}
project - Project ID for this request.snapshot - Name of the Snapshot resource to return.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Snapshot get(GetSnapshotRequest 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);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetSnapshotRequest,Snapshot> getCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
public final Policy getIamPolicy(String project, String 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";
Policy response = snapshotsClient.getIamPolicy(project, resource);
}
project - Project ID for this request.resource - Name or id of the resource for this request.com.google.api.gax.rpc.ApiException - if the remote call failspublic final Policy getIamPolicy(GetIamPolicySnapshotRequest 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()) {
GetIamPolicySnapshotRequest request =
GetIamPolicySnapshotRequest.newBuilder()
.setOptionsRequestedPolicyVersion(-574521795)
.setProject("project-309310695")
.setResource("resource-341064690")
.build();
Policy response = snapshotsClient.getIamPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<GetIamPolicySnapshotRequest,Policy> getIamPolicyCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> insertAsync(String project, Snapshot snapshotResource)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
project - Project ID for this request.snapshotResource - The body resource for this requestcom.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> insertAsync(InsertSnapshotRequest 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()) {
InsertSnapshotRequest request =
InsertSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setRequestId("requestId693933066")
.setSnapshotResource(Snapshot.newBuilder().build())
.build();
Operation response = snapshotsClient.insertAsync(request).get();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<InsertSnapshotRequest,Operation,Operation> insertOperationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
public final com.google.api.gax.rpc.UnaryCallable<InsertSnapshotRequest,Operation> insertCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
public final SnapshotsClient.ListPagedResponse list(String 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);
}
}
project - Project ID for this request.com.google.api.gax.rpc.ApiException - if the remote call failspublic final SnapshotsClient.ListPagedResponse list(ListSnapshotsRequest 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()) {
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);
}
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<ListSnapshotsRequest,SnapshotsClient.ListPagedResponse> listPagedCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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);
}
}
public final com.google.api.gax.rpc.UnaryCallable<ListSnapshotsRequest,SnapshotList> listCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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;
}
}
}
public final Policy setIamPolicy(String project, String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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);
}
project - Project ID for this request.resource - Name or id of the resource for this request.globalSetPolicyRequestResource - The body resource for this requestcom.google.api.gax.rpc.ApiException - if the remote call failspublic final Policy setIamPolicy(SetIamPolicySnapshotRequest 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()) {
SetIamPolicySnapshotRequest request =
SetIamPolicySnapshotRequest.newBuilder()
.setGlobalSetPolicyRequestResource(GlobalSetPolicyRequest.newBuilder().build())
.setProject("project-309310695")
.setResource("resource-341064690")
.build();
Policy response = snapshotsClient.setIamPolicy(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<SetIamPolicySnapshotRequest,Policy> setIamPolicyCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
public final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> setLabelsAsync(String project, String resource, GlobalSetLabelsRequest globalSetLabelsRequestResource)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
project - Project ID for this request.resource - Name or id of the resource for this request.globalSetLabelsRequestResource - The body resource for this requestcom.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.longrunning.OperationFuture<Operation,Operation> setLabelsAsync(SetLabelsSnapshotRequest 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()) {
SetLabelsSnapshotRequest request =
SetLabelsSnapshotRequest.newBuilder()
.setGlobalSetLabelsRequestResource(GlobalSetLabelsRequest.newBuilder().build())
.setProject("project-309310695")
.setResource("resource-341064690")
.build();
Operation response = snapshotsClient.setLabelsAsync(request).get();
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.OperationCallable<SetLabelsSnapshotRequest,Operation,Operation> setLabelsOperationCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
public final com.google.api.gax.rpc.UnaryCallable<SetLabelsSnapshotRequest,Operation> setLabelsCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
public final TestPermissionsResponse testIamPermissions(String project, String resource, TestPermissionsRequest testPermissionsRequestResource)
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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);
}
project - Project ID for this request.resource - Name or id of the resource for this request.testPermissionsRequestResource - The body resource for this requestcom.google.api.gax.rpc.ApiException - if the remote call failspublic final TestPermissionsResponse testIamPermissions(TestIamPermissionsSnapshotRequest 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()) {
TestIamPermissionsSnapshotRequest request =
TestIamPermissionsSnapshotRequest.newBuilder()
.setProject("project-309310695")
.setResource("resource-341064690")
.setTestPermissionsRequestResource(TestPermissionsRequest.newBuilder().build())
.build();
TestPermissionsResponse response = snapshotsClient.testIamPermissions(request);
}
request - The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException - if the remote call failspublic final com.google.api.gax.rpc.UnaryCallable<TestIamPermissionsSnapshotRequest,TestPermissionsResponse> testIamPermissionsCallable()
Sample code:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying 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();
}
public final void close()
close in interface AutoCloseablepublic void shutdown()
shutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isShutdown()
isShutdown in interface com.google.api.gax.core.BackgroundResourcepublic boolean isTerminated()
isTerminated in interface com.google.api.gax.core.BackgroundResourcepublic void shutdownNow()
shutdownNow in interface com.google.api.gax.core.BackgroundResourcepublic boolean awaitTermination(long duration,
TimeUnit unit)
throws InterruptedException
awaitTermination in interface com.google.api.gax.core.BackgroundResourceInterruptedExceptionCopyright © 2024 Google LLC. All rights reserved.