Class v1.CloudShellServiceClient (2.1.2)

API for interacting with Google Cloud Shell. Each user of Cloud Shell has at least one environment, which has the ID "default". Environment consists of a Docker image defining what is installed on the environment and a home directory containing the user's data that will remain across sessions. Clients use this API to start and fetch information about their environment, which can then be used to connect to that environment via a separate SSH client. v1

Package

@google-cloud/shell

Constructors

(constructor)(opts, gaxInstance)

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

Construct an instance of CloudShellServiceClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof gax.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 CloudShellServiceClient({fallback: 'rest'}, gax); ```

Properties

apiEndpoint

static get apiEndpoint(): string;

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

auth

auth: gax.GoogleAuth;

cloudShellServiceStub

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

descriptors

descriptors: Descriptors;

innerApiCalls

innerApiCalls: {
        [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.

warn

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

Methods

addPublicKey(request, options)

addPublicKey(request?: protos.google.cloud.shell.v1.IAddPublicKeyRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.cloud.shell.v1.IAddPublicKeyResponse, protos.google.cloud.shell.v1.IAddPublicKeyMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Adds a public SSH key to an environment, allowing clients with the corresponding private key to connect to that environment via SSH. If a key with the same content already exists, this will error with ALREADY_EXISTS.

Parameters
NameDescription
request protos.google.cloud.shell.v1.IAddPublicKeyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.cloud.shell.v1.IAddPublicKeyResponse, protos.google.cloud.shell.v1.IAddPublicKeyMetadata>, 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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) 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.
   */
  /**
   *  Environment this key should be added to, e.g.
   *  `users/me/environments/default`.
   */
  // const environment = 'abc123'
  /**
   *  Key that should be added to the environment. Supported formats are
   *  `ssh-dss` (see RFC4253), `ssh-rsa` (see RFC4253), `ecdsa-sha2-nistp256`
   *  (see RFC5656), `ecdsa-sha2-nistp384` (see RFC5656) and
   *  `ecdsa-sha2-nistp521` (see RFC5656). It should be structured as
   *  <format> <content>, where <content> part is encoded with
   *  Base64.
   */
  // const key = 'abc123'

  // Imports the Shell library
  const {CloudShellServiceClient} = require('@google-cloud/shell').v1;

  // Instantiates a client
  const shellClient = new CloudShellServiceClient();

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

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

  callAddPublicKey();

addPublicKey(request, options, callback)

addPublicKey(request: protos.google.cloud.shell.v1.IAddPublicKeyRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.shell.v1.IAddPublicKeyResponse, protos.google.cloud.shell.v1.IAddPublicKeyMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.shell.v1.IAddPublicKeyRequest
options CallOptions
callback Callback<LROperation<protos.google.cloud.shell.v1.IAddPublicKeyResponse, protos.google.cloud.shell.v1.IAddPublicKeyMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

addPublicKey(request, callback)

addPublicKey(request: protos.google.cloud.shell.v1.IAddPublicKeyRequest, callback: Callback<LROperation<protos.google.cloud.shell.v1.IAddPublicKeyResponse, protos.google.cloud.shell.v1.IAddPublicKeyMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.shell.v1.IAddPublicKeyRequest
callback Callback<LROperation<protos.google.cloud.shell.v1.IAddPublicKeyResponse, protos.google.cloud.shell.v1.IAddPublicKeyMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

authorizeEnvironment(request, options)

authorizeEnvironment(request?: protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Sends OAuth credentials to a running environment on behalf of a user. When this completes, the environment will be authorized to run various Google Cloud command line tools without requiring the user to manually authenticate.

Parameters
NameDescription
request protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata>, 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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) 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 that should receive the credentials, for example
   *  `users/me/environments/default` or
   *  `users/someone@example.com/environments/default`.
   */
  // const name = 'abc123'
  /**
   *  The OAuth access token that should be sent to the environment.
   */
  // const accessToken = 'abc123'
  /**
   *  The OAuth ID token that should be sent to the environment.
   */
  // const idToken = 'abc123'
  /**
   *  The time when the credentials expire. If not set, defaults to one hour from
   *  when the server received the request.
   */
  // const expireTime = {}

  // Imports the Shell library
  const {CloudShellServiceClient} = require('@google-cloud/shell').v1;

  // Instantiates a client
  const shellClient = new CloudShellServiceClient();

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

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

  callAuthorizeEnvironment();

authorizeEnvironment(request, options, callback)

authorizeEnvironment(request: protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest
options CallOptions
callback Callback<LROperation<protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

authorizeEnvironment(request, callback)

authorizeEnvironment(request: protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest, callback: Callback<LROperation<protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.shell.v1.IAuthorizeEnvironmentRequest
callback Callback<LROperation<protos.google.cloud.shell.v1.IAuthorizeEnvironmentResponse, protos.google.cloud.shell.v1.IAuthorizeEnvironmentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

cancelOperation(request, options, callback)

cancelOperation(request: protos.google.longrunning.CancelOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>, callback?: Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>): Promise<protos.google.protobuf.Empty>;

Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an value with a of 1, corresponding to Code.CANCELLED.

Parameters
NameDescription
request protos.google.longrunning.CancelOperationRequest

The request object that will be sent.

options gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.CancelOperationRequest, {} | undefined | null>

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

callback Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>

The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Returns
TypeDescription
Promise<protos.google.protobuf.Empty>
Example

const client = longrunning.operationsClient();
await client.cancelOperation({name: ''});

checkAddPublicKeyProgress(name)

checkAddPublicKeyProgress(name: string): Promise<LROperation<protos.google.cloud.shell.v1.AddPublicKeyResponse, protos.google.cloud.shell.v1.AddPublicKeyMetadata>>;

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

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.cloud.shell.v1.AddPublicKeyResponse, protos.google.cloud.shell.v1.AddPublicKeyMetadata>>

{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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) 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.
   */
  /**
   *  Environment this key should be added to, e.g.
   *  `users/me/environments/default`.
   */
  // const environment = 'abc123'
  /**
   *  Key that should be added to the environment. Supported formats are
   *  `ssh-dss` (see RFC4253), `ssh-rsa` (see RFC4253), `ecdsa-sha2-nistp256`
   *  (see RFC5656), `ecdsa-sha2-nistp384` (see RFC5656) and
   *  `ecdsa-sha2-nistp521` (see RFC5656). It should be structured as
   *  <format> <content>, where <content> part is encoded with
   *  Base64.
   */
  // const key = 'abc123'

  // Imports the Shell library
  const {CloudShellServiceClient} = require('@google-cloud/shell').v1;

  // Instantiates a client
  const shellClient = new CloudShellServiceClient();

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

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

  callAddPublicKey();

checkAuthorizeEnvironmentProgress(name)

checkAuthorizeEnvironmentProgress(name: string): Promise<LROperation<protos.google.cloud.shell.v1.AuthorizeEnvironmentResponse, protos.google.cloud.shell.v1.AuthorizeEnvironmentMetadata>>;

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

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.cloud.shell.v1.AuthorizeEnvironmentResponse, protos.google.cloud.shell.v1.AuthorizeEnvironmentMetadata>>

{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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) 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 that should receive the credentials, for example
   *  `users/me/environments/default` or
   *  `users/someone@example.com/environments/default`.
   */
  // const name = 'abc123'
  /**
   *  The OAuth access token that should be sent to the environment.
   */
  // const accessToken = 'abc123'
  /**
   *  The OAuth ID token that should be sent to the environment.
   */
  // const idToken = 'abc123'
  /**
   *  The time when the credentials expire. If not set, defaults to one hour from
   *  when the server received the request.
   */
  // const expireTime = {}

  // Imports the Shell library
  const {CloudShellServiceClient} = require('@google-cloud/shell').v1;

  // Instantiates a client
  const shellClient = new CloudShellServiceClient();

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

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

  callAuthorizeEnvironment();

checkRemovePublicKeyProgress(name)

checkRemovePublicKeyProgress(name: string): Promise<LROperation<protos.google.cloud.shell.v1.RemovePublicKeyResponse, protos.google.cloud.shell.v1.RemovePublicKeyMetadata>>;

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

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.cloud.shell.v1.RemovePublicKeyResponse, protos.google.cloud.shell.v1.RemovePublicKeyMetadata>>

{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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) 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.
   */
  /**
   *  Environment this key should be removed from, e.g.
   *  `users/me/environments/default`.
   */
  // const environment = 'abc123'
  /**
   *  Key that should be removed from the environment.
   */
  // const key = 'abc123'

  // Imports the Shell library
  const {CloudShellServiceClient} = require('@google-cloud/shell').v1;

  // Instantiates a client
  const shellClient = new CloudShellServiceClient();

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

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

  callRemovePublicKey();

checkStartEnvironmentProgress(name)

checkStartEnvironmentProgress(name: string): Promise<LROperation<protos.google.cloud.shell.v1.StartEnvironmentResponse, protos.google.cloud.shell.v1.StartEnvironmentMetadata>>;

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

Parameter
NameDescription
name string

The operation name that will be passed.

Returns
TypeDescription
Promise<LROperation<protos.google.cloud.shell.v1.StartEnvironmentResponse, protos.google.cloud.shell.v1.StartEnvironmentMetadata>>

{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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) 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 that should be started, for example
   *  `users/me/environments/default` or
   *  `users/someone@example.com/environments/default`.
   */
  // const name = 'abc123'
  /**
   *  The initial access token passed to the environment. If this is present and
   *  valid, the environment will be pre-authenticated with gcloud so that the
   *  user can run gcloud commands in Cloud Shell without having to log in. This
   *  code can be updated later by calling AuthorizeEnvironment.
   */
  // const accessToken = 'abc123'
  /**
   *  Public keys that should be added to the environment before it is started.
   */
  // const publicKeys = 'abc123'

  // Imports the Shell library
  const {CloudShellServiceClient} = require('@google-cloud/shell').v1;

  // Instantiates a client
  const shellClient = new CloudShellServiceClient();

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

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

  callStartEnvironment();

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.

deleteOperation(request, options, callback)

deleteOperation(request: protos.google.longrunning.DeleteOperationRequest, options?: gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>): Promise<protos.google.protobuf.Empty>;

Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED.

Parameters
NameDescription
request protos.google.longrunning.DeleteOperationRequest

The request object that will be sent.

options gax.CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>

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

callback Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>

The function which will be called with the result of the API call. {Promise} - The promise which resolves when API call finishes. The promise has a method named "cancel" which cancels the ongoing API call.

Returns
TypeDescription
Promise<protos.google.protobuf.Empty>
Example

const client = longrunning.operationsClient();
await client.deleteOperation({name: ''});

environmentPath(user, environment)

environmentPath(user: string, environment: string): string;

Return a fully-qualified environment resource name string.

Parameters
NameDescription
user string
environment string
Returns
TypeDescription
string

{string} Resource name string.

getEnvironment(request, options)

getEnvironment(request?: protos.google.cloud.shell.v1.IGetEnvironmentRequest, options?: CallOptions): Promise<[
        protos.google.cloud.shell.v1.IEnvironment,
        protos.google.cloud.shell.v1.IGetEnvironmentRequest | undefined,
        {} | undefined
    ]>;

Gets an environment. Returns NOT_FOUND if the environment does not exist.

Parameters
NameDescription
request protos.google.cloud.shell.v1.IGetEnvironmentRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.cloud.shell.v1.IEnvironment, protos.google.cloud.shell.v1.IGetEnvironmentRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing . Please see the [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) 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.
   */
  /**
   *  Required. Name of the requested resource, for example `users/me/environments/default`
   *  or `users/someone@example.com/environments/default`.
   */
  // const name = 'abc123'

  // Imports the Shell library
  const {CloudShellServiceClient} = require('@google-cloud/shell').v1;

  // Instantiates a client
  const shellClient = new CloudShellServiceClient();

  async function callGetEnvironment() {
    // Construct request
    const request = {
      name,
    };

    // Run request
    const response = await shellClient.getEnvironment(request);
    console.log(response);
  }

  callGetEnvironment();

getEnvironment(request, options, callback)

getEnvironment(request: protos.google.cloud.shell.v1.IGetEnvironmentRequest, options: CallOptions, callback: Callback<protos.google.cloud.shell.v1.IEnvironment, protos.google.cloud.shell.v1.IGetEnvironmentRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.shell.v1.IGetEnvironmentRequest
options CallOptions
callback Callback<protos.google.cloud.shell.v1.IEnvironment, protos.google.cloud.shell.v1.IGetEnvironmentRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getEnvironment(request, callback)

getEnvironment(request: protos.google.cloud.shell.v1.IGetEnvironmentRequest, callback: Callback<protos.google.cloud.shell.v1.IEnvironment, protos.google.cloud.shell.v1.IGetEnvironmentRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.shell.v1.IGetEnvironmentRequest
callback Callback<protos.google.cloud.shell.v1.IEnvironment, protos.google.cloud.shell.v1.IGetEnvironmentRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

getOperation(request, options, callback)

getOperation(request: protos.google.longrunning.GetOperationRequest, options?: gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>, callback?: Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>): Promise<[protos.google.longrunning.Operation]>;

Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.

Parameters
NameDescription
request protos.google.longrunning.GetOperationRequest

The request object that will be sent.

options gax.CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>

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

callback Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>

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

The second parameter to the callback is an object representing . {Promise} - The promise which resolves to an array. The first element of the array is an object representing . The promise has a method named "cancel" which cancels the ongoing API call.

Returns
TypeDescription
Promise<[protos.google.longrunning.Operation]>
Example

const client = longrunning.operationsClient();
const name = '';
const [response] = await client.getOperation({name});
// doThingsWith(response)

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.

listOperationsAsync(request, options)

listOperationsAsync(request: protos.google.longrunning.ListOperationsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.longrunning.ListOperationsResponse>;

Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED. Returns an iterable object.

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

Parameters
NameDescription
request protos.google.longrunning.ListOperationsRequest

The request object that will be sent.

options gax.CallOptions

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

Returns
TypeDescription
AsyncIterable<protos.google.longrunning.ListOperationsResponse>

{Object} An iterable Object that conforms to iteration protocols.

Example

const client = longrunning.operationsClient();
for await (const response of client.listOperationsAsync(request));
// doThingsWith(response)

matchEnvironmentFromEnvironmentName(environmentName)

matchEnvironmentFromEnvironmentName(environmentName: string): string | number;

Parse the environment from Environment resource.

Parameter
NameDescription
environmentName string

A fully-qualified path representing Environment resource.

Returns
TypeDescription
string | number

{string} A string representing the environment.

matchUserFromEnvironmentName(environmentName)

matchUserFromEnvironmentName(environmentName: string): string | number;

Parse the user from Environment resource.

Parameter
NameDescription
environmentName string

A fully-qualified path representing Environment resource.

Returns
TypeDescription
string | number

{string} A string representing the user.

removePublicKey(request, options)

removePublicKey(request?: protos.google.cloud.shell.v1.IRemovePublicKeyRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.cloud.shell.v1.IRemovePublicKeyResponse, protos.google.cloud.shell.v1.IRemovePublicKeyMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Removes a public SSH key from an environment. Clients will no longer be able to connect to the environment using the corresponding private key. If a key with the same content is not present, this will error with NOT_FOUND.

Parameters
NameDescription
request protos.google.cloud.shell.v1.IRemovePublicKeyRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.cloud.shell.v1.IRemovePublicKeyResponse, protos.google.cloud.shell.v1.IRemovePublicKeyMetadata>, 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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) 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.
   */
  /**
   *  Environment this key should be removed from, e.g.
   *  `users/me/environments/default`.
   */
  // const environment = 'abc123'
  /**
   *  Key that should be removed from the environment.
   */
  // const key = 'abc123'

  // Imports the Shell library
  const {CloudShellServiceClient} = require('@google-cloud/shell').v1;

  // Instantiates a client
  const shellClient = new CloudShellServiceClient();

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

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

  callRemovePublicKey();

removePublicKey(request, options, callback)

removePublicKey(request: protos.google.cloud.shell.v1.IRemovePublicKeyRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.shell.v1.IRemovePublicKeyResponse, protos.google.cloud.shell.v1.IRemovePublicKeyMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.shell.v1.IRemovePublicKeyRequest
options CallOptions
callback Callback<LROperation<protos.google.cloud.shell.v1.IRemovePublicKeyResponse, protos.google.cloud.shell.v1.IRemovePublicKeyMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

removePublicKey(request, callback)

removePublicKey(request: protos.google.cloud.shell.v1.IRemovePublicKeyRequest, callback: Callback<LROperation<protos.google.cloud.shell.v1.IRemovePublicKeyResponse, protos.google.cloud.shell.v1.IRemovePublicKeyMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.shell.v1.IRemovePublicKeyRequest
callback Callback<LROperation<protos.google.cloud.shell.v1.IRemovePublicKeyResponse, protos.google.cloud.shell.v1.IRemovePublicKeyMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

startEnvironment(request, options)

startEnvironment(request?: protos.google.cloud.shell.v1.IStartEnvironmentRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.cloud.shell.v1.IStartEnvironmentResponse, protos.google.cloud.shell.v1.IStartEnvironmentMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Starts an existing environment, allowing clients to connect to it. The returned operation will contain an instance of StartEnvironmentMetadata in its metadata field. Users can wait for the environment to start by polling this operation via GetOperation. Once the environment has finished starting and is ready to accept connections, the operation will contain a StartEnvironmentResponse in its response field.

Parameters
NameDescription
request protos.google.cloud.shell.v1.IStartEnvironmentRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ LROperation<protos.google.cloud.shell.v1.IStartEnvironmentResponse, protos.google.cloud.shell.v1.IStartEnvironmentMetadata>, 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](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) 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 that should be started, for example
   *  `users/me/environments/default` or
   *  `users/someone@example.com/environments/default`.
   */
  // const name = 'abc123'
  /**
   *  The initial access token passed to the environment. If this is present and
   *  valid, the environment will be pre-authenticated with gcloud so that the
   *  user can run gcloud commands in Cloud Shell without having to log in. This
   *  code can be updated later by calling AuthorizeEnvironment.
   */
  // const accessToken = 'abc123'
  /**
   *  Public keys that should be added to the environment before it is started.
   */
  // const publicKeys = 'abc123'

  // Imports the Shell library
  const {CloudShellServiceClient} = require('@google-cloud/shell').v1;

  // Instantiates a client
  const shellClient = new CloudShellServiceClient();

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

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

  callStartEnvironment();

startEnvironment(request, options, callback)

startEnvironment(request: protos.google.cloud.shell.v1.IStartEnvironmentRequest, options: CallOptions, callback: Callback<LROperation<protos.google.cloud.shell.v1.IStartEnvironmentResponse, protos.google.cloud.shell.v1.IStartEnvironmentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.shell.v1.IStartEnvironmentRequest
options CallOptions
callback Callback<LROperation<protos.google.cloud.shell.v1.IStartEnvironmentResponse, protos.google.cloud.shell.v1.IStartEnvironmentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

startEnvironment(request, callback)

startEnvironment(request: protos.google.cloud.shell.v1.IStartEnvironmentRequest, callback: Callback<LROperation<protos.google.cloud.shell.v1.IStartEnvironmentResponse, protos.google.cloud.shell.v1.IStartEnvironmentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.cloud.shell.v1.IStartEnvironmentRequest
callback Callback<LROperation<protos.google.cloud.shell.v1.IStartEnvironmentResponse, protos.google.cloud.shell.v1.IStartEnvironmentMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
TypeDescription
void