Reference documentation and code samples for the Cloud Spanner V1 Client class InstanceAdminClient.
Service Description: Cloud Spanner Instance Admin API
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:
$instanceAdminClient = new InstanceAdminClient();
try {
$formattedParent = $instanceAdminClient->projectName('[PROJECT]');
$instanceId = 'instance_id';
$instance = new Instance();
$operationResponse = $instanceAdminClient->createInstance($formattedParent, $instanceId, $instance);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $instanceAdminClient->createInstance($formattedParent, $instanceId, $instance);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'createInstance');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$instanceAdminClient->close();
}
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 parseName method to extract the individual identifiers contained within formatted names that are returned by the API.
Methods
instanceName
Formats a string containing the fully-qualified path to represent a instance resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
instance |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted instance resource. |
instanceConfigName
Formats a string containing the fully-qualified path to represent a instance_config resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
instanceConfig |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted instance_config resource. |
projectName
Formats a string containing the fully-qualified path to represent a project resource.
Parameter | |
---|---|
Name | Description |
project |
string
|
Returns | |
---|---|
Type | Description |
string | The formatted project resource. |
parseName
Parses a formatted name string and returns an associative array of the components in the name.
The following name formats are supported: Template: Pattern
- instance: projects/{project}/instances/{instance}
- instanceConfig: projects/{project}/instanceConfigs/{instance_config}
- project: projects/{project}
The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.
Parameters | |
---|---|
Name | Description |
formattedName |
string
The formatted name string |
template |
string
Optional name of template to match |
Returns | |
---|---|
Type | Description |
array | An associative array from name component IDs to component values. |
getOperationsClient
Return an OperationsClient object with the same endpoint as $this.
Returns | |
---|---|
Type | Description |
Google\ApiCore\LongRunning\OperationsClient |
resumeOperation
Resume an existing long running operation that was previously started by a long running API method. If $methodName is not provided, or does not match a long running API method, then the operation can still be resumed, but the OperationResponse object will not deserialize the final response.
Parameters | |
---|---|
Name | Description |
operationName |
string
The name of the long running operation |
methodName |
string
The name of the method used to start the operation |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
options |
array
Optional. Options for configuring the service API wrapper. |
↳ apiEndpoint |
string
The address of the API remote host. May optionally include the port, formatted as "
|
↳ credentials |
string|array|FetchAuthTokenInterface|CredentialsWrapper
The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. |
↳ credentialsConfig |
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() . |
↳ disableRetries |
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to |
↳ clientConfig |
string|array
Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder. |
↳ transport |
string|TransportInterface
The transport used for executing network requests. May be either the string |
↳ transportConfig |
array
Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'grpc' => [...], 'rest' => [...], ]; See the Google\ApiCore\Transport\GrpcTransport::build() and Google\ApiCore\Transport\RestTransport::build() methods for the supported options. |
↳ clientCertSource |
callable
A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS. |
createInstance
Creates an instance and begins preparing it to begin serving. The
returned long-running 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, CreateInstance
returns
ALREADY_EXISTS
.
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 will
have a name of the format <instance_name>/operations/<operation_id>
and
can be used to track creation of the instance. The
metadata field type is
CreateInstanceMetadata.
The response field type is
Instance, if successful.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$formattedParent = $instanceAdminClient->projectName('[PROJECT]');
$instanceId = 'instance_id';
$instance = new Instance();
$operationResponse = $instanceAdminClient->createInstance($formattedParent, $instanceId, $instance);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $instanceAdminClient->createInstance($formattedParent, $instanceId, $instance);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'createInstance');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The name of the project in which to create the instance. Values
are of the form |
instanceId |
string
Required. The ID of the instance to create. Valid identifiers are of the
form |
instance |
Google\Cloud\Spanner\Admin\Instance\V1\Instance
Required. The instance to create. The name may be omitted, but if
specified must be |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
createInstanceConfig
Creates an instance config and begins preparing it to be used. The
returned long-running operation
can be used to track the progress of preparing the new
instance config. The instance config name is assigned by the caller. If the
named instance config already exists, CreateInstanceConfig
returns
ALREADY_EXISTS
.
Immediately after the request returns:
- The instance config is readable via the API, with all requested
attributes. The instance config's
reconciling
field is set to true. Its state is
CREATING
.
While the operation is pending:
- Cancelling the operation renders the instance config immediately unreadable via the API.
- Except for deleting the creating resource, all other attempts to modify the instance config are rejected.
Upon completion of the returned operation:
- Instances can be created using the instance configuration.
- The instance config's
reconciling
field becomes false. Its state becomes
READY
.
The returned long-running operation will
have a name of the format
<instance_config_name>/operations/<operation_id>
and can be used to track
creation of the instance config. The
metadata field type is
CreateInstanceConfigMetadata.
The response field type is
InstanceConfig, if
successful.
Authorization requires spanner.instanceConfigs.create
permission on
the resource
parent.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$formattedParent = $instanceAdminClient->projectName('[PROJECT]');
$instanceConfigId = 'instance_config_id';
$instanceConfig = new InstanceConfig();
$operationResponse = $instanceAdminClient->createInstanceConfig($formattedParent, $instanceConfigId, $instanceConfig);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $instanceAdminClient->createInstanceConfig($formattedParent, $instanceConfigId, $instanceConfig);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'createInstanceConfig');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The name of the project in which to create the instance config.
Values are of the form |
instanceConfigId |
string
Required. The ID of the instance config to create. Valid identifiers are
of the form |
instanceConfig |
Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig
Required. The InstanceConfig proto of the configuration to create.
instance_config.name must be
|
optionalArgs |
array
Optional. |
↳ validateOnly |
bool
An option to validate, but not actually execute, a request, and provide the same response. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
deleteInstance
Deletes an instance.
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:
$instanceAdminClient = new InstanceAdminClient();
try {
$formattedName = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]');
$instanceAdminClient->deleteInstance($formattedName);
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the instance to be deleted. Values are of the form
|
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
deleteInstanceConfig
Deletes the instance config. Deletion is only allowed when no
instances are using the configuration. If any instances are using
the config, returns FAILED_PRECONDITION
.
Only user managed configurations can be deleted.
Authorization requires spanner.instanceConfigs.delete
permission on
the resource name.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$formattedName = $instanceAdminClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]');
$instanceAdminClient->deleteInstanceConfig($formattedName);
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the instance configuration to be deleted.
Values are of the form
|
optionalArgs |
array
Optional. |
↳ etag |
string
Used for optimistic concurrency control as a way to help prevent simultaneous deletes of an instance config from overwriting each other. If not empty, the API only deletes the instance config when the etag provided matches the current status of the requested instance config. Otherwise, deletes the instance config without checking the current status of the requested instance config. |
↳ validateOnly |
bool
An option to validate, but not actually execute, a request, and provide the same response. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
getIamPolicy
Gets the access control policy for an instance resource. Returns an empty policy if an instance exists but does not have a policy set.
Authorization requires spanner.instances.getIamPolicy
on
resource.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$resource = 'resource';
$response = $instanceAdminClient->getIamPolicy($resource);
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
resource |
string
REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field. |
optionalArgs |
array
Optional. |
↳ options |
GetPolicyOptions
OPTIONAL: A |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Iam\V1\Policy |
getInstance
Gets information about a particular instance.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$formattedName = $instanceAdminClient->instanceName('[PROJECT]', '[INSTANCE]');
$response = $instanceAdminClient->getInstance($formattedName);
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the requested instance. Values are of the form
|
optionalArgs |
array
Optional. |
↳ fieldMask |
FieldMask
If field_mask is present, specifies the subset of Instance fields that should be returned. If absent, all Instance fields are returned. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Spanner\Admin\Instance\V1\Instance |
getInstanceConfig
Gets information about a particular instance configuration.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$formattedName = $instanceAdminClient->instanceConfigName('[PROJECT]', '[INSTANCE_CONFIG]');
$response = $instanceAdminClient->getInstanceConfig($formattedName);
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
name |
string
Required. The name of the requested instance configuration. Values are of
the form |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig |
listInstanceConfigOperations
Lists the user-managed instance config long-running
operations in the given project. An instance
config operation has a name of the form
projects/<project>/instanceConfigs/<instance_config>/operations/<operation>
.
The long-running operation
metadata field type
metadata.type_url
describes the type of the metadata. Operations returned
include those that have completed/failed/canceled within the last 7 days,
and pending operations. Operations returned are ordered by
operation.metadata.value.start_time
in descending order starting
from the most recently started operation.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$formattedParent = $instanceAdminClient->projectName('[PROJECT]');
// Iterate over pages of elements
$pagedResponse = $instanceAdminClient->listInstanceConfigOperations($formattedParent);
foreach ($pagedResponse->iteratePages() as $page) {
foreach ($page as $element) {
// doSomethingWith($element);
}
}
// Alternatively:
// Iterate through all elements
$pagedResponse = $instanceAdminClient->listInstanceConfigOperations($formattedParent);
foreach ($pagedResponse->iterateAllElements() as $element) {
// doSomethingWith($element);
}
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The project of the instance config operations.
Values are of the form |
optionalArgs |
array
Optional. |
↳ filter |
string
An expression that filters the list of returned operations. A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: |
↳ pageSize |
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved. |
↳ pageToken |
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
listInstanceConfigs
Lists the supported instance configurations for a given project.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$formattedParent = $instanceAdminClient->projectName('[PROJECT]');
// Iterate over pages of elements
$pagedResponse = $instanceAdminClient->listInstanceConfigs($formattedParent);
foreach ($pagedResponse->iteratePages() as $page) {
foreach ($page as $element) {
// doSomethingWith($element);
}
}
// Alternatively:
// Iterate through all elements
$pagedResponse = $instanceAdminClient->listInstanceConfigs($formattedParent);
foreach ($pagedResponse->iterateAllElements() as $element) {
// doSomethingWith($element);
}
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The name of the project for which a list of supported instance
configurations is requested. Values are of the form
|
optionalArgs |
array
Optional. |
↳ pageSize |
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved. |
↳ pageToken |
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
listInstances
Lists all instances in the given project.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$formattedParent = $instanceAdminClient->projectName('[PROJECT]');
// Iterate over pages of elements
$pagedResponse = $instanceAdminClient->listInstances($formattedParent);
foreach ($pagedResponse->iteratePages() as $page) {
foreach ($page as $element) {
// doSomethingWith($element);
}
}
// Alternatively:
// Iterate through all elements
$pagedResponse = $instanceAdminClient->listInstances($formattedParent);
foreach ($pagedResponse->iterateAllElements() as $element) {
// doSomethingWith($element);
}
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
parent |
string
Required. The name of the project for which a list of instances is
requested. Values are of the form |
optionalArgs |
array
Optional. |
↳ pageSize |
int
The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved. |
↳ pageToken |
string
A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. |
↳ filter |
string
An expression for filtering the results of the request. Filter rules are case insensitive. The fields eligible for filtering are: * |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
setIamPolicy
Sets the access control policy on an instance resource. Replaces any existing policy.
Authorization requires spanner.instances.setIamPolicy
on
resource.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$resource = 'resource';
$policy = new Policy();
$response = $instanceAdminClient->setIamPolicy($resource, $policy);
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
resource |
string
REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field. |
policy |
Google\Cloud\Iam\V1\Policy
REQUIRED: The complete policy to be applied to the |
optionalArgs |
array
Optional. |
↳ updateMask |
FieldMask
OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Iam\V1\Policy |
testIamPermissions
Returns permissions that the caller has on the specified instance resource.
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:
$instanceAdminClient = new InstanceAdminClient();
try {
$resource = 'resource';
$permissions = [];
$response = $instanceAdminClient->testIamPermissions($resource, $permissions);
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
resource |
string
REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field. |
permissions |
string[]
The set of permissions to check for the |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Iam\V1\TestIamPermissionsResponse |
updateInstance
Updates an instance, and begins allocating or releasing resources
as requested. The returned long-running
operation can be used to track the
progress of updating the instance. If the named instance does not
exist, returns NOT_FOUND
.
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.
The returned long-running operation will
have a name of the format <instance_name>/operations/<operation_id>
and
can be used to track the instance modification. The
metadata field type is
UpdateInstanceMetadata.
The response field type is
Instance, if successful.
Authorization requires spanner.instances.update
permission on
the resource name.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$instance = new Instance();
$fieldMask = new FieldMask();
$operationResponse = $instanceAdminClient->updateInstance($instance, $fieldMask);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $instanceAdminClient->updateInstance($instance, $fieldMask);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'updateInstance');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
instance |
Google\Cloud\Spanner\Admin\Instance\V1\Instance
Required. The instance to update, which must always include the instance name. Otherwise, only fields mentioned in field_mask need be included. |
fieldMask |
Google\Protobuf\FieldMask
Required. A mask specifying which fields in Instance should be updated. The field mask must always be specified; this prevents any future fields in Instance from being erased accidentally by clients that do not know about them. |
optionalArgs |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
updateInstanceConfig
Updates an instance config. The returned
long-running operation can be used to track
the progress of updating the instance. If the named instance config does
not exist, returns NOT_FOUND
.
Only user managed configurations can be updated.
Immediately after the request returns:
- The instance config's reconciling field is set to true.
While the operation is pending:
- Cancelling the operation sets its metadata's
cancel_time.
The operation is guaranteed to succeed at undoing all changes, after
which point it terminates with a
CANCELLED
status. - All other attempts to modify the instance config are rejected.
- Reading the instance config via the API continues to give the pre-request values.
Upon completion of the returned operation:
- Creating instances using the instance configuration uses the new values.
- The instance config's new values are readable via the API.
- The instance config's reconciling field becomes false.
The returned long-running operation will
have a name of the format
<instance_config_name>/operations/<operation_id>
and can be used to track
the instance config modification. The
metadata field type is
UpdateInstanceConfigMetadata.
The response field type is
InstanceConfig, if
successful.
Authorization requires spanner.instanceConfigs.update
permission on
the resource name.
Sample code:
$instanceAdminClient = new InstanceAdminClient();
try {
$instanceConfig = new InstanceConfig();
$updateMask = new FieldMask();
$operationResponse = $instanceAdminClient->updateInstanceConfig($instanceConfig, $updateMask);
$operationResponse->pollUntilComplete();
if ($operationResponse->operationSucceeded()) {
$result = $operationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $operationResponse->getError();
// handleError($error)
}
// Alternatively:
// start the operation, keep the operation name, and resume later
$operationResponse = $instanceAdminClient->updateInstanceConfig($instanceConfig, $updateMask);
$operationName = $operationResponse->getName();
// ... do other work
$newOperationResponse = $instanceAdminClient->resumeOperation($operationName, 'updateInstanceConfig');
while (!$newOperationResponse->isDone()) {
// ... do other work
$newOperationResponse->reload();
}
if ($newOperationResponse->operationSucceeded()) {
$result = $newOperationResponse->getResult();
// doSomethingWith($result)
} else {
$error = $newOperationResponse->getError();
// handleError($error)
}
} finally {
$instanceAdminClient->close();
}
Parameters | |
---|---|
Name | Description |
instanceConfig |
Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig
Required. The user instance config to update, which must always include the instance config name. Otherwise, only fields mentioned in update_mask need be included. To prevent conflicts of concurrent updates, etag can be used. |
updateMask |
Google\Protobuf\FieldMask
Required. A mask specifying which fields in InstanceConfig should be updated. The field mask must always be specified; this prevents any future fields in InstanceConfig from being erased accidentally by clients that do not know about them. Only display_name and labels can be updated. |
optionalArgs |
array
Optional. |
↳ validateOnly |
bool
An option to validate, but not actually execute, a request, and provide the same response. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\OperationResponse |
Constants
SERVICE_NAME
Value: 'google.spanner.admin.instance.v1.InstanceAdmin'
The name of the service.
SERVICE_ADDRESS
Value: 'spanner.googleapis.com'
The default address of the service.
DEFAULT_SERVICE_PORT
Value: 443
The default port of the service.
CODEGEN_NAME
Value: 'gapic'
The name of the code generator, to be included in the agent header.