@Generated(value="by gapic-generator") @BetaApi public class SnapshotClient 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:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotName snapshot = ProjectGlobalSnapshotName.of("[PROJECT]", "[SNAPSHOT]");
Operation response = snapshotClient.deleteSnapshot(snapshot);
}
Note: close() needs to be called on the snapshotClient 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:
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 SnapshotSettings to create(). For example:
To customize credentials:
SnapshotSettings snapshotSettings =
SnapshotSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
SnapshotClient snapshotClient =
SnapshotClient.create(snapshotSettings);
To customize the endpoint:
SnapshotSettings snapshotSettings =
SnapshotSettings.newBuilder().setEndpoint(myEndpoint).build();
SnapshotClient snapshotClient =
SnapshotClient.create(snapshotSettings);
Modifier and Type | Class and Description |
---|---|
static class |
SnapshotClient.ListSnapshotsFixedSizeCollection |
static class |
SnapshotClient.ListSnapshotsPage |
static class |
SnapshotClient.ListSnapshotsPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
SnapshotClient(SnapshotSettings settings)
Constructs an instance of SnapshotClient, using the given settings.
|
protected |
SnapshotClient(SnapshotStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static SnapshotClient |
create()
Constructs an instance of SnapshotClient with default settings.
|
static SnapshotClient |
create(SnapshotSettings settings)
Constructs an instance of SnapshotClient, using the given settings.
|
static SnapshotClient |
create(SnapshotStub stub)
Constructs an instance of SnapshotClient, using the given stub for making calls.
|
Operation |
deleteSnapshot(DeleteSnapshotHttpRequest request)
Deletes the specified Snapshot resource.
|
Operation |
deleteSnapshot(ProjectGlobalSnapshotName snapshot)
Deletes the specified Snapshot resource.
|
Operation |
deleteSnapshot(String snapshot)
Deletes the specified Snapshot resource.
|
com.google.api.gax.rpc.UnaryCallable<DeleteSnapshotHttpRequest,Operation> |
deleteSnapshotCallable()
Deletes the specified Snapshot resource.
|
Policy |
getIamPolicySnapshot(GetIamPolicySnapshotHttpRequest request)
Gets the access control policy for a resource.
|
Policy |
getIamPolicySnapshot(ProjectGlobalSnapshotResourceName resource)
Gets the access control policy for a resource.
|
Policy |
getIamPolicySnapshot(String resource)
Gets the access control policy for a resource.
|
com.google.api.gax.rpc.UnaryCallable<GetIamPolicySnapshotHttpRequest,Policy> |
getIamPolicySnapshotCallable()
Gets the access control policy for a resource.
|
SnapshotSettings |
getSettings() |
Snapshot |
getSnapshot(GetSnapshotHttpRequest request)
Returns the specified Snapshot resource.
|
Snapshot |
getSnapshot(ProjectGlobalSnapshotName snapshot)
Returns the specified Snapshot resource.
|
Snapshot |
getSnapshot(String snapshot)
Returns the specified Snapshot resource.
|
com.google.api.gax.rpc.UnaryCallable<GetSnapshotHttpRequest,Snapshot> |
getSnapshotCallable()
Returns the specified Snapshot resource.
|
SnapshotStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
SnapshotClient.ListSnapshotsPagedResponse |
listSnapshots(ListSnapshotsHttpRequest request)
Retrieves the list of Snapshot resources contained within the specified project.
|
SnapshotClient.ListSnapshotsPagedResponse |
listSnapshots(ProjectName project)
Retrieves the list of Snapshot resources contained within the specified project.
|
SnapshotClient.ListSnapshotsPagedResponse |
listSnapshots(String project)
Retrieves the list of Snapshot resources contained within the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListSnapshotsHttpRequest,SnapshotList> |
listSnapshotsCallable()
Retrieves the list of Snapshot resources contained within the specified project.
|
com.google.api.gax.rpc.UnaryCallable<ListSnapshotsHttpRequest,SnapshotClient.ListSnapshotsPagedResponse> |
listSnapshotsPagedCallable()
Retrieves the list of Snapshot resources contained within the specified project.
|
Policy |
setIamPolicySnapshot(ProjectGlobalSnapshotResourceName resource,
GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sets the access control policy on the specified resource.
|
Policy |
setIamPolicySnapshot(SetIamPolicySnapshotHttpRequest request)
Sets the access control policy on the specified resource.
|
Policy |
setIamPolicySnapshot(String resource,
GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sets the access control policy on the specified resource.
|
com.google.api.gax.rpc.UnaryCallable<SetIamPolicySnapshotHttpRequest,Policy> |
setIamPolicySnapshotCallable()
Sets the access control policy on the specified resource.
|
Operation |
setLabelsSnapshot(ProjectGlobalSnapshotResourceName resource,
GlobalSetLabelsRequest globalSetLabelsRequestResource)
Sets the labels on a snapshot.
|
Operation |
setLabelsSnapshot(SetLabelsSnapshotHttpRequest request)
Sets the labels on a snapshot.
|
Operation |
setLabelsSnapshot(String resource,
GlobalSetLabelsRequest globalSetLabelsRequestResource)
Sets the labels on a snapshot.
|
com.google.api.gax.rpc.UnaryCallable<SetLabelsSnapshotHttpRequest,Operation> |
setLabelsSnapshotCallable()
Sets the labels on a snapshot.
|
void |
shutdown() |
void |
shutdownNow() |
TestPermissionsResponse |
testIamPermissionsSnapshot(ProjectGlobalSnapshotResourceName resource,
TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
|
TestPermissionsResponse |
testIamPermissionsSnapshot(String resource,
TestPermissionsRequest testPermissionsRequestResource)
Returns permissions that a caller has on the specified resource.
|
TestPermissionsResponse |
testIamPermissionsSnapshot(TestIamPermissionsSnapshotHttpRequest request)
Returns permissions that a caller has on the specified resource.
|
com.google.api.gax.rpc.UnaryCallable<TestIamPermissionsSnapshotHttpRequest,TestPermissionsResponse> |
testIamPermissionsSnapshotCallable()
Returns permissions that a caller has on the specified resource.
|
protected SnapshotClient(SnapshotSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected SnapshotClient(SnapshotStub stub)
public static final SnapshotClient create() throws IOException
IOException
public static final SnapshotClient create(SnapshotSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final SnapshotClient create(SnapshotStub stub)
public final SnapshotSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public SnapshotStub getStub()
@BetaApi public final Operation deleteSnapshot(ProjectGlobalSnapshotName snapshot)
For more information, see Deleting snapshots.
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotName snapshot = ProjectGlobalSnapshotName.of("[PROJECT]", "[SNAPSHOT]");
Operation response = snapshotClient.deleteSnapshot(snapshot);
}
snapshot
- Name of the Snapshot resource to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation deleteSnapshot(String snapshot)
For more information, see Deleting snapshots.
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotName snapshot = ProjectGlobalSnapshotName.of("[PROJECT]", "[SNAPSHOT]");
Operation response = snapshotClient.deleteSnapshot(snapshot.toString());
}
snapshot
- Name of the Snapshot resource to delete.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation deleteSnapshot(DeleteSnapshotHttpRequest request)
For more information, see Deleting snapshots.
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedSnapshot = ProjectGlobalSnapshotName.format("[PROJECT]", "[SNAPSHOT]");
DeleteSnapshotHttpRequest request = DeleteSnapshotHttpRequest.newBuilder()
.setSnapshot(formattedSnapshot)
.build();
Operation response = snapshotClient.deleteSnapshot(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<DeleteSnapshotHttpRequest,Operation> deleteSnapshotCallable()
For more information, see Deleting snapshots.
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedSnapshot = ProjectGlobalSnapshotName.format("[PROJECT]", "[SNAPSHOT]");
DeleteSnapshotHttpRequest request = DeleteSnapshotHttpRequest.newBuilder()
.setSnapshot(formattedSnapshot)
.build();
ApiFuture<Operation> future = snapshotClient.deleteSnapshotCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final Snapshot getSnapshot(ProjectGlobalSnapshotName snapshot)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotName snapshot = ProjectGlobalSnapshotName.of("[PROJECT]", "[SNAPSHOT]");
Snapshot response = snapshotClient.getSnapshot(snapshot);
}
snapshot
- Name of the Snapshot resource to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Snapshot getSnapshot(String snapshot)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotName snapshot = ProjectGlobalSnapshotName.of("[PROJECT]", "[SNAPSHOT]");
Snapshot response = snapshotClient.getSnapshot(snapshot.toString());
}
snapshot
- Name of the Snapshot resource to return.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Snapshot getSnapshot(GetSnapshotHttpRequest request)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedSnapshot = ProjectGlobalSnapshotName.format("[PROJECT]", "[SNAPSHOT]");
GetSnapshotHttpRequest request = GetSnapshotHttpRequest.newBuilder()
.setSnapshot(formattedSnapshot)
.build();
Snapshot response = snapshotClient.getSnapshot(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<GetSnapshotHttpRequest,Snapshot> getSnapshotCallable()
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedSnapshot = ProjectGlobalSnapshotName.format("[PROJECT]", "[SNAPSHOT]");
GetSnapshotHttpRequest request = GetSnapshotHttpRequest.newBuilder()
.setSnapshot(formattedSnapshot)
.build();
ApiFuture<Snapshot> future = snapshotClient.getSnapshotCallable().futureCall(request);
// Do something
Snapshot response = future.get();
}
@BetaApi public final Policy getIamPolicySnapshot(ProjectGlobalSnapshotResourceName resource)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotResourceName resource = ProjectGlobalSnapshotResourceName.of("[PROJECT]", "[RESOURCE]");
Policy response = snapshotClient.getIamPolicySnapshot(resource);
}
resource
- Name or id of the resource for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Policy getIamPolicySnapshot(String resource)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotResourceName resource = ProjectGlobalSnapshotResourceName.of("[PROJECT]", "[RESOURCE]");
Policy response = snapshotClient.getIamPolicySnapshot(resource.toString());
}
resource
- Name or id of the resource for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Policy getIamPolicySnapshot(GetIamPolicySnapshotHttpRequest request)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedResource = ProjectGlobalSnapshotResourceName.format("[PROJECT]", "[RESOURCE]");
GetIamPolicySnapshotHttpRequest request = GetIamPolicySnapshotHttpRequest.newBuilder()
.setResource(formattedResource)
.build();
Policy response = snapshotClient.getIamPolicySnapshot(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<GetIamPolicySnapshotHttpRequest,Policy> getIamPolicySnapshotCallable()
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedResource = ProjectGlobalSnapshotResourceName.format("[PROJECT]", "[RESOURCE]");
GetIamPolicySnapshotHttpRequest request = GetIamPolicySnapshotHttpRequest.newBuilder()
.setResource(formattedResource)
.build();
ApiFuture<Policy> future = snapshotClient.getIamPolicySnapshotCallable().futureCall(request);
// Do something
Policy response = future.get();
}
@BetaApi public final SnapshotClient.ListSnapshotsPagedResponse listSnapshots(ProjectName project)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (Snapshot element : snapshotClient.listSnapshots(project).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final SnapshotClient.ListSnapshotsPagedResponse listSnapshots(String project)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectName project = ProjectName.of("[PROJECT]");
for (Snapshot element : snapshotClient.listSnapshots(project.toString()).iterateAll()) {
// doThingsWith(element);
}
}
project
- Project ID for this request.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final SnapshotClient.ListSnapshotsPagedResponse listSnapshots(ListSnapshotsHttpRequest request)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListSnapshotsHttpRequest request = ListSnapshotsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
for (Snapshot element : snapshotClient.listSnapshots(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 fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListSnapshotsHttpRequest,SnapshotClient.ListSnapshotsPagedResponse> listSnapshotsPagedCallable()
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListSnapshotsHttpRequest request = ListSnapshotsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
ApiFuture<ListSnapshotsPagedResponse> future = snapshotClient.listSnapshotsPagedCallable().futureCall(request);
// Do something
for (Snapshot element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
@BetaApi public final com.google.api.gax.rpc.UnaryCallable<ListSnapshotsHttpRequest,SnapshotList> listSnapshotsCallable()
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedProject = ProjectName.format("[PROJECT]");
ListSnapshotsHttpRequest request = ListSnapshotsHttpRequest.newBuilder()
.setProject(formattedProject)
.build();
while (true) {
SnapshotList response = snapshotClient.listSnapshotsCallable().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;
}
}
}
@BetaApi public final Policy setIamPolicySnapshot(ProjectGlobalSnapshotResourceName resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotResourceName resource = ProjectGlobalSnapshotResourceName.of("[PROJECT]", "[RESOURCE]");
GlobalSetPolicyRequest globalSetPolicyRequestResource = GlobalSetPolicyRequest.newBuilder().build();
Policy response = snapshotClient.setIamPolicySnapshot(resource, globalSetPolicyRequestResource);
}
resource
- Name or id of the resource for this request.globalSetPolicyRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Policy setIamPolicySnapshot(String resource, GlobalSetPolicyRequest globalSetPolicyRequestResource)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotResourceName resource = ProjectGlobalSnapshotResourceName.of("[PROJECT]", "[RESOURCE]");
GlobalSetPolicyRequest globalSetPolicyRequestResource = GlobalSetPolicyRequest.newBuilder().build();
Policy response = snapshotClient.setIamPolicySnapshot(resource.toString(), globalSetPolicyRequestResource);
}
resource
- Name or id of the resource for this request.globalSetPolicyRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Policy setIamPolicySnapshot(SetIamPolicySnapshotHttpRequest request)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedResource = ProjectGlobalSnapshotResourceName.format("[PROJECT]", "[RESOURCE]");
GlobalSetPolicyRequest globalSetPolicyRequestResource = GlobalSetPolicyRequest.newBuilder().build();
SetIamPolicySnapshotHttpRequest request = SetIamPolicySnapshotHttpRequest.newBuilder()
.setResource(formattedResource)
.setGlobalSetPolicyRequestResource(globalSetPolicyRequestResource)
.build();
Policy response = snapshotClient.setIamPolicySnapshot(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<SetIamPolicySnapshotHttpRequest,Policy> setIamPolicySnapshotCallable()
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedResource = ProjectGlobalSnapshotResourceName.format("[PROJECT]", "[RESOURCE]");
GlobalSetPolicyRequest globalSetPolicyRequestResource = GlobalSetPolicyRequest.newBuilder().build();
SetIamPolicySnapshotHttpRequest request = SetIamPolicySnapshotHttpRequest.newBuilder()
.setResource(formattedResource)
.setGlobalSetPolicyRequestResource(globalSetPolicyRequestResource)
.build();
ApiFuture<Policy> future = snapshotClient.setIamPolicySnapshotCallable().futureCall(request);
// Do something
Policy response = future.get();
}
@BetaApi public final Operation setLabelsSnapshot(ProjectGlobalSnapshotResourceName resource, GlobalSetLabelsRequest globalSetLabelsRequestResource)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotResourceName resource = ProjectGlobalSnapshotResourceName.of("[PROJECT]", "[RESOURCE]");
GlobalSetLabelsRequest globalSetLabelsRequestResource = GlobalSetLabelsRequest.newBuilder().build();
Operation response = snapshotClient.setLabelsSnapshot(resource, globalSetLabelsRequestResource);
}
resource
- Name or id of the resource for this request.globalSetLabelsRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation setLabelsSnapshot(String resource, GlobalSetLabelsRequest globalSetLabelsRequestResource)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotResourceName resource = ProjectGlobalSnapshotResourceName.of("[PROJECT]", "[RESOURCE]");
GlobalSetLabelsRequest globalSetLabelsRequestResource = GlobalSetLabelsRequest.newBuilder().build();
Operation response = snapshotClient.setLabelsSnapshot(resource.toString(), globalSetLabelsRequestResource);
}
resource
- Name or id of the resource for this request.globalSetLabelsRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final Operation setLabelsSnapshot(SetLabelsSnapshotHttpRequest request)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedResource = ProjectGlobalSnapshotResourceName.format("[PROJECT]", "[RESOURCE]");
GlobalSetLabelsRequest globalSetLabelsRequestResource = GlobalSetLabelsRequest.newBuilder().build();
SetLabelsSnapshotHttpRequest request = SetLabelsSnapshotHttpRequest.newBuilder()
.setResource(formattedResource)
.setGlobalSetLabelsRequestResource(globalSetLabelsRequestResource)
.build();
Operation response = snapshotClient.setLabelsSnapshot(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<SetLabelsSnapshotHttpRequest,Operation> setLabelsSnapshotCallable()
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedResource = ProjectGlobalSnapshotResourceName.format("[PROJECT]", "[RESOURCE]");
GlobalSetLabelsRequest globalSetLabelsRequestResource = GlobalSetLabelsRequest.newBuilder().build();
SetLabelsSnapshotHttpRequest request = SetLabelsSnapshotHttpRequest.newBuilder()
.setResource(formattedResource)
.setGlobalSetLabelsRequestResource(globalSetLabelsRequestResource)
.build();
ApiFuture<Operation> future = snapshotClient.setLabelsSnapshotCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi public final TestPermissionsResponse testIamPermissionsSnapshot(ProjectGlobalSnapshotResourceName resource, TestPermissionsRequest testPermissionsRequestResource)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotResourceName resource = ProjectGlobalSnapshotResourceName.of("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestPermissionsResponse response = snapshotClient.testIamPermissionsSnapshot(resource, testPermissionsRequestResource);
}
resource
- Name or id of the resource for this request.testPermissionsRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final TestPermissionsResponse testIamPermissionsSnapshot(String resource, TestPermissionsRequest testPermissionsRequestResource)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
ProjectGlobalSnapshotResourceName resource = ProjectGlobalSnapshotResourceName.of("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestPermissionsResponse response = snapshotClient.testIamPermissionsSnapshot(resource.toString(), testPermissionsRequestResource);
}
resource
- Name or id of the resource for this request.testPermissionsRequestResource
- com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final TestPermissionsResponse testIamPermissionsSnapshot(TestIamPermissionsSnapshotHttpRequest request)
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedResource = ProjectGlobalSnapshotResourceName.format("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestIamPermissionsSnapshotHttpRequest request = TestIamPermissionsSnapshotHttpRequest.newBuilder()
.setResource(formattedResource)
.setTestPermissionsRequestResource(testPermissionsRequestResource)
.build();
TestPermissionsResponse response = snapshotClient.testIamPermissionsSnapshot(request);
}
request
- The request object containing all of the parameters for the API call.com.google.api.gax.rpc.ApiException
- if the remote call fails@BetaApi public final com.google.api.gax.rpc.UnaryCallable<TestIamPermissionsSnapshotHttpRequest,TestPermissionsResponse> testIamPermissionsSnapshotCallable()
Sample code:
try (SnapshotClient snapshotClient = SnapshotClient.create()) {
String formattedResource = ProjectGlobalSnapshotResourceName.format("[PROJECT]", "[RESOURCE]");
TestPermissionsRequest testPermissionsRequestResource = TestPermissionsRequest.newBuilder().build();
TestIamPermissionsSnapshotHttpRequest request = TestIamPermissionsSnapshotHttpRequest.newBuilder()
.setResource(formattedResource)
.setTestPermissionsRequestResource(testPermissionsRequestResource)
.build();
ApiFuture<TestPermissionsResponse> future = snapshotClient.testIamPermissionsSnapshotCallable().futureCall(request);
// Do something
TestPermissionsResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isShutdown()
isShutdown
in interface com.google.api.gax.core.BackgroundResource
public boolean isTerminated()
isTerminated
in interface com.google.api.gax.core.BackgroundResource
public void shutdownNow()
shutdownNow
in interface com.google.api.gax.core.BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface com.google.api.gax.core.BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.