InstanceAdminClient

v1~ 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.

promise function <optional>

Custom promise module to use instead of native Promises.

apiEndpoint string <optional>

The domain name of the API remote host.

Source:

Members

(static) apiEndpoint

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

Source:

(static) port

The port for this API service.

Source:

(static) scopes

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

Source:

(static) servicePath

The DNS address for this API service.

Source:

Methods

createInstance(request, optionsopt, callbackopt) → {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]*[a-z0-9] and must be between 2 and 64 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 Object <optional>

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

callback function <optional>

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

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

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

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

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

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

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

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

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

    // 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);
  });

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

// Handle the operation using the await pattern.
const [operation] = await client.createInstance(request);

const [response] = await operation.promise();

deleteInstance(request, optionsopt, callbackopt) → {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>

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

callback function <optional>

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

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

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

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

getIamPolicy(request, optionsopt, callbackopt) → {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 Attributes 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 Object <optional>

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

This object should have the same structure as GetPolicyOptions

options Object <optional>

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

callback function <optional>

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

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

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

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

const resource = '';
client.getIamPolicy({resource: resource})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getInstance(request, optionsopt, callbackopt) → {Promise}

Gets information about a particular instance.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

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

fieldMask Object <optional>

If field_mask is present, specifies the subset of [][google.spanner.admin.instance.v1.Instance] fields that should be returned. If absent, all [][google.spanner.admin.instance.v1.Instance] fields are returned.

This object should have the same structure as FieldMask

options Object <optional>

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

callback function <optional>

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

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

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

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

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

getInstanceConfig(request, optionsopt, callbackopt) → {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>

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

callback function <optional>

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

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

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

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

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

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.

Source:

instanceConfigPath(project, instanceConfig) → {String}

Return a fully-qualified instance_config resource name string.

Parameters:
Name Type Description
project String
instanceConfig String
Source:

instancePath(project, instance) → {String}

Return a fully-qualified instance resource name string.

Parameters:
Name Type Description
project String
instance String
Source:

listInstanceConfigs(request, optionsopt, callbackopt) → {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 Attributes 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 <optional>

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 Object <optional>

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

callback function <optional>

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.

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

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

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

client.listInstanceConfigs({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

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


const options = {autoPaginate: false};
const callback = responses => {
  // The actual resources in a response.
  const resources = responses[0];
  // The next request if the response shows that there are more responses.
  const nextRequest = responses[1];
  // The actual response object, if necessary.
  // const rawResponse = responses[2];
  for (const resource of resources) {
    // doThingsWith(resource);
  }
  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(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 Attributes 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 <optional>

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 Object <optional>

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

Source:
See:
Example
const spanner = require('@google-cloud/spanner');

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

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

listInstances(request, optionsopt, callbackopt) → {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 Attributes 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 <optional>

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 string <optional>

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>

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

callback function <optional>

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.

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

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

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

client.listInstances({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

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


const options = {autoPaginate: false};
const callback = responses => {
  // The actual resources in a response.
  const resources = responses[0];
  // The next request if the response shows that there are more responses.
  const nextRequest = responses[1];
  // The actual response object, if necessary.
  // const rawResponse = responses[2];
  for (const resource of resources) {
    // doThingsWith(resource);
  }
  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(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 Attributes 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 <optional>

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 string <optional>

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>

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

Source:
See:
Example
const spanner = require('@google-cloud/spanner');

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

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

matchInstanceConfigFromInstanceConfigName(instanceConfigName) → {String}

Parse the instanceConfigName from a instance_config resource.

Parameters:
Name Type Description
instanceConfigName String

A fully-qualified path representing a instance_config resources.

Source:

matchInstanceFromInstanceName(instanceName) → {String}

Parse the instanceName from a instance resource.

Parameters:
Name Type Description
instanceName String

A fully-qualified path representing a instance resources.

Source:

matchProjectFromInstanceConfigName(instanceConfigName) → {String}

Parse the instanceConfigName from a instance_config resource.

Parameters:
Name Type Description
instanceConfigName String

A fully-qualified path representing a instance_config resources.

Source:

matchProjectFromInstanceName(instanceName) → {String}

Parse the instanceName from a instance resource.

Parameters:
Name Type Description
instanceName String

A fully-qualified path representing a instance resources.

Source:

matchProjectFromProjectName(projectName) → {String}

Parse the projectName from a project resource.

Parameters:
Name Type Description
projectName String

A fully-qualified path representing a project resources.

Source:

projectPath(project) → {String}

Return a fully-qualified project resource name string.

Parameters:
Name Type Description
project String
Source:

setIamPolicy(request, optionsopt, callbackopt) → {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 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 Object <optional>

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

callback function <optional>

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

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

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

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

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

testIamPermissions(request, optionsopt, callbackopt) → {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>

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

callback function <optional>

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

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

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

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

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

updateInstance(request, optionsopt, callbackopt) → {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.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

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

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

callback function <optional>

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

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

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

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

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

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

    // Operation#promise starts polling for the completion of the LRO.
    return operation.promise();
  })
  .then(responses => {
    const result = responses[0];
    const metadata = responses[1];
    const finalApiResponse = responses[2];
  })
  .catch(err => {
    console.error(err);
  });

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

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

    // 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);
  });

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

// Handle the operation using the await pattern.
const [operation] = await client.updateInstance(request);

const [response] = await operation.promise();