Class v1.QuotaControllerClient (3.3.0)

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

Allows clients to allocate and release quota 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 QuotaControllerClient.

Parameters
NameDescription
opts ClientOptions
gaxInstance typeof gax | typeof fallback

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

port

static get port(): number;

The port for this API service.

quotaControllerStub

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

scopes

static get scopes(): string[];

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

servicePath

static get servicePath(): string;

The DNS address for this API service.

universeDomain

get universeDomain(): string;

warn

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

Methods

allocateQuota(request, options)

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

Attempts to allocate quota for the specified consumer. It should be called before the operation is executed.

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

**NOTE:** The client **must** fail-open on server errors INTERNAL, UNKNOWN, DEADLINE_EXCEEDED, and UNAVAILABLE. To ensure system reliability, the server may inject these errors to prohibit any hard dependency on the quota functionality.

Parameters
NameDescription
request IAllocateQuotaRequest

The request object that will be sent.

options CallOptions

Call options. See CallOptions for more details.

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

{Promise} - The promise which resolves to an array. The first element of the array is an object representing AllocateQuotaResponse. 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 service as specified in the service configuration. For example,
   *  `"pubsub.googleapis.com"`.
   *  See google.api.Service google.api.Service  for the definition of a service name.
   */
  // const serviceName = 'abc123'
  /**
   *  Operation that describes the quota allocation.
   */
  // const allocateOperation = {}
  /**
   *  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 {QuotaControllerClient} = require('@google-cloud/service-control').v1;

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

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

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

  callAllocateQuota();

allocateQuota(request, options, callback)

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

allocateQuota(request, callback)

allocateQuota(request: protos.google.api.servicecontrol.v1.IAllocateQuotaRequest, callback: Callback<protos.google.api.servicecontrol.v1.IAllocateQuotaResponse, protos.google.api.servicecontrol.v1.IAllocateQuotaRequest | null | undefined, {} | null | undefined>): void;
Parameters
NameDescription
request IAllocateQuotaRequest
callback Callback<protos.google.api.servicecontrol.v1.IAllocateQuotaResponse, protos.google.api.servicecontrol.v1.IAllocateQuotaRequest | 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.