Class v1.InstancesClient (3.2.0)

Manages instances of a version. v1

Package

@google-cloud/appengine-admin

Constructors

(constructor)(opts, gaxInstance)

constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);

Construct an instance of InstancesClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof fallback

: loaded instance of google-gax. Useful if you need to avoid loading the default gRPC version and want to use the fallback HTTP implementation. Load only fallback version and pass it to the constructor: ``` const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC const client = new InstancesClient({fallback: true}, gax); ```

Properties

apiEndpoint

get apiEndpoint(): string;

The DNS address for this API service.

apiEndpoint

static get apiEndpoint(): string;

The DNS address for this API service - same as servicePath.

auth

auth: gax.GoogleAuth;

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [name: string]: Function;
    };

instancesStub

instancesStub?: Promise<{
        [name: string]: Function;
    }>;

operationsClient

operationsClient: gax.OperationsClient;

pathTemplates

pathTemplates: {
        [name: string]: gax.PathTemplate;
    };

port

static get port(): number;

The port for this API service.

scopes

static get scopes(): string[];

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

servicePath

static get servicePath(): string;

The DNS address for this API service.

universeDomain

get universeDomain(): string;

warn

warn: (code: string, message: string, warnType?: string) => void;

Methods

checkDebugInstanceProgress(name)

checkDebugInstanceProgress(name: string): Promise<LROperation<protos.google.appengine.v1.Instance, protos.google.appengine.v1.OperationMetadataV1>>;

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

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.appengine.v1.Instance, protos.google.appengine.v1.OperationMetadataV1>>

