Class v1.ServiceUsageClient (5.1.1)

Enables services that service consumers want to use on Google Cloud Platform, lists the available or enabled services, or disables services that service consumers no longer use.

See [Service Usage API](https://cloud.google.com/service-usage/docs/overview) v1

Package

@google-cloud/service-usage

Constructors

(constructor)(opts, gaxInstance)

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

Construct an instance of ServiceUsageClient.

Parameters
Name Description
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 ServiceUsageClient({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;
    };

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.

serviceUsageStub

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

universeDomain

get universeDomain(): string;

warn

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

Methods

batchEnableServices(request, options)

batchEnableServices(request?: protos.google.api.serviceusage.v1.IBatchEnableServicesRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Enable multiple services on a project. The operation is atomic: if enabling any service fails, then the entire batch fails, and no state changes occur. To enable a single service, use the EnableService method instead.

Parameters
Name Description
request IBatchEnableServicesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, 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.
   */
  /**
   *  Parent to enable services on.
   *  An example name would be:
   *  `projects/123` where `123` is the project number.
   *  The `BatchEnableServices` method currently only supports projects.
   */
  // const parent = 'abc123'
  /**
   *  The identifiers of the services to enable on the project.
   *  A valid identifier would be:
   *  serviceusage.googleapis.com
   *  Enabling services requires that each service is public or is shared with
   *  the user enabling the service.
   *  A single request can enable a maximum of 20 services at a time. If more
   *  than 20 services are specified, the request will fail, and no state changes
   *  will occur.
   */
  // const serviceIds = ['abc','def']

  // Imports the Serviceusage library
  const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;

  // Instantiates a client
  const serviceusageClient = new ServiceUsageClient();

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

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

  callBatchEnableServices();

batchEnableServices(request, options, callback)

batchEnableServices(request: protos.google.api.serviceusage.v1.IBatchEnableServicesRequest, options: CallOptions, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IBatchEnableServicesRequest
options CallOptions
callback Callback<LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
Type Description
void

batchEnableServices(request, callback)

batchEnableServices(request: protos.google.api.serviceusage.v1.IBatchEnableServicesRequest, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IBatchEnableServicesRequest
callback Callback<LROperation<protos.google.api.serviceusage.v1.IBatchEnableServicesResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
Type Description
void

batchGetServices(request, options)

batchGetServices(request?: protos.google.api.serviceusage.v1.IBatchGetServicesRequest, options?: CallOptions): Promise<[
        protos.google.api.serviceusage.v1.IBatchGetServicesResponse,
        protos.google.api.serviceusage.v1.IBatchGetServicesRequest | undefined,
        {} | undefined
    ]>;

Returns the service configurations and enabled states for a given list of services.

Parameters
Name Description
request IBatchGetServicesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.api.serviceusage.v1.IBatchGetServicesResponse, protos.google.api.serviceusage.v1.IBatchGetServicesRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing BatchGetServicesResponse. 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.
   */
  /**
   *  Parent to retrieve services from.
   *  If this is set, the parent of all of the services specified in `names` must
   *  match this field. An example name would be: `projects/123` where `123` is
   *  the project number. The `BatchGetServices` method currently only supports
   *  projects.
   */
  // const parent = 'abc123'
  /**
   *  Names of the services to retrieve.
   *  An example name would be:
   *  `projects/123/services/serviceusage.googleapis.com` where `123` is the
   *  project number.
   *  A single request can get a maximum of 30 services at a time.
   */
  // const names = ['abc','def']

  // Imports the Serviceusage library
  const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;

  // Instantiates a client
  const serviceusageClient = new ServiceUsageClient();

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

    // Run request
    const response = await serviceusageClient.batchGetServices(request);
    console.log(response);
  }

  callBatchGetServices();

batchGetServices(request, options, callback)

batchGetServices(request: protos.google.api.serviceusage.v1.IBatchGetServicesRequest, options: CallOptions, callback: Callback<protos.google.api.serviceusage.v1.IBatchGetServicesResponse, protos.google.api.serviceusage.v1.IBatchGetServicesRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IBatchGetServicesRequest
options CallOptions
callback Callback<protos.google.api.serviceusage.v1.IBatchGetServicesResponse, protos.google.api.serviceusage.v1.IBatchGetServicesRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

batchGetServices(request, callback)

batchGetServices(request: protos.google.api.serviceusage.v1.IBatchGetServicesRequest, callback: Callback<protos.google.api.serviceusage.v1.IBatchGetServicesResponse, protos.google.api.serviceusage.v1.IBatchGetServicesRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IBatchGetServicesRequest
callback Callback<protos.google.api.serviceusage.v1.IBatchGetServicesResponse, protos.google.api.serviceusage.v1.IBatchGetServicesRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

cancelOperation(request, optionsOrCallback, callback)

cancelOperation(request: protos.google.longrunning.CancelOperationRequest, optionsOrCallback?: gax.CallOptions | Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | 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
Name Description
request CancelOperationRequest

The request object that will be sent.

optionsOrCallback CallOptions | Callback<protos.google.longrunning.CancelOperationRequest, protos.google.protobuf.Empty, {} | undefined | null>
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
Type Description
Promise<protos.google.protobuf.Empty>
Example

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

checkBatchEnableServicesProgress(name)

checkBatchEnableServicesProgress(name: string): Promise<LROperation<protos.google.api.serviceusage.v1.BatchEnableServicesResponse, protos.google.api.serviceusage.v1.OperationMetadata>>;

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

Parameter
Name Description
name string

The operation name that will be passed.

Returns
Type Description
Promise<LROperation<protos.google.api.serviceusage.v1.BatchEnableServicesResponse, protos.google.api.serviceusage.v1.OperationMetadata>>

{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.
   */
  /**
   *  Parent to enable services on.
   *  An example name would be:
   *  `projects/123` where `123` is the project number.
   *  The `BatchEnableServices` method currently only supports projects.
   */
  // const parent = 'abc123'
  /**
   *  The identifiers of the services to enable on the project.
   *  A valid identifier would be:
   *  serviceusage.googleapis.com
   *  Enabling services requires that each service is public or is shared with
   *  the user enabling the service.
   *  A single request can enable a maximum of 20 services at a time. If more
   *  than 20 services are specified, the request will fail, and no state changes
   *  will occur.
   */
  // const serviceIds = ['abc','def']

  // Imports the Serviceusage library
  const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;

  // Instantiates a client
  const serviceusageClient = new ServiceUsageClient();

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

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

  callBatchEnableServices();

checkDisableServiceProgress(name)

checkDisableServiceProgress(name: string): Promise<LROperation<protos.google.api.serviceusage.v1.DisableServiceResponse, protos.google.api.serviceusage.v1.OperationMetadata>>;

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

Parameter
Name Description
name string

The operation name that will be passed.

Returns
Type Description
Promise<LROperation<protos.google.api.serviceusage.v1.DisableServiceResponse, protos.google.api.serviceusage.v1.OperationMetadata>>

{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 consumer and service to disable the service on.
   *  The enable and disable methods currently only support projects.
   *  An example name would be:
   *  `projects/123/services/serviceusage.googleapis.com` where `123` is the
   *  project number.
   */
  // const name = 'abc123'
  /**
   *  Indicates if services that are enabled and which depend on this service
   *  should also be disabled. If not set, an error will be generated if any
   *  enabled services depend on the service to be disabled. When set, the
   *  service, and any enabled services that depend on it, will be disabled
   *  together.
   */
  // const disableDependentServices = true
  /**
   *  Defines the behavior for checking service usage when disabling a service.
   */
  // const checkIfServiceHasUsage = {}

  // Imports the Serviceusage library
  const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;

  // Instantiates a client
  const serviceusageClient = new ServiceUsageClient();

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

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

  callDisableService();

checkEnableServiceProgress(name)

checkEnableServiceProgress(name: string): Promise<LROperation<protos.google.api.serviceusage.v1.EnableServiceResponse, protos.google.api.serviceusage.v1.OperationMetadata>>;

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

Parameter
Name Description
name string

The operation name that will be passed.

Returns
Type Description
Promise<LROperation<protos.google.api.serviceusage.v1.EnableServiceResponse, protos.google.api.serviceusage.v1.OperationMetadata>>

{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 consumer and service to enable the service on.
   *  The `EnableService` and `DisableService` methods currently only support
   *  projects.
   *  Enabling a service requires that the service is public or is shared with
   *  the user enabling the service.
   *  An example name would be:
   *  `projects/123/services/serviceusage.googleapis.com` where `123` is the
   *  project number.
   */
  // const name = 'abc123'

  // Imports the Serviceusage library
  const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;

  // Instantiates a client
  const serviceusageClient = new ServiceUsageClient();

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

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

  callEnableService();

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
Type Description
Promise<void>

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

deleteOperation(request, optionsOrCallback, callback)

deleteOperation(request: protos.google.longrunning.DeleteOperationRequest, optionsOrCallback?: 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
Name Description
request DeleteOperationRequest

The request object that will be sent.

optionsOrCallback CallOptions | Callback<protos.google.protobuf.Empty, protos.google.longrunning.DeleteOperationRequest, {} | null | undefined>
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
Type Description
Promise<protos.google.protobuf.Empty>
Example

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

disableService(request, options)

disableService(request?: protos.google.api.serviceusage.v1.IDisableServiceRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Disable a service so that it can no longer be used with a project. This prevents unintended usage that may cause unexpected billing charges or security leaks.

It is not valid to call the disable method on a service that is not currently enabled. Callers will receive a FAILED_PRECONDITION status if the target service is not currently enabled.

Parameters
Name Description
request IDisableServiceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, 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 consumer and service to disable the service on.
   *  The enable and disable methods currently only support projects.
   *  An example name would be:
   *  `projects/123/services/serviceusage.googleapis.com` where `123` is the
   *  project number.
   */
  // const name = 'abc123'
  /**
   *  Indicates if services that are enabled and which depend on this service
   *  should also be disabled. If not set, an error will be generated if any
   *  enabled services depend on the service to be disabled. When set, the
   *  service, and any enabled services that depend on it, will be disabled
   *  together.
   */
  // const disableDependentServices = true
  /**
   *  Defines the behavior for checking service usage when disabling a service.
   */
  // const checkIfServiceHasUsage = {}

  // Imports the Serviceusage library
  const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;

  // Instantiates a client
  const serviceusageClient = new ServiceUsageClient();

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

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

  callDisableService();

disableService(request, options, callback)

disableService(request: protos.google.api.serviceusage.v1.IDisableServiceRequest, options: CallOptions, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDisableServiceRequest
options CallOptions
callback Callback<LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
Type Description
void

disableService(request, callback)

disableService(request: protos.google.api.serviceusage.v1.IDisableServiceRequest, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IDisableServiceRequest
callback Callback<LROperation<protos.google.api.serviceusage.v1.IDisableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
Type Description
void

enableService(request, options)

enableService(request?: protos.google.api.serviceusage.v1.IEnableServiceRequest, options?: CallOptions): Promise<[
        LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>,
        protos.google.longrunning.IOperation | undefined,
        {} | undefined
    ]>;

Enable a service so that it can be used with a project.

Parameters
Name Description
request IEnableServiceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, 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 consumer and service to enable the service on.
   *  The `EnableService` and `DisableService` methods currently only support
   *  projects.
   *  Enabling a service requires that the service is public or is shared with
   *  the user enabling the service.
   *  An example name would be:
   *  `projects/123/services/serviceusage.googleapis.com` where `123` is the
   *  project number.
   */
  // const name = 'abc123'

  // Imports the Serviceusage library
  const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;

  // Instantiates a client
  const serviceusageClient = new ServiceUsageClient();

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

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

  callEnableService();

enableService(request, options, callback)

enableService(request: protos.google.api.serviceusage.v1.IEnableServiceRequest, options: CallOptions, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IEnableServiceRequest
options CallOptions
callback Callback<LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
Type Description
void

enableService(request, callback)

enableService(request: protos.google.api.serviceusage.v1.IEnableServiceRequest, callback: Callback<LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IEnableServiceRequest
callback Callback<LROperation<protos.google.api.serviceusage.v1.IEnableServiceResponse, protos.google.api.serviceusage.v1.IOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>
Returns
Type Description
void

folderServicePath(folder, service)

folderServicePath(folder: string, service: string): string;

Return a fully-qualified folderService resource name string.

Parameters
Name Description
folder string
service string
Returns
Type Description
string

{string} Resource name string.

getOperation(request, optionsOrCallback, callback)

getOperation(request: protos.google.longrunning.GetOperationRequest, optionsOrCallback?: 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
Name Description
request GetOperationRequest

The request object that will be sent.

optionsOrCallback CallOptions | Callback<protos.google.longrunning.Operation, protos.google.longrunning.GetOperationRequest, {} | null | undefined>
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
Type Description
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
Type Description
Promise<string>

getProjectId(callback)

getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter
Name Description
callback Callback<string, undefined, undefined>
Returns
Type Description
void

getService(request, options)

getService(request?: protos.google.api.serviceusage.v1.IGetServiceRequest, options?: CallOptions): Promise<[
        protos.google.api.serviceusage.v1.IService,
        protos.google.api.serviceusage.v1.IGetServiceRequest | undefined,
        {} | undefined
    ]>;

Returns the service configuration and enabled state for a given service.

Parameters
Name Description
request IGetServiceRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.api.serviceusage.v1.IService, protos.google.api.serviceusage.v1.IGetServiceRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing Service. 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 consumer and service to get the `ConsumerState` for.
   *  An example name would be:
   *  `projects/123/services/serviceusage.googleapis.com` where `123` is the
   *  project number.
   */
  // const name = 'abc123'

  // Imports the Serviceusage library
  const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;

  // Instantiates a client
  const serviceusageClient = new ServiceUsageClient();

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

    // Run request
    const response = await serviceusageClient.getService(request);
    console.log(response);
  }

  callGetService();

getService(request, options, callback)

getService(request: protos.google.api.serviceusage.v1.IGetServiceRequest, options: CallOptions, callback: Callback<protos.google.api.serviceusage.v1.IService, protos.google.api.serviceusage.v1.IGetServiceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetServiceRequest
options CallOptions
callback Callback<protos.google.api.serviceusage.v1.IService, protos.google.api.serviceusage.v1.IGetServiceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
void

getService(request, callback)

getService(request: protos.google.api.serviceusage.v1.IGetServiceRequest, callback: Callback<protos.google.api.serviceusage.v1.IService, protos.google.api.serviceusage.v1.IGetServiceRequest | null | undefined, {} | null | undefined>): void;
Parameters
Name Description
request IGetServiceRequest
callback Callback<protos.google.api.serviceusage.v1.IService, protos.google.api.serviceusage.v1.IGetServiceRequest | null | undefined, {} | null | undefined>
Returns
Type Description
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
Type Description
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.IOperation>;

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
Name Description
request ListOperationsRequest

The request object that will be sent.

options 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
Type Description
AsyncIterable<protos.google.longrunning.IOperation>

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

Example

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

listServices(request, options)

listServices(request?: protos.google.api.serviceusage.v1.IListServicesRequest, options?: CallOptions): Promise<[
        protos.google.api.serviceusage.v1.IService[],
        protos.google.api.serviceusage.v1.IListServicesRequest | null,
        protos.google.api.serviceusage.v1.IListServicesResponse
    ]>;

List all services available to the specified project, and the current state of those services with respect to the project. The list includes all public services, all services for which the calling user has the servicemanagement.services.bind permission, and all services that have already been enabled on the project. The list can be filtered to only include services in a specific state, for example to only include services enabled on the project.

WARNING: If you need to query enabled services frequently or across an organization, you should use [Cloud Asset Inventory API](https://cloud.google.com/asset-inventory/docs/apis), which provides higher throughput and richer filtering capability.

Parameters
Name Description
request IListServicesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Promise<[ protos.google.api.serviceusage.v1.IService[], protos.google.api.serviceusage.v1.IListServicesRequest | null, protos.google.api.serviceusage.v1.IListServicesResponse ]>

{Promise} - The promise which resolves to an array. The first element of the array is Array of Service. 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 listServicesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

listServices(request, options, callback)

listServices(request: protos.google.api.serviceusage.v1.IListServicesRequest, options: CallOptions, callback: PaginationCallback<protos.google.api.serviceusage.v1.IListServicesRequest, protos.google.api.serviceusage.v1.IListServicesResponse | null | undefined, protos.google.api.serviceusage.v1.IService>): void;
Parameters
Name Description
request IListServicesRequest
options CallOptions
callback PaginationCallback<protos.google.api.serviceusage.v1.IListServicesRequest, protos.google.api.serviceusage.v1.IListServicesResponse | null | undefined, protos.google.api.serviceusage.v1.IService>
Returns
Type Description
void

listServices(request, callback)

listServices(request: protos.google.api.serviceusage.v1.IListServicesRequest, callback: PaginationCallback<protos.google.api.serviceusage.v1.IListServicesRequest, protos.google.api.serviceusage.v1.IListServicesResponse | null | undefined, protos.google.api.serviceusage.v1.IService>): void;
Parameters
Name Description
request IListServicesRequest
callback PaginationCallback<protos.google.api.serviceusage.v1.IListServicesRequest, protos.google.api.serviceusage.v1.IListServicesResponse | null | undefined, protos.google.api.serviceusage.v1.IService>
Returns
Type Description
void

listServicesAsync(request, options)

listServicesAsync(request?: protos.google.api.serviceusage.v1.IListServicesRequest, options?: CallOptions): AsyncIterable<protos.google.api.serviceusage.v1.IService>;

Equivalent to listServices, but returns an iterable object.

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

Parameters
Name Description
request IListServicesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
AsyncIterable<protos.google.api.serviceusage.v1.IService>

{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Service. 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.
   */
  /**
   *  Parent to search for services on.
   *  An example name would be:
   *  `projects/123` where `123` is the project number.
   */
  // const parent = 'abc123'
  /**
   *  Requested size of the next page of data.
   *  Requested page size cannot exceed 200.
   *  If not set, the default page size is 50.
   */
  // const pageSize = 1234
  /**
   *  Token identifying which result to start with, which is returned by a
   *  previous list call.
   */
  // const pageToken = 'abc123'
  /**
   *  Only list services that conform to the given filter.
   *  The allowed filter strings are `state:ENABLED` and `state:DISABLED`.
   */
  // const filter = 'abc123'

  // Imports the Serviceusage library
  const {ServiceUsageClient} = require('@google-cloud/service-usage').v1;

  // Instantiates a client
  const serviceusageClient = new ServiceUsageClient();

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

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

  callListServices();

listServicesStream(request, options)

listServicesStream(request?: protos.google.api.serviceusage.v1.IListServicesRequest, options?: CallOptions): Transform;

Equivalent to listServices, but returns a NodeJS Stream object.

Parameters
Name Description
request IListServicesRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
Type Description
Transform

{Stream} An object stream which emits an object representing Service 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 listServicesAsync() method described below for async iteration which you can stop as needed. Please see the documentation for more details and examples.

matchFolderFromFolderServiceName(folderServiceName)

matchFolderFromFolderServiceName(folderServiceName: string): string | number;

Parse the folder from FolderService resource.

Parameter
Name Description
folderServiceName string

A fully-qualified path representing folder_service resource.

Returns
Type Description
string | number

{string} A string representing the folder.

matchOrganizationFromOrganizationServiceName(organizationServiceName)

matchOrganizationFromOrganizationServiceName(organizationServiceName: string): string | number;

Parse the organization from OrganizationService resource.

Parameter
Name Description
organizationServiceName string

A fully-qualified path representing organization_service resource.

Returns
Type Description
string | number

{string} A string representing the organization.

matchProjectFromProjectServiceName(projectServiceName)

matchProjectFromProjectServiceName(projectServiceName: string): string | number;

Parse the project from ProjectService resource.

Parameter
Name Description
projectServiceName string

A fully-qualified path representing project_service resource.

Returns
Type Description
string | number

{string} A string representing the project.

matchServiceFromFolderServiceName(folderServiceName)

matchServiceFromFolderServiceName(folderServiceName: string): string | number;

Parse the service from FolderService resource.

Parameter
Name Description
folderServiceName string

A fully-qualified path representing folder_service resource.

Returns
Type Description
string | number

{string} A string representing the service.

matchServiceFromOrganizationServiceName(organizationServiceName)

matchServiceFromOrganizationServiceName(organizationServiceName: string): string | number;

Parse the service from OrganizationService resource.

Parameter
Name Description
organizationServiceName string

A fully-qualified path representing organization_service resource.

Returns
Type Description
string | number

{string} A string representing the service.

matchServiceFromProjectServiceName(projectServiceName)

matchServiceFromProjectServiceName(projectServiceName: string): string | number;

Parse the service from ProjectService resource.

Parameter
Name Description
projectServiceName string

A fully-qualified path representing project_service resource.

Returns
Type Description
string | number

{string} A string representing the service.

organizationServicePath(organization, service)

organizationServicePath(organization: string, service: string): string;

Return a fully-qualified organizationService resource name string.

Parameters
Name Description
organization string
service string
Returns
Type Description
string

{string} Resource name string.

projectServicePath(project, service)

projectServicePath(project: string, service: string): string;

Return a fully-qualified projectService resource name string.

Parameters
Name Description
project string
service string
Returns
Type Description
string

{string} Resource name string.