@Generated(value="by gapic-generator") @BetaApi public class InstanceAdminClient extends Object implements BackgroundResource
The Cloud Spanner Instance Admin API can be used to create, delete, modify and list instances. Instances are dedicated Cloud Spanner serving and storage resources to be used by Cloud Spanner databases.
Each instance has a "configuration", which dictates where the serving resources for the Cloud Spanner instance are located (e.g., US-central, Europe). Configurations are created by Google based on resource availability.
Cloud Spanner billing is based on the instances that exist and their sizes. After an instance exists, there are no additional per-database or per-operation charges for use of the instance (though there may be additional network bandwidth charges). Instances offer isolation: problems with databases in one instance will not affect other instances. However, within an instance databases can affect each other. For example, if one database in an instance receives a lot of requests and consumes most of the instance resources, fewer resources are available for other databases in that instance, and their performance may suffer.
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 (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
InstanceConfig response = instanceAdminClient.getInstanceConfig(name);
}
Note: close() needs to be called on the instanceAdminClient 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 InstanceAdminSettings to create(). For example:
To customize credentials:
InstanceAdminSettings instanceAdminSettings =
InstanceAdminSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
InstanceAdminClient instanceAdminClient =
InstanceAdminClient.create(instanceAdminSettings);
To customize the endpoint:
InstanceAdminSettings instanceAdminSettings =
InstanceAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
InstanceAdminClient instanceAdminClient =
InstanceAdminClient.create(instanceAdminSettings);
Modifier and Type | Class and Description |
---|---|
static class |
InstanceAdminClient.ListInstanceConfigsFixedSizeCollection |
static class |
InstanceAdminClient.ListInstanceConfigsPage |
static class |
InstanceAdminClient.ListInstanceConfigsPagedResponse |
static class |
InstanceAdminClient.ListInstancesFixedSizeCollection |
static class |
InstanceAdminClient.ListInstancesPage |
static class |
InstanceAdminClient.ListInstancesPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
InstanceAdminClient(InstanceAdminSettings settings)
Constructs an instance of InstanceAdminClient, using the given settings.
|
protected |
InstanceAdminClient(InstanceAdminStub stub) |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long duration,
TimeUnit unit) |
void |
close() |
static InstanceAdminClient |
create()
Constructs an instance of InstanceAdminClient with default settings.
|
static InstanceAdminClient |
create(InstanceAdminSettings settings)
Constructs an instance of InstanceAdminClient, using the given settings.
|
static InstanceAdminClient |
create(InstanceAdminStub stub)
Constructs an instance of InstanceAdminClient, using the given stub for making calls.
|
OperationFuture<com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.CreateInstanceMetadata> |
createInstanceAsync(com.google.spanner.admin.instance.v1.CreateInstanceRequest request)
Creates an instance and begins preparing it to begin serving.
|
OperationFuture<com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.CreateInstanceMetadata> |
createInstanceAsync(com.google.spanner.admin.instance.v1.ProjectName parent,
com.google.spanner.admin.instance.v1.InstanceName instanceId,
com.google.spanner.admin.instance.v1.Instance instance)
Creates an instance and begins preparing it to begin serving.
|
OperationFuture<com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.CreateInstanceMetadata> |
createInstanceAsync(String parent,
String instanceId,
com.google.spanner.admin.instance.v1.Instance instance)
Creates an instance and begins preparing it to begin serving.
|
UnaryCallable<com.google.spanner.admin.instance.v1.CreateInstanceRequest,Operation> |
createInstanceCallable()
Creates an instance and begins preparing it to begin serving.
|
OperationCallable<com.google.spanner.admin.instance.v1.CreateInstanceRequest,com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.CreateInstanceMetadata> |
createInstanceOperationCallable()
Creates an instance and begins preparing it to begin serving.
|
void |
deleteInstance(com.google.spanner.admin.instance.v1.DeleteInstanceRequest request)
Deletes an instance.
|
void |
deleteInstance(com.google.spanner.admin.instance.v1.InstanceName name)
Deletes an instance.
|
void |
deleteInstance(String name)
Deletes an instance.
|
UnaryCallable<com.google.spanner.admin.instance.v1.DeleteInstanceRequest,Empty> |
deleteInstanceCallable()
Deletes an instance.
|
com.google.iam.v1.Policy |
getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Gets the access control policy for an instance resource.
|
com.google.iam.v1.Policy |
getIamPolicy(String resource)
Gets the access control policy for an instance resource.
|
UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> |
getIamPolicyCallable()
Gets the access control policy for an instance resource.
|
com.google.spanner.admin.instance.v1.Instance |
getInstance(com.google.spanner.admin.instance.v1.GetInstanceRequest request)
Gets information about a particular instance.
|
com.google.spanner.admin.instance.v1.Instance |
getInstance(com.google.spanner.admin.instance.v1.InstanceName name)
Gets information about a particular instance.
|
com.google.spanner.admin.instance.v1.Instance |
getInstance(String name)
Gets information about a particular instance.
|
UnaryCallable<com.google.spanner.admin.instance.v1.GetInstanceRequest,com.google.spanner.admin.instance.v1.Instance> |
getInstanceCallable()
Gets information about a particular instance.
|
com.google.spanner.admin.instance.v1.InstanceConfig |
getInstanceConfig(com.google.spanner.admin.instance.v1.GetInstanceConfigRequest request)
Gets information about a particular instance configuration.
|
com.google.spanner.admin.instance.v1.InstanceConfig |
getInstanceConfig(com.google.spanner.admin.instance.v1.InstanceConfigName name)
Gets information about a particular instance configuration.
|
com.google.spanner.admin.instance.v1.InstanceConfig |
getInstanceConfig(String name)
Gets information about a particular instance configuration.
|
UnaryCallable<com.google.spanner.admin.instance.v1.GetInstanceConfigRequest,com.google.spanner.admin.instance.v1.InstanceConfig> |
getInstanceConfigCallable()
Gets information about a particular instance configuration.
|
OperationsClient |
getOperationsClient()
Returns the OperationsClient that can be used to query the status of a long-running operation
returned by another API method call.
|
InstanceAdminSettings |
getSettings() |
InstanceAdminStub |
getStub() |
boolean |
isShutdown() |
boolean |
isTerminated() |
InstanceAdminClient.ListInstanceConfigsPagedResponse |
listInstanceConfigs(com.google.spanner.admin.instance.v1.ListInstanceConfigsRequest request)
Lists the supported instance configurations for a given project.
|
InstanceAdminClient.ListInstanceConfigsPagedResponse |
listInstanceConfigs(com.google.spanner.admin.instance.v1.ProjectName parent)
Lists the supported instance configurations for a given project.
|
InstanceAdminClient.ListInstanceConfigsPagedResponse |
listInstanceConfigs(String parent)
Lists the supported instance configurations for a given project.
|
UnaryCallable<com.google.spanner.admin.instance.v1.ListInstanceConfigsRequest,com.google.spanner.admin.instance.v1.ListInstanceConfigsResponse> |
listInstanceConfigsCallable()
Lists the supported instance configurations for a given project.
|
UnaryCallable<com.google.spanner.admin.instance.v1.ListInstanceConfigsRequest,InstanceAdminClient.ListInstanceConfigsPagedResponse> |
listInstanceConfigsPagedCallable()
Lists the supported instance configurations for a given project.
|
InstanceAdminClient.ListInstancesPagedResponse |
listInstances(com.google.spanner.admin.instance.v1.ListInstancesRequest request)
Lists all instances in the given project.
|
InstanceAdminClient.ListInstancesPagedResponse |
listInstances(com.google.spanner.admin.instance.v1.ProjectName parent)
Lists all instances in the given project.
|
InstanceAdminClient.ListInstancesPagedResponse |
listInstances(String parent)
Lists all instances in the given project.
|
UnaryCallable<com.google.spanner.admin.instance.v1.ListInstancesRequest,com.google.spanner.admin.instance.v1.ListInstancesResponse> |
listInstancesCallable()
Lists all instances in the given project.
|
UnaryCallable<com.google.spanner.admin.instance.v1.ListInstancesRequest,InstanceAdminClient.ListInstancesPagedResponse> |
listInstancesPagedCallable()
Lists all instances in the given project.
|
com.google.iam.v1.Policy |
setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Sets the access control policy on an instance resource.
|
com.google.iam.v1.Policy |
setIamPolicy(String resource,
com.google.iam.v1.Policy policy)
Sets the access control policy on an instance resource.
|
UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> |
setIamPolicyCallable()
Sets the access control policy on an instance resource.
|
void |
shutdown() |
void |
shutdownNow() |
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(String resource,
List<String> permissions)
Returns permissions that the caller has on the specified instance resource.
|
com.google.iam.v1.TestIamPermissionsResponse |
testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Returns permissions that the caller has on the specified instance resource.
|
UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> |
testIamPermissionsCallable()
Returns permissions that the caller has on the specified instance resource.
|
OperationFuture<com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.UpdateInstanceMetadata> |
updateInstanceAsync(com.google.spanner.admin.instance.v1.Instance instance,
FieldMask fieldMask)
Updates an instance, and begins allocating or releasing resources as requested.
|
OperationFuture<com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.UpdateInstanceMetadata> |
updateInstanceAsync(com.google.spanner.admin.instance.v1.UpdateInstanceRequest request)
Updates an instance, and begins allocating or releasing resources as requested.
|
UnaryCallable<com.google.spanner.admin.instance.v1.UpdateInstanceRequest,Operation> |
updateInstanceCallable()
Updates an instance, and begins allocating or releasing resources as requested.
|
OperationCallable<com.google.spanner.admin.instance.v1.UpdateInstanceRequest,com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.UpdateInstanceMetadata> |
updateInstanceOperationCallable()
Updates an instance, and begins allocating or releasing resources as requested.
|
protected InstanceAdminClient(InstanceAdminSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected InstanceAdminClient(InstanceAdminStub stub)
public static final InstanceAdminClient create() throws IOException
IOException
public static final InstanceAdminClient create(InstanceAdminSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final InstanceAdminClient create(InstanceAdminStub stub)
public final InstanceAdminSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public InstanceAdminStub getStub()
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationsClient getOperationsClient()
public final InstanceAdminClient.ListInstanceConfigsPagedResponse listInstanceConfigs(com.google.spanner.admin.instance.v1.ProjectName parent)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (InstanceConfig element : instanceAdminClient.listInstanceConfigs(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The name of the project for which a list of supported instance
configurations is requested. Values are of the form `projects/<project>`.ApiException
- if the remote call failspublic final InstanceAdminClient.ListInstanceConfigsPagedResponse listInstanceConfigs(String parent)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (InstanceConfig element : instanceAdminClient.listInstanceConfigs(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The name of the project for which a list of supported instance
configurations is requested. Values are of the form `projects/<project>`.ApiException
- if the remote call failspublic final InstanceAdminClient.ListInstanceConfigsPagedResponse listInstanceConfigs(com.google.spanner.admin.instance.v1.ListInstanceConfigsRequest request)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListInstanceConfigsRequest request = ListInstanceConfigsRequest.newBuilder()
.setParent(parent.toString())
.build();
for (InstanceConfig element : instanceAdminClient.listInstanceConfigs(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.spanner.admin.instance.v1.ListInstanceConfigsRequest,InstanceAdminClient.ListInstanceConfigsPagedResponse> listInstanceConfigsPagedCallable()
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListInstanceConfigsRequest request = ListInstanceConfigsRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListInstanceConfigsPagedResponse> future = instanceAdminClient.listInstanceConfigsPagedCallable().futureCall(request);
// Do something
for (InstanceConfig element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.spanner.admin.instance.v1.ListInstanceConfigsRequest,com.google.spanner.admin.instance.v1.ListInstanceConfigsResponse> listInstanceConfigsCallable()
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListInstanceConfigsRequest request = ListInstanceConfigsRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListInstanceConfigsResponse response = instanceAdminClient.listInstanceConfigsCallable().call(request);
for (InstanceConfig element : response.getInstanceConfigsList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.spanner.admin.instance.v1.InstanceConfig getInstanceConfig(com.google.spanner.admin.instance.v1.InstanceConfigName name)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
InstanceConfig response = instanceAdminClient.getInstanceConfig(name);
}
name
- Required. The name of the requested instance configuration. Values are of the form
`projects/<project>/instanceConfigs/<config>`.ApiException
- if the remote call failspublic final com.google.spanner.admin.instance.v1.InstanceConfig getInstanceConfig(String name)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
InstanceConfig response = instanceAdminClient.getInstanceConfig(name.toString());
}
name
- Required. The name of the requested instance configuration. Values are of the form
`projects/<project>/instanceConfigs/<config>`.ApiException
- if the remote call failspublic final com.google.spanner.admin.instance.v1.InstanceConfig getInstanceConfig(com.google.spanner.admin.instance.v1.GetInstanceConfigRequest request)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
GetInstanceConfigRequest request = GetInstanceConfigRequest.newBuilder()
.setName(name.toString())
.build();
InstanceConfig response = instanceAdminClient.getInstanceConfig(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.spanner.admin.instance.v1.GetInstanceConfigRequest,com.google.spanner.admin.instance.v1.InstanceConfig> getInstanceConfigCallable()
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceConfigName name = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]");
GetInstanceConfigRequest request = GetInstanceConfigRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<InstanceConfig> future = instanceAdminClient.getInstanceConfigCallable().futureCall(request);
// Do something
InstanceConfig response = future.get();
}
public final InstanceAdminClient.ListInstancesPagedResponse listInstances(com.google.spanner.admin.instance.v1.ProjectName parent)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Instance element : instanceAdminClient.listInstances(parent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The name of the project for which a list of instances is requested.
Values are of the form `projects/<project>`.ApiException
- if the remote call failspublic final InstanceAdminClient.ListInstancesPagedResponse listInstances(String parent)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
for (Instance element : instanceAdminClient.listInstances(parent.toString()).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The name of the project for which a list of instances is requested.
Values are of the form `projects/<project>`.ApiException
- if the remote call failspublic final InstanceAdminClient.ListInstancesPagedResponse listInstances(com.google.spanner.admin.instance.v1.ListInstancesRequest request)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListInstancesRequest request = ListInstancesRequest.newBuilder()
.setParent(parent.toString())
.build();
for (Instance element : instanceAdminClient.listInstances(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.spanner.admin.instance.v1.ListInstancesRequest,InstanceAdminClient.ListInstancesPagedResponse> listInstancesPagedCallable()
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListInstancesRequest request = ListInstancesRequest.newBuilder()
.setParent(parent.toString())
.build();
ApiFuture<ListInstancesPagedResponse> future = instanceAdminClient.listInstancesPagedCallable().futureCall(request);
// Do something
for (Instance element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<com.google.spanner.admin.instance.v1.ListInstancesRequest,com.google.spanner.admin.instance.v1.ListInstancesResponse> listInstancesCallable()
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
ListInstancesRequest request = ListInstancesRequest.newBuilder()
.setParent(parent.toString())
.build();
while (true) {
ListInstancesResponse response = instanceAdminClient.listInstancesCallable().call(request);
for (Instance element : response.getInstancesList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final com.google.spanner.admin.instance.v1.Instance getInstance(com.google.spanner.admin.instance.v1.InstanceName name)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
Instance response = instanceAdminClient.getInstance(name);
}
name
- Required. The name of the requested instance. Values are of the form
`projects/<project>/instances/<instance>`.ApiException
- if the remote call failspublic final com.google.spanner.admin.instance.v1.Instance getInstance(String name)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
Instance response = instanceAdminClient.getInstance(name.toString());
}
name
- Required. The name of the requested instance. Values are of the form
`projects/<project>/instances/<instance>`.ApiException
- if the remote call failspublic final com.google.spanner.admin.instance.v1.Instance getInstance(com.google.spanner.admin.instance.v1.GetInstanceRequest request)
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
GetInstanceRequest request = GetInstanceRequest.newBuilder()
.setName(name.toString())
.build();
Instance response = instanceAdminClient.getInstance(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.spanner.admin.instance.v1.GetInstanceRequest,com.google.spanner.admin.instance.v1.Instance> getInstanceCallable()
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
GetInstanceRequest request = GetInstanceRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Instance> future = instanceAdminClient.getInstanceCallable().futureCall(request);
// Do something
Instance response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.CreateInstanceMetadata> createInstanceAsync(com.google.spanner.admin.instance.v1.ProjectName parent, com.google.spanner.admin.instance.v1.InstanceName instanceId, com.google.spanner.admin.instance.v1.Instance instance)
Immediately upon completion of this request:
* The instance is readable via the API, with all requested attributes but no allocated resources. Its state is `CREATING`.
Until completion of the returned operation:
* Cancelling the operation renders the instance immediately unreadable via the API. * The instance can be deleted. * All other attempts to modify the instance are rejected.
Upon completion of the returned operation:
* Billing for all successfully-allocated resources begins (some types may have lower than the requested levels). * Databases can be created in the instance. * The instance's allocated resource levels are readable via the API. * The instance's state becomes `READY`.
The returned [long-running operation][google.longrunning.Operation] will have a name of the format `<instance_name>/operations/<operation_id>` and can be used to track creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The [response][google.longrunning.Operation.response] field type is [Instance][google.spanner.admin.instance.v1.Instance], if successful.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
InstanceName instanceId = InstanceName.of("[PROJECT]", "[INSTANCE]");
Instance instance = Instance.newBuilder().build();
Instance response = instanceAdminClient.createInstanceAsync(parent, instanceId, instance).get();
}
parent
- Required. The name of the project in which to create the instance. Values are of
the form `projects/<project>`.instanceId
- Required. The ID of the instance to create. Valid identifiers are of the form
`[a-z][-a-z0-9]*[a-z0-9]` and must be between 6 and 30 characters in length.instance
- Required. The instance to create. The name may be omitted, but if specified
must be `<parent>/instances/<instance_id>`.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.CreateInstanceMetadata> createInstanceAsync(String parent, String instanceId, com.google.spanner.admin.instance.v1.Instance instance)
Immediately upon completion of this request:
* The instance is readable via the API, with all requested attributes but no allocated resources. Its state is `CREATING`.
Until completion of the returned operation:
* Cancelling the operation renders the instance immediately unreadable via the API. * The instance can be deleted. * All other attempts to modify the instance are rejected.
Upon completion of the returned operation:
* Billing for all successfully-allocated resources begins (some types may have lower than the requested levels). * Databases can be created in the instance. * The instance's allocated resource levels are readable via the API. * The instance's state becomes `READY`.
The returned [long-running operation][google.longrunning.Operation] will have a name of the format `<instance_name>/operations/<operation_id>` and can be used to track creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The [response][google.longrunning.Operation.response] field type is [Instance][google.spanner.admin.instance.v1.Instance], if successful.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
InstanceName instanceId = InstanceName.of("[PROJECT]", "[INSTANCE]");
Instance instance = Instance.newBuilder().build();
Instance response = instanceAdminClient.createInstanceAsync(parent.toString(), instanceId.toString(), instance).get();
}
parent
- Required. The name of the project in which to create the instance. Values are of
the form `projects/<project>`.instanceId
- Required. The ID of the instance to create. Valid identifiers are of the form
`[a-z][-a-z0-9]*[a-z0-9]` and must be between 6 and 30 characters in length.instance
- Required. The instance to create. The name may be omitted, but if specified
must be `<parent>/instances/<instance_id>`.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.CreateInstanceMetadata> createInstanceAsync(com.google.spanner.admin.instance.v1.CreateInstanceRequest request)
Immediately upon completion of this request:
* The instance is readable via the API, with all requested attributes but no allocated resources. Its state is `CREATING`.
Until completion of the returned operation:
* Cancelling the operation renders the instance immediately unreadable via the API. * The instance can be deleted. * All other attempts to modify the instance are rejected.
Upon completion of the returned operation:
* Billing for all successfully-allocated resources begins (some types may have lower than the requested levels). * Databases can be created in the instance. * The instance's allocated resource levels are readable via the API. * The instance's state becomes `READY`.
The returned [long-running operation][google.longrunning.Operation] will have a name of the format `<instance_name>/operations/<operation_id>` and can be used to track creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The [response][google.longrunning.Operation.response] field type is [Instance][google.spanner.admin.instance.v1.Instance], if successful.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
InstanceName instanceId = InstanceName.of("[PROJECT]", "[INSTANCE]");
Instance instance = Instance.newBuilder().build();
CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
.setParent(parent.toString())
.setInstanceId(instanceId.toString())
.setInstance(instance)
.build();
Instance response = instanceAdminClient.createInstanceAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<com.google.spanner.admin.instance.v1.CreateInstanceRequest,com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.CreateInstanceMetadata> createInstanceOperationCallable()
Immediately upon completion of this request:
* The instance is readable via the API, with all requested attributes but no allocated resources. Its state is `CREATING`.
Until completion of the returned operation:
* Cancelling the operation renders the instance immediately unreadable via the API. * The instance can be deleted. * All other attempts to modify the instance are rejected.
Upon completion of the returned operation:
* Billing for all successfully-allocated resources begins (some types may have lower than the requested levels). * Databases can be created in the instance. * The instance's allocated resource levels are readable via the API. * The instance's state becomes `READY`.
The returned [long-running operation][google.longrunning.Operation] will have a name of the format `<instance_name>/operations/<operation_id>` and can be used to track creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The [response][google.longrunning.Operation.response] field type is [Instance][google.spanner.admin.instance.v1.Instance], if successful.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
InstanceName instanceId = InstanceName.of("[PROJECT]", "[INSTANCE]");
Instance instance = Instance.newBuilder().build();
CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
.setParent(parent.toString())
.setInstanceId(instanceId.toString())
.setInstance(instance)
.build();
OperationFuture<Instance, CreateInstanceMetadata> future = instanceAdminClient.createInstanceOperationCallable().futureCall(request);
// Do something
Instance response = future.get();
}
public final UnaryCallable<com.google.spanner.admin.instance.v1.CreateInstanceRequest,Operation> createInstanceCallable()
Immediately upon completion of this request:
* The instance is readable via the API, with all requested attributes but no allocated resources. Its state is `CREATING`.
Until completion of the returned operation:
* Cancelling the operation renders the instance immediately unreadable via the API. * The instance can be deleted. * All other attempts to modify the instance are rejected.
Upon completion of the returned operation:
* Billing for all successfully-allocated resources begins (some types may have lower than the requested levels). * Databases can be created in the instance. * The instance's allocated resource levels are readable via the API. * The instance's state becomes `READY`.
The returned [long-running operation][google.longrunning.Operation] will have a name of the format `<instance_name>/operations/<operation_id>` and can be used to track creation of the instance. The [metadata][google.longrunning.Operation.metadata] field type is [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. The [response][google.longrunning.Operation.response] field type is [Instance][google.spanner.admin.instance.v1.Instance], if successful.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
ProjectName parent = ProjectName.of("[PROJECT]");
InstanceName instanceId = InstanceName.of("[PROJECT]", "[INSTANCE]");
Instance instance = Instance.newBuilder().build();
CreateInstanceRequest request = CreateInstanceRequest.newBuilder()
.setParent(parent.toString())
.setInstanceId(instanceId.toString())
.setInstance(instance)
.build();
ApiFuture<Operation> future = instanceAdminClient.createInstanceCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.UpdateInstanceMetadata> updateInstanceAsync(com.google.spanner.admin.instance.v1.Instance instance, FieldMask fieldMask)
Immediately upon completion of this request:
* For resource types for which a decrease in the instance's allocation has been requested, billing is based on the newly-requested level.
Until completion of the returned operation:
* Cancelling the operation sets its metadata's [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins restoring resources to their pre-request values. The operation is guaranteed to succeed at undoing all resource changes, after which point it terminates with a `CANCELLED` status. * All other attempts to modify the instance are rejected. * Reading the instance via the API continues to give the pre-request resource levels.
Upon completion of the returned operation:
* Billing begins for all successfully-allocated resources (some types may have lower than the requested levels). * All newly-reserved resources are available for serving the instance's tables. * The instance's new resource levels are readable via the API.
The returned [long-running operation][google.longrunning.Operation] will have a name of the format `<instance_name>/operations/<operation_id>` and can be used to track the instance modification. The [metadata][google.longrunning.Operation.metadata] field type is [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The [response][google.longrunning.Operation.response] field type is [Instance][google.spanner.admin.instance.v1.Instance], if successful.
Authorization requires `spanner.instances.update` permission on resource [name][google.spanner.admin.instance.v1.Instance.name].
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
Instance instance = Instance.newBuilder().build();
FieldMask fieldMask = FieldMask.newBuilder().build();
Instance response = instanceAdminClient.updateInstanceAsync(instance, fieldMask).get();
}
instance
- Required. The instance to update, which must always include the instance name.
Otherwise, only fields mentioned in
[][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be included.fieldMask
- Required. A mask specifying which fields in
[][google.spanner.admin.instance.v1.UpdateInstanceRequest.instance] should be updated. The
field mask must always be specified; this prevents any future fields in
[][google.spanner.admin.instance.v1.Instance] from being erased accidentally by clients
that do not know about them.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.UpdateInstanceMetadata> updateInstanceAsync(com.google.spanner.admin.instance.v1.UpdateInstanceRequest request)
Immediately upon completion of this request:
* For resource types for which a decrease in the instance's allocation has been requested, billing is based on the newly-requested level.
Until completion of the returned operation:
* Cancelling the operation sets its metadata's [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins restoring resources to their pre-request values. The operation is guaranteed to succeed at undoing all resource changes, after which point it terminates with a `CANCELLED` status. * All other attempts to modify the instance are rejected. * Reading the instance via the API continues to give the pre-request resource levels.
Upon completion of the returned operation:
* Billing begins for all successfully-allocated resources (some types may have lower than the requested levels). * All newly-reserved resources are available for serving the instance's tables. * The instance's new resource levels are readable via the API.
The returned [long-running operation][google.longrunning.Operation] will have a name of the format `<instance_name>/operations/<operation_id>` and can be used to track the instance modification. The [metadata][google.longrunning.Operation.metadata] field type is [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The [response][google.longrunning.Operation.response] field type is [Instance][google.spanner.admin.instance.v1.Instance], if successful.
Authorization requires `spanner.instances.update` permission on resource [name][google.spanner.admin.instance.v1.Instance.name].
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
Instance instance = Instance.newBuilder().build();
FieldMask fieldMask = FieldMask.newBuilder().build();
UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
.setInstance(instance)
.setFieldMask(fieldMask)
.build();
Instance response = instanceAdminClient.updateInstanceAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<com.google.spanner.admin.instance.v1.UpdateInstanceRequest,com.google.spanner.admin.instance.v1.Instance,com.google.spanner.admin.instance.v1.UpdateInstanceMetadata> updateInstanceOperationCallable()
Immediately upon completion of this request:
* For resource types for which a decrease in the instance's allocation has been requested, billing is based on the newly-requested level.
Until completion of the returned operation:
* Cancelling the operation sets its metadata's [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins restoring resources to their pre-request values. The operation is guaranteed to succeed at undoing all resource changes, after which point it terminates with a `CANCELLED` status. * All other attempts to modify the instance are rejected. * Reading the instance via the API continues to give the pre-request resource levels.
Upon completion of the returned operation:
* Billing begins for all successfully-allocated resources (some types may have lower than the requested levels). * All newly-reserved resources are available for serving the instance's tables. * The instance's new resource levels are readable via the API.
The returned [long-running operation][google.longrunning.Operation] will have a name of the format `<instance_name>/operations/<operation_id>` and can be used to track the instance modification. The [metadata][google.longrunning.Operation.metadata] field type is [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The [response][google.longrunning.Operation.response] field type is [Instance][google.spanner.admin.instance.v1.Instance], if successful.
Authorization requires `spanner.instances.update` permission on resource [name][google.spanner.admin.instance.v1.Instance.name].
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
Instance instance = Instance.newBuilder().build();
FieldMask fieldMask = FieldMask.newBuilder().build();
UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
.setInstance(instance)
.setFieldMask(fieldMask)
.build();
OperationFuture<Instance, UpdateInstanceMetadata> future = instanceAdminClient.updateInstanceOperationCallable().futureCall(request);
// Do something
Instance response = future.get();
}
public final UnaryCallable<com.google.spanner.admin.instance.v1.UpdateInstanceRequest,Operation> updateInstanceCallable()
Immediately upon completion of this request:
* For resource types for which a decrease in the instance's allocation has been requested, billing is based on the newly-requested level.
Until completion of the returned operation:
* Cancelling the operation sets its metadata's [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins restoring resources to their pre-request values. The operation is guaranteed to succeed at undoing all resource changes, after which point it terminates with a `CANCELLED` status. * All other attempts to modify the instance are rejected. * Reading the instance via the API continues to give the pre-request resource levels.
Upon completion of the returned operation:
* Billing begins for all successfully-allocated resources (some types may have lower than the requested levels). * All newly-reserved resources are available for serving the instance's tables. * The instance's new resource levels are readable via the API.
The returned [long-running operation][google.longrunning.Operation] will have a name of the format `<instance_name>/operations/<operation_id>` and can be used to track the instance modification. The [metadata][google.longrunning.Operation.metadata] field type is [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. The [response][google.longrunning.Operation.response] field type is [Instance][google.spanner.admin.instance.v1.Instance], if successful.
Authorization requires `spanner.instances.update` permission on resource [name][google.spanner.admin.instance.v1.Instance.name].
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
Instance instance = Instance.newBuilder().build();
FieldMask fieldMask = FieldMask.newBuilder().build();
UpdateInstanceRequest request = UpdateInstanceRequest.newBuilder()
.setInstance(instance)
.setFieldMask(fieldMask)
.build();
ApiFuture<Operation> future = instanceAdminClient.updateInstanceCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final void deleteInstance(com.google.spanner.admin.instance.v1.InstanceName name)
Immediately upon completion of the request:
* Billing ceases for all of the instance's reserved resources.
Soon afterward:
* The instance and *all of its databases* immediately and irrevocably disappear from the API. All data in the databases is permanently deleted.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
instanceAdminClient.deleteInstance(name);
}
name
- Required. The name of the instance to be deleted. Values are of the form
`projects/<project>/instances/<instance>`ApiException
- if the remote call failspublic final void deleteInstance(String name)
Immediately upon completion of the request:
* Billing ceases for all of the instance's reserved resources.
Soon afterward:
* The instance and *all of its databases* immediately and irrevocably disappear from the API. All data in the databases is permanently deleted.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
instanceAdminClient.deleteInstance(name.toString());
}
name
- Required. The name of the instance to be deleted. Values are of the form
`projects/<project>/instances/<instance>`ApiException
- if the remote call failspublic final void deleteInstance(com.google.spanner.admin.instance.v1.DeleteInstanceRequest request)
Immediately upon completion of the request:
* Billing ceases for all of the instance's reserved resources.
Soon afterward:
* The instance and *all of its databases* immediately and irrevocably disappear from the API. All data in the databases is permanently deleted.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder()
.setName(name.toString())
.build();
instanceAdminClient.deleteInstance(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.spanner.admin.instance.v1.DeleteInstanceRequest,Empty> deleteInstanceCallable()
Immediately upon completion of the request:
* Billing ceases for all of the instance's reserved resources.
Soon afterward:
* The instance and *all of its databases* immediately and irrevocably disappear from the API. All data in the databases is permanently deleted.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]");
DeleteInstanceRequest request = DeleteInstanceRequest.newBuilder()
.setName(name.toString())
.build();
ApiFuture<Void> future = instanceAdminClient.deleteInstanceCallable().futureCall(request);
// Do something
future.get();
}
public final com.google.iam.v1.Policy setIamPolicy(String resource, com.google.iam.v1.Policy policy)
Authorization requires `spanner.instances.setIamPolicy` on [resource][google.iam.v1.SetIamPolicyRequest.resource].
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
Policy policy = Policy.newBuilder().build();
Policy response = instanceAdminClient.setIamPolicy(formattedResource, policy);
}
resource
- REQUIRED: The resource for which the policy is being specified. `resource` is
usually specified as a path. For example, a Project resource is specified as
`projects/{project}`.policy
- REQUIRED: The complete policy to be applied to the `resource`. The size of the
policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud
Platform services (such as Projects) might reject them.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy setIamPolicy(com.google.iam.v1.SetIamPolicyRequest request)
Authorization requires `spanner.instances.setIamPolicy` on [resource][google.iam.v1.SetIamPolicyRequest.resource].
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
Policy policy = Policy.newBuilder().build();
SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
.setResource(formattedResource)
.setPolicy(policy)
.build();
Policy response = instanceAdminClient.setIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.SetIamPolicyRequest,com.google.iam.v1.Policy> setIamPolicyCallable()
Authorization requires `spanner.instances.setIamPolicy` on [resource][google.iam.v1.SetIamPolicyRequest.resource].
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
Policy policy = Policy.newBuilder().build();
SetIamPolicyRequest request = SetIamPolicyRequest.newBuilder()
.setResource(formattedResource)
.setPolicy(policy)
.build();
ApiFuture<Policy> future = instanceAdminClient.setIamPolicyCallable().futureCall(request);
// Do something
Policy response = future.get();
}
public final com.google.iam.v1.Policy getIamPolicy(String resource)
Authorization requires `spanner.instances.getIamPolicy` on [resource][google.iam.v1.GetIamPolicyRequest.resource].
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
Policy response = instanceAdminClient.getIamPolicy(formattedResource);
}
resource
- REQUIRED: The resource for which the policy is being requested. `resource` is
usually specified as a path. For example, a Project resource is specified as
`projects/{project}`.ApiException
- if the remote call failspublic final com.google.iam.v1.Policy getIamPolicy(com.google.iam.v1.GetIamPolicyRequest request)
Authorization requires `spanner.instances.getIamPolicy` on [resource][google.iam.v1.GetIamPolicyRequest.resource].
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
.setResource(formattedResource)
.build();
Policy response = instanceAdminClient.getIamPolicy(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.GetIamPolicyRequest,com.google.iam.v1.Policy> getIamPolicyCallable()
Authorization requires `spanner.instances.getIamPolicy` on [resource][google.iam.v1.GetIamPolicyRequest.resource].
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
GetIamPolicyRequest request = GetIamPolicyRequest.newBuilder()
.setResource(formattedResource)
.build();
ApiFuture<Policy> future = instanceAdminClient.getIamPolicyCallable().futureCall(request);
// Do something
Policy response = future.get();
}
public final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(String resource, List<String> permissions)
Attempting this RPC on a non-existent Cloud Spanner instance resource will result in a NOT_FOUND error if the user has `spanner.instances.list` permission on the containing Google Cloud Project. Otherwise returns an empty set of permissions.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse response = instanceAdminClient.testIamPermissions(formattedResource, permissions);
}
resource
- REQUIRED: The resource for which the policy detail is being requested.
`resource` is usually specified as a path. For example, a Project resource is specified as
`projects/{project}`.permissions
- The set of permissions to check for the `resource`. Permissions with
wildcards (such as '*' or 'storage.*') are not allowed. For more information see
[IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).ApiException
- if the remote call failspublic final com.google.iam.v1.TestIamPermissionsResponse testIamPermissions(com.google.iam.v1.TestIamPermissionsRequest request)
Attempting this RPC on a non-existent Cloud Spanner instance resource will result in a NOT_FOUND error if the user has `spanner.instances.list` permission on the containing Google Cloud Project. Otherwise returns an empty set of permissions.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
.setResource(formattedResource)
.addAllPermissions(permissions)
.build();
TestIamPermissionsResponse response = instanceAdminClient.testIamPermissions(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<com.google.iam.v1.TestIamPermissionsRequest,com.google.iam.v1.TestIamPermissionsResponse> testIamPermissionsCallable()
Attempting this RPC on a non-existent Cloud Spanner instance resource will result in a NOT_FOUND error if the user has `spanner.instances.list` permission on the containing Google Cloud Project. Otherwise returns an empty set of permissions.
Sample code:
try (InstanceAdminClient instanceAdminClient = InstanceAdminClient.create()) {
String formattedResource = InstanceName.format("[PROJECT]", "[INSTANCE]");
List<String> permissions = new ArrayList<>();
TestIamPermissionsRequest request = TestIamPermissionsRequest.newBuilder()
.setResource(formattedResource)
.addAllPermissions(permissions)
.build();
ApiFuture<TestIamPermissionsResponse> future = instanceAdminClient.testIamPermissionsCallable().futureCall(request);
// Do something
TestIamPermissionsResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2019 Google LLC. All rights reserved.