InstanceAdminClient

InstanceAdminClient

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.

Constructor

new InstanceAdminClient(optionsopt)

Construct an instance of InstanceAdminClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. See the subsequent parameters for more details.

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

apiEndpoint string <optional>

The domain name of the API remote host.

Members

(static) apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

(static) port

The port for this API service.

(static) scopes

The scopes needed to make gRPC calls for every method defined in this service.

(static) servicePath

The DNS address for this API service.

Methods

(async) checkCreateInstanceProgress(name) → {Promise}

Check the status of the long running operation returned by the createInstance() method.

Parameters:
Name Type Description
name String

The operation name that will be passed.

(async) checkUpdateInstanceProgress(name) → {Promise}

Check the status of the long running operation returned by the updateInstance() method.

Parameters:
Name Type Description
name String

The operation name that will be passed.

close()

Terminate the GRPC channel and close the client.

The client will no longer be usable and all future behavior is undefined.

createInstance(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
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] and must be between 2 and 64 characters in length.

instance google.spanner.admin.instance.v1.Instance

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

options object <optional>

Call options. See CallOptions for more details.

deleteInstance(request, optionsopt) → {Promise}

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.
Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

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

options object <optional>

Call options. See CallOptions for more details.

getIamPolicy(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
resource string

REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.

options google.iam.v1.GetPolicyOptions

OPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy. This field is only used by Cloud IAM.

options object <optional>

Call options. See CallOptions for more details.

getInstance(request, optionsopt) → {Promise}

Gets information about a particular instance.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

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

fieldMask google.protobuf.FieldMask

If field_mask is present, specifies the subset of Instance fields that should be returned. If absent, all Instance fields are returned.

options object <optional>

Call options. See CallOptions for more details.

getInstanceConfig(request, optionsopt) → {Promise}

Gets information about a particular instance configuration.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

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

options object <optional>

Call options. See CallOptions for more details.

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

initialize() → {Promise}

Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.

You can await on this method if you want to make sure the client is initialized.

instanceConfigPath(project, instance_config) → {string}

Return a fully-qualified instanceConfig resource name string.

Parameters:
Name Type Description
project string
instance_config string

instancePath(project, instance) → {string}

Return a fully-qualified instance resource name string.

Parameters:
Name Type Description
project string
instance string

listInstanceConfigs(request, optionsopt) → {Promise}

Lists the supported instance configurations for a given project.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
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>.

pageSize number

Number of instance configurations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListInstanceConfigsResponse.

options object <optional>

Call options. See CallOptions for more details.

listInstanceConfigsAsync(request, optionsopt) → {Object}

Equivalent to listInstanceConfigs, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
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>.

pageSize number

Number of instance configurations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListInstanceConfigsResponse.

options object <optional>

Call options. See CallOptions for more details.

listInstanceConfigsStream(request, optionsopt) → {Stream}

Equivalent to listInstanceConfigs, but returns a NodeJS Stream object.

This fetches the paged responses for listInstanceConfigs continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
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>.

pageSize number

Number of instance configurations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListInstanceConfigsResponse.

options object <optional>

Call options. See CallOptions for more details.

See:

listInstances(request, optionsopt) → {Promise}

Lists all instances in the given project.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

pageSize number

Number of instances to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListInstancesResponse.

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".
options object <optional>

Call options. See CallOptions for more details.

listInstancesAsync(request, optionsopt) → {Object}

Equivalent to listInstances, but returns an iterable object.

for-await-of syntax is used with the iterable to recursively get response element on-demand.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

pageSize number

Number of instances to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListInstancesResponse.

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".
options object <optional>

Call options. See CallOptions for more details.

listInstancesStream(request, optionsopt) → {Stream}

Equivalent to listInstances, but returns a NodeJS Stream object.

This fetches the paged responses for listInstances continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
parent string

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

pageSize number

Number of instances to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.

pageToken string

If non-empty, page_token should contain a next_page_token from a previous ListInstancesResponse.

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".
options object <optional>

Call options. See CallOptions for more details.

See:

matchInstanceConfigFromInstanceConfigName(instanceConfigName) → {string}

Parse the instance_config from InstanceConfig resource.

Parameters:
Name Type Description
instanceConfigName string

A fully-qualified path representing InstanceConfig resource.

matchInstanceFromInstanceName(instanceName) → {string}

Parse the instance from Instance resource.

Parameters:
Name Type Description
instanceName string

A fully-qualified path representing Instance resource.

matchProjectFromInstanceConfigName(instanceConfigName) → {string}

Parse the project from InstanceConfig resource.

Parameters:
Name Type Description
instanceConfigName string

A fully-qualified path representing InstanceConfig resource.

matchProjectFromInstanceName(instanceName) → {string}

Parse the project from Instance resource.

Parameters:
Name Type Description
instanceName string

A fully-qualified path representing Instance resource.

setIamPolicy(request, optionsopt) → {Promise}

Sets the access control policy on an instance resource. Replaces any existing policy.

Authorization requires spanner.instances.setIamPolicy on resource.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type 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.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.

options object <optional>

Call options. See CallOptions for more details.

testIamPermissions(request, optionsopt) → {Promise}

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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type 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 Array.<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.

options object <optional>

Call options. See CallOptions for more details.

updateInstance(request, optionsopt) → {Promise}

Updates an instance, and begins allocating or releasing resources as requested. The returned [long-running operation][google.longrunning.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 resource name.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
instance google.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.

options object <optional>

Call options. See CallOptions for more details.