[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-controlConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of QuotaControllerClient.
Parameters | |
---|---|
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof fallback
: loaded instance of |
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 | |
---|---|
Name | Description |
request |
IAllocateQuotaRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
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. |
/**
* 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 | |
---|---|
Name | Description |
request |
IAllocateQuotaRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.api.servicecontrol.v1.IAllocateQuotaResponse, protos.google.api.servicecontrol.v1.IAllocateQuotaRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
request |
IAllocateQuotaRequest
|
callback |
Callback<protos.google.api.servicecontrol.v1.IAllocateQuotaResponse, protos.google.api.servicecontrol.v1.IAllocateQuotaRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
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 | |
---|---|
Type | Description |
Promise<void> | {Promise} A promise that resolves when the client is closed. |
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 |
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. |