Cloud Spanner V1 Client - Class InstanceAdminClient (1.64.0)

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.

This service has a new (beta) implementation. See Google\Cloud\Spanner\Admin\Instance\V1\Client\InstanceAdminClient to use the new surface.

Namespace

Google \ Cloud \ Spanner \ Admin \ Instance \ V1

Methods

__construct

Constructor.

Parameters
NameDescription
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 false.

↳ 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 rest or grpc. Defaults to grpc if gRPC support is detected on the system. Advanced usage: Additionally, it is possible to pass in an already instantiated Google\ApiCore\Transport\TransportInterface object. Note that when this object is provided, any settings in $transportConfig, and any $apiEndpoint setting, will be ignored.

↳ 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
NameDescription
parent string

Required. The name of the project in which to create the instance. Values are of the form projects/<project>.

instanceId string

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 2 and 64 characters in length.

instance Google\Cloud\Spanner\Admin\Instance\V1\Instance

Required. The instance to create. The name may be omitted, but if specified must be <parent>/instances/<instance_id>.

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
TypeDescription
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
NameDescription
parent string

Required. The name of the project in which to create the instance config. Values are of the form projects/<project>.

instanceConfigId string

Required. The ID of the instance config to create. Valid identifiers are of the form custom-[-a-z0-9]*[a-z0-9] and must be between 2 and 64 characters in length. The custom- prefix is required to avoid name conflicts with Google managed configurations.

instanceConfig Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig

Required. The InstanceConfig proto of the configuration to create. instance_config.name must be <parent>/instanceConfigs/<instance_config_id>. instance_config.base_config must be a Google managed configuration name, e.g.

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
TypeDescription
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
NameDescription
name string

Required. The name of the instance to be deleted. Values are of the form projects/<project>/instances/<instance>

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
NameDescription
name string

Required. The name of the instance configuration to be deleted. Values are of the form projects/<project>/instanceConfigs/<instance_config>

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
NameDescription
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 GetPolicyOptions object for specifying options to GetIamPolicy.

↳ 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
TypeDescription
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
NameDescription
name string

Required. The name of the requested instance. Values are of the form projects/<project>/instances/<instance>.

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
TypeDescription
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
NameDescription
name string

Required. The name of the requested instance configuration. Values are of the form projects/<project>/instanceConfigs/<config>.

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
TypeDescription
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
NameDescription
parent string

Required. The project of the instance config operations. Values are of the form projects/<project>.

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: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive. The following fields in the Operation are eligible for filtering: * name - The name of the long-running operation * done - False if the operation is in progress, else true. * metadata.@type - the type of metadata. For example, the type string for CreateInstanceConfigMetadata is type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata. * metadata.<field_name> - any field in metadata.value. metadata.@type must be specified first, if filtering on metadata fields. * error - Error associated with the long-running operation. * response.@type - the type of response. * response.<field_name> - any field in response.value. You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic. However, you can specify AND, OR, and NOT logic explicitly. Here are a few examples: * done:true - The operation is complete. * (metadata.@type= \ type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) AND \ (metadata.instance_config.name:custom-config) AND \ (metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND \ (error:*) - Return operations where: * The operation's metadata type is CreateInstanceConfigMetadata. * The instance config name contains "custom-config". * The operation started before 2021-03-28T14:50:00Z. * The operation resulted in an error.

↳ 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
TypeDescription
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
NameDescription
parent string

Required. The name of the project for which a list of supported instance configurations is requested. Values are of the form projects/<project>.

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
TypeDescription
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
NameDescription
parent string

Required. The name of the project for which a list of instances is requested. Values are of the form projects/<project>.

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: * name * display_name * labels.key where key is the name of a label Some examples of using filters are: * name:* --> The instance has a name. * name:Howl --> The instance's name contains the string "howl". * name:HOWL --> Equivalent to above. * NAME:howl --> Equivalent to above. * labels.env:* --> The instance has the label "env". * labels.env:dev --> The instance has the label "env" and the value of the label contains the string "dev". * name:howl labels.env:dev --> The instance's name contains "howl" and it has the label "env" with its value containing "dev".

↳ 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
TypeDescription
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
NameDescription
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 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.

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: paths: "bindings, etag"

↳ 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
TypeDescription
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
NameDescription
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 resource. Permissions with wildcards (such as '' or 'storage.') are not allowed. For more information see IAM Overview.

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
TypeDescription
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
NameDescription
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
TypeDescription
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
NameDescription
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
TypeDescription
Google\ApiCore\OperationResponse

getOperationsClient

Return an OperationsClient object with the same endpoint as $this.

Returns
TypeDescription
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
NameDescription
operationName string

The name of the long running operation

methodName string

The name of the method used to start the operation

Returns
TypeDescription
Google\ApiCore\OperationResponse

static::instanceName

Formats a string containing the fully-qualified path to represent a instance resource.

Parameters
NameDescription
project string
instance string
Returns
TypeDescription
stringThe formatted instance resource.

static::instanceConfigName

Formats a string containing the fully-qualified path to represent a instance_config resource.

Parameters
NameDescription
project string
instanceConfig string
Returns
TypeDescription
stringThe formatted instance_config resource.

static::projectName

Formats a string containing the fully-qualified path to represent a project resource.

Parameter
NameDescription
project string
Returns
TypeDescription
stringThe formatted project resource.

static::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
NameDescription
formattedName string

The formatted name string

template string

Optional name of template to match

Returns
TypeDescription
arrayAn associative array from name component IDs to component values.

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.