{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Name of the resource requested. Example:
   *  `apps/myapp/services/default/versions/v1/instances/instance-1`.
   */
  // const name = 'abc123'
  /**
   *  Public SSH key to add to the instance. Examples:
   *  * `[USERNAME]:ssh-rsa [KEY_VALUE] [USERNAME]`
   *  * `[USERNAME]:ssh-rsa [KEY_VALUE] google-ssh {"userName":"[USERNAME]","expireOn":"[EXPIRE_TIME]"}`
   *  For more information, see
   *  Adding and Removing SSH Keys (https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys).
   */
  // const sshKey = 'abc123'

  // Imports the Appengine library
  const {InstancesClient} = require('@google-cloud/appengine-admin').v1;

  // Instantiates a client
  const appengineClient = new InstancesClient();

  async function callDebugInstance() {
    // Construct request
    const request = {
    };

    // Run request
    const [operation] = await appengineClient.debugInstance(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDebugInstance();

checkDeleteInstanceProgress(name)

checkDeleteInstanceProgress(name: string): Promise<LROperation<protos.google.protobuf.Empty, protos.google.appengine.v1.OperationMetadataV1>>;

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

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.protobuf.Empty, protos.google.appengine.v1.OperationMetadataV1>>

{Promise} - The promise which resolves to an object. The decoded operation object has result and metadata field to get information from. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Name of the resource requested. Example:
   *  `apps/myapp/services/default/versions/v1/instances/instance-1`.
   */
  // const name = 'abc123'

  // Imports the Appengine library
  const {InstancesClient} = require('@google-cloud/appengine-admin').v1;

  // Instantiates a client
  const appengineClient = new InstancesClient();

  async function callDeleteInstance() {
    // Construct request
    const request = {
    };

    // Run request
    const [operation] = await appengineClient.deleteInstance(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteInstance();

close()

close(): Promise<void>;

Terminate the gRPC channel and close the client.

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

Returns
TypeDescription
Promise<void>

{Promise} A promise that resolves when the client is closed.

debugInstance(request, options)

debugInstance(request?: protos.google.appengine.v1.IDebugInstanceRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.appengine.v1.IInstance, protos.google.appengine.v1.IOperationMetadataV1>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Enables debugging on a VM instance. This allows you to use the SSH command to connect to the virtual machine where the instance lives. While in "debug mode", the instance continues to serve live traffic. You should delete the instance when you are done debugging and then allow the system to take over and determine if another instance should be started.

Only applicable for instances in App Engine flexible environment.

Parameters
NameDescription
request IDebugInstanceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.appengine.v1.IInstance, protos.google.appengine.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Name of the resource requested. Example:
   *  `apps/myapp/services/default/versions/v1/instances/instance-1`.
   */
  // const name = 'abc123'
  /**
   *  Public SSH key to add to the instance. Examples:
   *  * `[USERNAME]:ssh-rsa [KEY_VALUE] [USERNAME]`
   *  * `[USERNAME]:ssh-rsa [KEY_VALUE] google-ssh {"userName":"[USERNAME]","expireOn":"[EXPIRE_TIME]"}`
   *  For more information, see
   *  Adding and Removing SSH Keys (https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys).
   */
  // const sshKey = 'abc123'

  // Imports the Appengine library
  const {InstancesClient} = require('@google-cloud/appengine-admin').v1;

  // Instantiates a client
  const appengineClient = new InstancesClient();

  async function callDebugInstance() {
    // Construct request
    const request = {
    };

    // Run request
    const [operation] = await appengineClient.debugInstance(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDebugInstance();

debugInstance(request, options, callback)

debugInstance(request: protos.google.appengine.v1.IDebugInstanceRequest, options: CallOptions, callback: Callback<LROperation<protos.google.appengine.v1.IInstance, protos.google.appengine.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDebugInstanceRequest
options CallOptions
callback Callback<LROperation<protos.google.appengine.v1.IInstance, protos.google.appengine.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

debugInstance(request, callback)

debugInstance(request: protos.google.appengine.v1.IDebugInstanceRequest, callback: Callback<LROperation<protos.google.appengine.v1.IInstance, protos.google.appengine.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDebugInstanceRequest
callback Callback<LROperation<protos.google.appengine.v1.IInstance, protos.google.appengine.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteInstance(request, options)

deleteInstance(request?: protos.google.appengine.v1.IDeleteInstanceRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.protobuf.IEmpty, protos.google.appengine.v1.IOperationMetadataV1>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Stops a running instance.

The instance might be automatically recreated based on the scaling settings of the version. For more information, see "How Instances are Managed" ([standard environment](https://cloud.google.com/appengine/docs/standard/python/how-instances-are-managed) | [flexible environment](https://cloud.google.com/appengine/docs/flexible/python/how-instances-are-managed)).

To ensure that instances are not re-created and avoid getting billed, you can stop all instances within the target version by changing the serving status of the version to STOPPED with the [apps.services.versions.patch](https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch) method.

Parameters
NameDescription
request IDeleteInstanceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.protobuf.IEmpty, protos.google.appengine.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing a long running operation. Its promise() method returns a promise you can await for. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Name of the resource requested. Example:
   *  `apps/myapp/services/default/versions/v1/instances/instance-1`.
   */
  // const name = 'abc123'

  // Imports the Appengine library
  const {InstancesClient} = require('@google-cloud/appengine-admin').v1;

  // Instantiates a client
  const appengineClient = new InstancesClient();

  async function callDeleteInstance() {
    // Construct request
    const request = {
    };

    // Run request
    const [operation] = await appengineClient.deleteInstance(request);
    const [response] = await operation.promise();
    console.log(response);
  }

  callDeleteInstance();

deleteInstance(request, options, callback)

deleteInstance(request: protos.google.appengine.v1.IDeleteInstanceRequest, options: CallOptions, callback: Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.appengine.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteInstanceRequest
options CallOptions
callback Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.appengine.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

deleteInstance(request, callback)

deleteInstance(request: protos.google.appengine.v1.IDeleteInstanceRequest, callback: Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.appengine.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IDeleteInstanceRequest
callback Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.appengine.v1.IOperationMetadataV1>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getInstance(request, options)

getInstance(request?: protos.google.appengine.v1.IGetInstanceRequest, options?: CallOptions): Promise<[
        protos.google.appengine.v1.IInstance,
        protos.google.appengine.v1.IGetInstanceRequest | undefined,
        {} | undefined
    ]>;

Gets instance information.

Parameters
NameDescription
request IGetInstanceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.appengine.v1.IInstance, protos.google.appengine.v1.IGetInstanceRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Name of the resource requested. Example:
   *  `apps/myapp/services/default/versions/v1/instances/instance-1`.
   */
  // const name = 'abc123'

  // Imports the Appengine library
  const {InstancesClient} = require('@google-cloud/appengine-admin').v1;

  // Instantiates a client
  const appengineClient = new InstancesClient();

  async function callGetInstance() {
    // Construct request
    const request = {
    };

    // Run request
    const response = await appengineClient.getInstance(request);
    console.log(response);
  }

  callGetInstance();

getInstance(request, options, callback)

getInstance(request: protos.google.appengine.v1.IGetInstanceRequest, options: CallOptions, callback: Callback<protos.google.appengine.v1.IInstance, protos.google.appengine.v1.IGetInstanceRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetInstanceRequest
options CallOptions
callback Callback<protos.google.appengine.v1.IInstance, protos.google.appengine.v1.IGetInstanceRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getInstance(request, callback)

getInstance(request: protos.google.appengine.v1.IGetInstanceRequest, callback: Callback<protos.google.appengine.v1.IInstance, protos.google.appengine.v1.IGetInstanceRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IGetInstanceRequest
callback Callback<protos.google.appengine.v1.IInstance, protos.google.appengine.v1.IGetInstanceRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getProjectId()

getProjectId(): Promise<string>;
Returns
TypeDescription
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
NameDescription
callback Callback<string, undefined, undefined>
Returns
TypeDescription
void

initialize()

initialize(): Promise<{
        [name: string]: Function;
    }>;

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.

Returns
TypeDescription
Promise<{ [name: string]: Function; }>

{Promise} A promise that resolves to an authenticated service stub.

instancePath(app, service, version, instance)

instancePath(app: string, service: string, version: string, instance: string): string;

Return a fully-qualified instance resource name string.

Parameters
NameDescription
app string
service string
version string
instance string
Returns
TypeDescription
string

{string} Resource name string.

listInstances(request, options)

listInstances(request?: protos.google.appengine.v1.IListInstancesRequest, options?: CallOptions): Promise<[
        protos.google.appengine.v1.IInstance[],
        protos.google.appengine.v1.IListInstancesRequest | null,
        protos.google.appengine.v1.IListInstancesResponse
    ]>;

Lists the instances of a version.

Tip: To aggregate details about instances over time, see the [Stackdriver Monitoring API](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list).

Parameters
NameDescription
request IListInstancesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.appengine.v1.IInstance[], protos.google.appengine.v1.IListInstancesRequest | null, protos.google.appengine.v1.IListInstancesResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of . The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using listInstancesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listInstances(request, options, callback)

listInstances(request: protos.google.appengine.v1.IListInstancesRequest, options: CallOptions, callback: PaginationCallback<protos.google.appengine.v1.IListInstancesRequest, protos.google.appengine.v1.IListInstancesResponse | null | undefined, protos.google.appengine.v1.IInstance>): void;
Parameters
NameDescription
request IListInstancesRequest
options CallOptions
callback PaginationCallback<protos.google.appengine.v1.IListInstancesRequest, protos.google.appengine.v1.IListInstancesResponse | null | undefined, protos.google.appengine.v1.IInstance>
Returns
TypeDescription
void

listInstances(request, callback)

listInstances(request: protos.google.appengine.v1.IListInstancesRequest, callback: PaginationCallback<protos.google.appengine.v1.IListInstancesRequest, protos.google.appengine.v1.IListInstancesResponse | null | undefined, protos.google.appengine.v1.IInstance>): void;
Parameters
NameDescription
request IListInstancesRequest
callback PaginationCallback<protos.google.appengine.v1.IListInstancesRequest, protos.google.appengine.v1.IListInstancesResponse | null | undefined, protos.google.appengine.v1.IInstance>
Returns
TypeDescription
void

listInstancesAsync(request, options)

listInstancesAsync(request?: protos.google.appengine.v1.IListInstancesRequest, options?: CallOptions): AsyncIterable<protos.google.appengine.v1.IInstance>;

Equivalent to listInstances, but returns an iterable object.

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

Parameters
NameDescription
request IListInstancesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
AsyncIterable<protos.google.appengine.v1.IInstance>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing . The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples.

Example

  /**
   * This snippet has been automatically generated and should be regarded as a code template only.
   * It will require modifications to work.
   * It may require correct/in-range values for request initialization.
   * TODO(developer): Uncomment these variables before running the sample.
   */
  /**
   *  Name of the parent Version resource. Example:
   *  `apps/myapp/services/default/versions/v1`.
   */
  // const parent = 'abc123'
  /**
   *  Maximum results to return per page.
   */
  // const pageSize = 1234
  /**
   *  Continuation token for fetching the next page of results.
   */
  // const pageToken = 'abc123'

  // Imports the Appengine library
  const {InstancesClient} = require('@google-cloud/appengine-admin').v1;

  // Instantiates a client
  const appengineClient = new InstancesClient();

  async function callListInstances() {
    // Construct request
    const request = {
    };

    // Run request
    const iterable = appengineClient.listInstancesAsync(request);
    for await (const response of iterable) {
        console.log(response);
    }
  }

  callListInstances();

listInstancesStream(request, options)

listInstancesStream(request?: protos.google.appengine.v1.IListInstancesRequest, options?: CallOptions): Transform;

Equivalent to method.name.toCamelCase(), but returns a NodeJS Stream object.

Parameters
NameDescription
request IListInstancesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Transform

{Stream} An object stream which emits an object representing on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using listInstancesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

matchAppFromInstanceName(instanceName)

matchAppFromInstanceName(instanceName: string): string | number;

Parse the app from Instance resource.

Parameter
NameDescription
instanceName string

A fully-qualified path representing Instance resource.

Returns
TypeDescription
string | number

{string} A string representing the app.

matchInstanceFromInstanceName(instanceName)

matchInstanceFromInstanceName(instanceName: string): string | number;

Parse the instance from Instance resource.

Parameter
NameDescription
instanceName string

A fully-qualified path representing Instance resource.

Returns
TypeDescription
string | number

{string} A string representing the instance.

matchServiceFromInstanceName(instanceName)

matchServiceFromInstanceName(instanceName: string): string | number;

Parse the service from Instance resource.

Parameter
NameDescription
instanceName string

A fully-qualified path representing Instance resource.

Returns
TypeDescription
string | number

{string} A string representing the service.

matchVersionFromInstanceName(instanceName)

matchVersionFromInstanceName(instanceName: string): string | number;

Parse the version from Instance resource.

Parameter
NameDescription
instanceName string

A fully-qualified path representing Instance resource.

Returns
TypeDescription
string | number

{string} A string representing the version.