Constructor

InstanceAdminClient

new InstanceAdminClient(options)

Construct an instance of InstanceAdminClient.

Parameter

options

Optional

object

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

Values in options have the following properties:

Parameter

credentials

Optional

object

Credentials object.

credentials.client_email

Optional

string

credentials.private_key

Optional

string

email

Optional

string

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

keyFilename

Optional

string

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 above is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port

Optional

number

The port on which to connect to the remote host.

projectId

Optional

string

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.

promise

Optional

function()

Custom promise module to use instead of native Promises.

servicePath

Optional

string

The domain name of the API remote host.

Properties

port

static

The port for this API service.

scopes

static

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

servicePath

static

The DNS address for this API service.

Methods

createInstance

createInstance(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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 6 and 30 characters in length.

instance

Object

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

This object should have the same structure as Instance

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is a gax.Operation object.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

var formattedParent = client.projectPath('[PROJECT]');
var instanceId = '';
var instance = {};
var request = {
  parent: formattedParent,
  instanceId: instanceId,
  instance: instance,
};

// Handle the operation using the promise pattern.
client.createInstance(request)
  .then(responses => {
    var operation = responses[0];
    var initialApiResponse = responses[1];

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    // The final result of the operation.
    var result = responses[0];

    // The metadata value of the completed operation.
    var metadata = responses[1];

    // The response of the api call returning the complete operation.
    var finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

var formattedParent = client.projectPath('[PROJECT]');
var instanceId = '';
var instance = {};
var request = {
  parent: formattedParent,
  instanceId: instanceId,
  instance: instance,
};

// Handle the operation using the event emitter pattern.
client.createInstance(request)
  .then(responses => {
    var operation = responses[0];
    var initialApiResponse = responses[1];

    // Adding a listener for the "complete" event starts polling for the
    // completion of the operation.
    operation.on('complete', (result, metadata, finalApiResponse) => {
      // doSomethingWith(result);
    });

    // Adding a listener for the "progress" event causes the callback to be
    // called on any change in metadata when the operation is polled.
    operation.on('progress', (metadata, apiResponse) => {
      // doSomethingWith(metadata)
    });

    // Adding a listener for the "error" event handles any errors found during polling.
    operation.on('error', err => {
      // throw(err);
    });
  })
  .catch(err => {
    console.error(err);
  });

deleteInstance

deleteInstance(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error)

The function which will be called with the result of the API call.

Returns

Promise 

  • The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

var formattedName = client.instancePath('[PROJECT]', '[INSTANCE]');
client.deleteInstance({name: formattedName}).catch(err => {
  console.error(err);
});

getIamPolicy

getIamPolicy(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

resource

string

REQUIRED: The resource for which the policy is being requested. resource is usually specified as a path. For example, a Project resource is specified as projects/{project}.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Policy.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Policy. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

var formattedResource = client.instancePath('[PROJECT]', '[INSTANCE]');
client.getIamPolicy({resource: formattedResource})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getInstance

getInstance(request, options, callback) returns Promise

Gets information about a particular instance.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Instance.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Instance. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

var formattedName = client.instancePath('[PROJECT]', '[INSTANCE]');
client.getInstance({name: formattedName})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getInstanceConfig

getInstanceConfig(request, options, callback) returns Promise

Gets information about a particular instance configuration.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

name

string

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

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing InstanceConfig.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing InstanceConfig. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

var formattedName = client.instanceConfigPath('[PROJECT]', '[INSTANCE_CONFIG]');
client.getInstanceConfig({name: formattedName})
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getProjectId

getProjectId(callback)

Return the project ID used by this class.

Parameter

callback

function(Error, string)

the callback to be called with the current project Id.

instanceConfigPath

instanceConfigPath(project, instanceConfig) returns String

Return a fully-qualified instance_config resource name string.

Parameter

project

String

instanceConfig

String

Returns

String 

instancePath

instancePath(project, instance) returns String

Return a fully-qualified instance resource name string.

Parameter

project

String

instance

String

Returns

String 

listInstanceConfigs

listInstanceConfigs(request, options, callback) returns Promise

Lists the supported instance configurations for a given project.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is Array of InstanceConfig.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListInstanceConfigsResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of InstanceConfig.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of InstanceConfig in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListInstanceConfigsResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

// Iterate over all elements.
var formattedParent = client.projectPath('[PROJECT]');

client.listInstanceConfigs({parent: formattedParent})
  .then(responses => {
    var resources = responses[0];
    for (let i = 0; i < resources.length; i += 1) {
      // doThingsWith(resources[i])
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
var formattedParent = client.projectPath('[PROJECT]');


var options = {autoPaginate: false};
var callback = responses => {
  // The actual resources in a response.
  var resources = responses[0];
  // The next request if the response shows that there are more responses.
  var nextRequest = responses[1];
  // The actual response object, if necessary.
  // var rawResponse = responses[2];
  for (let i = 0; i < resources.length; i += 1) {
    // doThingsWith(resources[i]);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listInstanceConfigs(nextRequest, options).then(callback);
  }
}
client.listInstanceConfigs({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listInstanceConfigsStream

listInstanceConfigsStream(request, options) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

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

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing InstanceConfig on 'data' event.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

var formattedParent = client.projectPath('[PROJECT]');
client.listInstanceConfigsStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

listInstances

listInstances(request, options, callback) returns Promise

Lists all instances in the given project.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

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

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

filter

Optional

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

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Array, nullable Object, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is Array of Instance.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListInstancesResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is Array of Instance.

    When autoPaginate: false is specified through options, the array has three elements. The first element is Array of Instance in a single response. The second element is the next request object if the response indicates the next page exists, or null. The third element is an object representing ListInstancesResponse.

    The promise has a method named "cancel" which cancels the ongoing API call.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

// Iterate over all elements.
var formattedParent = client.projectPath('[PROJECT]');

client.listInstances({parent: formattedParent})
  .then(responses => {
    var resources = responses[0];
    for (let i = 0; i < resources.length; i += 1) {
      // doThingsWith(resources[i])
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
var formattedParent = client.projectPath('[PROJECT]');


var options = {autoPaginate: false};
var callback = responses => {
  // The actual resources in a response.
  var resources = responses[0];
  // The next request if the response shows that there are more responses.
  var nextRequest = responses[1];
  // The actual response object, if necessary.
  // var rawResponse = responses[2];
  for (let i = 0; i < resources.length; i += 1) {
    // doThingsWith(resources[i]);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listInstances(nextRequest, options).then(callback);
  }
}
client.listInstances({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listInstancesStream

listInstancesStream(request, options) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

parent

string

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

pageSize

Optional

number

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

filter

Optional

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

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

See also
https://nodejs.org/api/stream.html
Returns

Stream 

An object stream which emits an object representing Instance on 'data' event.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

var formattedParent = client.projectPath('[PROJECT]');
client.listInstancesStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

matchInstanceConfigFromInstanceConfigName

matchInstanceConfigFromInstanceConfigName(instanceConfigName) returns String

Parse the instanceConfigName from a instance_config resource.

Parameter

instanceConfigName

String

A fully-qualified path representing a instance_config resources.

Returns

String 

  • A string representing the instance_config.

matchInstanceFromInstanceName

matchInstanceFromInstanceName(instanceName) returns String

Parse the instanceName from a instance resource.

Parameter

instanceName

String

A fully-qualified path representing a instance resources.

Returns

String 

  • A string representing the instance.

matchProjectFromInstanceConfigName

matchProjectFromInstanceConfigName(instanceConfigName) returns String

Parse the instanceConfigName from a instance_config resource.

Parameter

instanceConfigName

String

A fully-qualified path representing a instance_config resources.

Returns

String 

  • A string representing the project.

matchProjectFromInstanceName

matchProjectFromInstanceName(instanceName) returns String

Parse the instanceName from a instance resource.

Parameter

instanceName

String

A fully-qualified path representing a instance resources.

Returns

String 

  • A string representing the project.

matchProjectFromProjectName

matchProjectFromProjectName(projectName) returns String

Parse the projectName from a project resource.

Parameter

projectName

String

A fully-qualified path representing a project resources.

Returns

String 

  • A string representing the project.

projectPath

projectPath(project) returns String

Return a fully-qualified project resource name string.

Parameter

project

String

Returns

String 

setIamPolicy

setIamPolicy(request, options, callback) returns Promise

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

Authorization requires spanner.instances.setIamPolicy on resource.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

resource

string

REQUIRED: The resource for which the policy is being specified. resource is usually specified as a path. For example, a Project resource is specified as projects/{project}.

policy

Object

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.

This object should have the same structure as Policy

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Policy.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing Policy. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

var formattedResource = client.instancePath('[PROJECT]', '[INSTANCE]');
var policy = {};
var request = {
  resource: formattedResource,
  policy: policy,
};
client.setIamPolicy(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

testIamPermissions

testIamPermissions(request, options, callback) returns 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.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

resource

string

REQUIRED: The resource for which the policy detail is being requested. resource is usually specified as a path. For example, a Project resource is specified as projects/{project}.

permissions

Array of 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

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing TestIamPermissionsResponse.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is an object representing TestIamPermissionsResponse. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

var formattedResource = client.instancePath('[PROJECT]', '[INSTANCE]');
var permissions = [];
var request = {
  resource: formattedResource,
  permissions: permissions,
};
client.testIamPermissions(request)
  .then(responses => {
    var response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

updateInstance

updateInstance(request, options, callback) returns Promise

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 resource name.

Parameter

request

Object

The request object that will be sent.

Values in request have the following properties:

Parameter

instance

Object

Required. The instance to update, which must always include the instance name. Otherwise, only fields mentioned in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask] need be included.

This object should have the same structure as Instance

fieldMask

Object

Required. A mask specifying which fields in [][google.spanner.admin.instance.v1.UpdateInstanceRequest.instance] should be updated. The field mask must always be specified; this prevents any future fields in [][google.spanner.admin.instance.v1.Instance] from being erased accidentally by clients that do not know about them.

This object should have the same structure as FieldMask

options

Optional

Object

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback

Optional

function(nullable Error, nullable Object)

The function which will be called with the result of the API call.

The second parameter to the callback is a gax.Operation object.

Returns

Promise 

  • The promise which resolves to an array. The first element of the array is a gax.Operation object. The promise has a method named "cancel" which cancels the ongoing API call.

Example

const spanner = require('@google-cloud/spanner');

var client = new spanner.v1.InstanceAdminClient({
  // optional auth parameters.
});

var instance = {};
var fieldMask = {};
var request = {
  instance: instance,
  fieldMask: fieldMask,
};

// Handle the operation using the promise pattern.
client.updateInstance(request)
  .then(responses => {
    var operation = responses[0];
    var initialApiResponse = responses[1];

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    // The final result of the operation.
    var result = responses[0];

    // The metadata value of the completed operation.
    var metadata = responses[1];

    // The response of the api call returning the complete operation.
    var finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

var instance = {};
var fieldMask = {};
var request = {
  instance: instance,
  fieldMask: fieldMask,
};

// Handle the operation using the event emitter pattern.
client.updateInstance(request)
  .then(responses => {
    var operation = responses[0];
    var initialApiResponse = responses[1];

    // Adding a listener for the "complete" event starts polling for the
    // completion of the operation.
    operation.on('complete', (result, metadata, finalApiResponse) => {
      // doSomethingWith(result);
    });

    // Adding a listener for the "progress" event causes the callback to be
    // called on any change in metadata when the operation is polled.
    operation.on('progress', (metadata, apiResponse) => {
      // doSomethingWith(metadata)
    });

    // Adding a listener for the "error" event handles any errors found during polling.
    operation.on('error', err => {
      // throw(err);
    });
  })
  .catch(err => {
    console.error(err);
  });