Class v1.ServiceControllerClient (2.0.3)

[Google Service Control API](/service-control/overview)

Lets clients check and report operations against a [managed service](https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService). v1

Package

@google-cloud/service-control

Constructors

(constructor)(opts, gaxInstance)

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

Construct an instance of ServiceControllerClient.

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 ServiceControllerClient({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;

descriptors

descriptors: Descriptors;

innerApiCalls

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

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.

serviceControllerStub

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

servicePath

static get servicePath(): string;

The DNS address for this API service.

warn

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

Methods

check(request, options)

check(request?: protos.google.api.servicecontrol.v1.ICheckRequest, options?: CallOptions): Promise<[
        protos.google.api.servicecontrol.v1.ICheckResponse,
        protos.google.api.servicecontrol.v1.ICheckRequest | undefined,
        {} | undefined
    ]>;

Checks whether an operation on a service should be allowed to proceed based on the configuration of the service and related policies. It must be called before the operation is executed.

If feasible, the client should cache the check results and reuse them for 60 seconds. In case of any server errors, the client should rely on the cached results for much longer time to avoid outage. WARNING: There is general 60s delay for the configuration and policy propagation, therefore callers MUST NOT depend on the Check method having the latest policy information.

NOTE: the has the size limit (wire-format byte size) of 1MB.

This method requires the servicemanagement.services.check permission on the specified service. For more information, see [Cloud IAM](https://cloud.google.com/iam).

Parameters
NameDescription
request protos.google.api.servicecontrol.v1.ICheckRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.api.servicecontrol.v1.ICheckResponse, protos.google.api.servicecontrol.v1.ICheckRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing [CheckResponse]. 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.
   */
  /**
   *  The service name as specified in its service configuration. For example,
   *  `"pubsub.googleapis.com"`.
   *  See
   *  google.api.Service (https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
   *  for the definition of a service name.
   */
  // const serviceName = 'abc123'
  /**
   *  The operation to be checked.
   */
  // const operation = {}
  /**
   *  Specifies which version of service configuration should be used to process
   *  the request.
   *  If unspecified or no matching version can be found, the
   *  latest one will be used.
   */
  // const serviceConfigId = 'abc123'

  // Imports the Servicecontrol library
  const {ServiceControllerClient} = require('@google-cloud/service-control').v1;

  // Instantiates a client
  const servicecontrolClient = new ServiceControllerClient();

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

    // Run request
    const response = await servicecontrolClient.check(request);
    console.log(response);
  }

  callCheck();

check(request, options, callback)

check(request: protos.google.api.servicecontrol.v1.ICheckRequest, options: CallOptions, callback: Callback<protos.google.api.servicecontrol.v1.ICheckResponse, protos.google.api.servicecontrol.v1.ICheckRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.api.servicecontrol.v1.ICheckRequest
options CallOptions
callback Callback<protos.google.api.servicecontrol.v1.ICheckResponse, protos.google.api.servicecontrol.v1.ICheckRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

check(request, callback)

check(request: protos.google.api.servicecontrol.v1.ICheckRequest, callback: Callback<protos.google.api.servicecontrol.v1.ICheckResponse, protos.google.api.servicecontrol.v1.ICheckRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.api.servicecontrol.v1.ICheckRequest
callback Callback<protos.google.api.servicecontrol.v1.ICheckResponse, protos.google.api.servicecontrol.v1.ICheckRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

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.

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.

report(request, options)

report(request?: protos.google.api.servicecontrol.v1.IReportRequest, options?: CallOptions): Promise<[
        protos.google.api.servicecontrol.v1.IReportResponse,
        protos.google.api.servicecontrol.v1.IReportRequest | undefined,
        {} | undefined
    ]>;

Reports operation results to Google Service Control, such as logs and metrics. It should be called after an operation is completed.

If feasible, the client should aggregate reporting data for up to 5 seconds to reduce API traffic. Limiting aggregation to 5 seconds is to reduce data loss during client crashes. Clients should carefully choose the aggregation time window to avoid data loss risk more than 0.01% for business and compliance reasons.

NOTE: the has the size limit (wire-format byte size) of 1MB.

This method requires the servicemanagement.services.report permission on the specified service. For more information, see [Google Cloud IAM](https://cloud.google.com/iam).

Parameters
NameDescription
request protos.google.api.servicecontrol.v1.IReportRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

Returns
TypeDescription
Promise<[ protos.google.api.servicecontrol.v1.IReportResponse, protos.google.api.servicecontrol.v1.IReportRequest | undefined, {} | undefined ]>

{Promise} - The promise which resolves to an array. The first element of the array is an object representing [ReportResponse]. 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.
   */
  /**
   *  The service name as specified in its service configuration. For example,
   *  `"pubsub.googleapis.com"`.
   *  See
   *  google.api.Service (https://cloud.google.com/service-management/reference/rpc/google.api#google.api.Service)
   *  for the definition of a service name.
   */
  // const serviceName = 'abc123'
  /**
   *  Operations to be reported.
   *  Typically the service should report one operation per request.
   *  Putting multiple operations into a single request is allowed, but should
   *  be used only when multiple operations are natually available at the time
   *  of the report.
   *  There is no limit on the number of operations in the same ReportRequest,
   *  however the ReportRequest size should be no larger than 1MB. See
   *  ReportResponse.report_errors google.api.servicecontrol.v1.ReportResponse.report_errors 
   *  for partial failure behavior.
   */
  // const operations = 1234
  /**
   *  Specifies which version of service config should be used to process the
   *  request.
   *  If unspecified or no matching version can be found, the
   *  latest one will be used.
   */
  // const serviceConfigId = 'abc123'

  // Imports the Servicecontrol library
  const {ServiceControllerClient} = require('@google-cloud/service-control').v1;

  // Instantiates a client
  const servicecontrolClient = new ServiceControllerClient();

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

    // Run request
    const response = await servicecontrolClient.report(request);
    console.log(response);
  }

  callReport();

report(request, options, callback)

report(request: protos.google.api.servicecontrol.v1.IReportRequest, options: CallOptions, callback: Callback<protos.google.api.servicecontrol.v1.IReportResponse, protos.google.api.servicecontrol.v1.IReportRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.api.servicecontrol.v1.IReportRequest
options CallOptions
callback Callback<protos.google.api.servicecontrol.v1.IReportResponse, protos.google.api.servicecontrol.v1.IReportRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void

report(request, callback)

report(request: protos.google.api.servicecontrol.v1.IReportRequest, callback: Callback<protos.google.api.servicecontrol.v1.IReportResponse, protos.google.api.servicecontrol.v1.IReportRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request protos.google.api.servicecontrol.v1.IReportRequest
callback Callback<protos.google.api.servicecontrol.v1.IReportResponse, protos.google.api.servicecontrol.v1.IReportRequest | null | undefined, {} | null | undefined>
Returns
TypeDescription
void