public interface InstanceAdminClient
Client to do admin operations on Cloud Spanner Instance and Instance Configs.
Methods
cancelOperation(String name)
public abstract void cancelOperation(String name)
Cancels the specified long-running operation.
Parameter |
---|
Name | Description |
name | String
|
createInstance(InstanceInfo instance)
public abstract OperationFuture<Instance,CreateInstanceMetadata> createInstance(InstanceInfo instance)
Creates an instance and begins preparing it to begin serving. The returned Operation
can be used to track the progress of preparing the new instance. The instance name is assigned
by the caller. If the named instance already exists, a SpannerException is thrown. 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
final String instanceId = my_instance_id;
final String configId = my_config_id;
final String clientProject = my_client_project;
Operation<Instance, CreateInstanceMetadata> op =
instanceAdminClient.createInstance(InstanceInfo
.newBuilder(InstanceId.of(clientProject, instanceId))
.setInstanceConfigId(InstanceConfigId.of(clientProject, configId))
.setDisplayName(instanceId)
.setNodeCount(1)
.build());
op.waitFor();
deleteInstance(String instanceId)
public abstract void deleteInstance(String instanceId)
Parameter |
---|
Name | Description |
instanceId | String
|
getInstance(String instanceId)
public abstract Instance getInstance(String instanceId)
Parameter |
---|
Name | Description |
instanceId | String
|
getInstanceConfig(String configId)
public abstract InstanceConfig getInstanceConfig(String configId)
Parameter |
---|
Name | Description |
configId | String
|
getInstanceIAMPolicy(String instanceId)
public abstract Policy getInstanceIAMPolicy(String instanceId)
Returns the IAM policy for the given instance.
Parameter |
---|
Name | Description |
instanceId | String
|
Returns |
---|
Type | Description |
com.google.cloud.Policy | |
getOperation(String name)
public abstract Operation getOperation(String name)
Gets the specified long-running operation.
Parameter |
---|
Name | Description |
name | String
|
listInstanceConfigs(Options.ListOption[] options)
public abstract Page<InstanceConfig> listInstanceConfigs(Options.ListOption[] options)
Lists the supported instance configs for current project.
listInstances(Options.ListOption[] options)
public abstract Page<Instance> listInstances(Options.ListOption[] options)
Parameter |
---|
Name | Description |
options | ListOption[]
Options to control the instances returned. It also supports Options#filter(String) option. The fields eligible for filtering are:
- name
- display_name
- labels.key where key is the name of a label
List<Instance> instances =
Lists.newArrayList(
instanceAdminClient.listInstances(Options.pageSize(1)).iterateAll());
<!--SNIPPET instance_admin_client_list_instances-->
|
newInstanceBuilder(InstanceId id)
public abstract Instance.Builder newInstanceBuilder(InstanceId id)
Returns a builder for Instance
object with the given id.
setInstanceIAMPolicy(String instanceId, Policy policy)
public abstract Policy setInstanceIAMPolicy(String instanceId, Policy policy)
Updates the IAM policy for the given instance and returns the resulting policy. It is highly
recommended to first get the current policy and base the updated policy on the returned policy.
See Policy.Builder#setEtag(String) for information on the recommended read-modify-write
cycle.
Parameters |
---|
Name | Description |
instanceId | String
|
policy | com.google.cloud.Policy
|
Returns |
---|
Type | Description |
com.google.cloud.Policy | |
testInstanceIAMPermissions(String instanceId, Iterable<String> permissions)
public abstract Iterable<String> testInstanceIAMPermissions(String instanceId, Iterable<String> permissions)
Tests for the given permissions on the specified instance for the caller.
Parameters |
---|
Name | Description |
instanceId | String
the id of the instance to test.
|
permissions | Iterable<String>
the permissions to test for. Permissions with wildcards (such as '',
'spanner.', 'spanner.instances.*') are not allowed.
|
Returns |
---|
Type | Description |
Iterable<String> | the subset of the tested permissions that the caller is allowed.
|
updateInstance(InstanceInfo instance, InstanceInfo.InstanceField[] fieldsToUpdate)
public abstract OperationFuture<Instance,UpdateInstanceMetadata> updateInstance(InstanceInfo instance, InstanceInfo.InstanceField[] fieldsToUpdate)
Updates an instance, and begins allocating or releasing resources as requested. The returned
Operation
can be used to track the progress of updating the instance. If the named
instance does not exist, throws SpannerException.
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, 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.
Instance instance = my_instance;
final String clientProject = my_client_project;
final String instanceId = my_instance_id;
final String newDisplayName = my_display_name;
InstanceInfo toUpdate =
InstanceInfo.newBuilder(InstanceId.of(clientProject, instanceId))
.setDisplayName(newDisplayName)
.setNodeCount(instance.getNodeCount() + 1)
.build();
// Only update display name
Operation<Instance, UpdateInstanceMetadata> op =
instanceAdminClient.updateInstance(toUpdate, InstanceInfo.InstanceField.DISPLAY_NAME);
op.waitFor().getResult();