[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-controlConstructors
(constructor)(opts)
constructor(opts?: ClientOptions);
Construct an instance of ServiceControllerClient.
Name | Description |
opts |
ClientOptions
|
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).
Name | Description |
request |
protos.google.api.servicecontrol.v1.ICheckRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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. |
/**
* 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;
Name | Description |
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>
|
Type | Description |
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;
Name | Description |
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>
|
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.
Type | Description |
Promise<void> | {Promise} A promise that resolves when the client is closed. |
getProjectId()
getProjectId(): Promise<string>;
Type | Description |
Promise<string> |
getProjectId(callback)
getProjectId(callback: Callback<string, undefined, undefined>): void;
Name | Description |
callback |
Callback<string, undefined, undefined>
|
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.
Type | Description |
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).
Name | Description |
request |
protos.google.api.servicecontrol.v1.IReportRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Type | Description |
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. |
/**
* 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;
Name | Description |
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>
|
Type | Description |
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;
Name | Description |
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>
|
Type | Description |
void |