0.0.20241024 • Published 8 months ago

@maxim_mazurok/gapi.client.servicecontrol-v1 v0.0.20241024

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

TypeScript typings for Service Control API v1

Provides admission control and telemetry reporting for services integrated with Service Infrastructure. For detailed description please check documentation.

Installing

Install typings for Service Control API:

npm install @types/gapi.client.servicecontrol-v1 --save-dev

Usage

You need to initialize Google API client in your code:

gapi.load('client', () => {
  // now we can use gapi.client
  // ...
});

Then load api client wrapper:

gapi.client.load(
  'https://servicecontrol.googleapis.com/$discovery/rest?version=v1',
  () => {
    // now we can use:
    // gapi.client.servicecontrol
  }
);
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('servicecontrol', 'v1', () => {
  // now we can use:
  // gapi.client.servicecontrol
});

Don't forget to authenticate your client before sending any request to resources:

// declare client_id registered in Google Developers Console
var client_id = '',
  scope = [
    // See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
    'https://www.googleapis.com/auth/cloud-platform',

    // Manage your Google Service Control data
    'https://www.googleapis.com/auth/servicecontrol',
  ],
  immediate = true;
// ...

gapi.auth.authorize(
  {client_id: client_id, scope: scope, immediate: immediate},
  authResult => {
    if (authResult && !authResult.error) {
      /* handle successful authorization */
    } else {
      /* handle authorization error */
    }
  }
);

After that you can use Service Control API resources:

/*
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.
*/
await gapi.client.servicecontrol.services.allocateQuota({
  serviceName: 'serviceName',
});

/*
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 CheckRequest 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).
*/
await gapi.client.servicecontrol.services.check({serviceName: 'serviceName'});

/*
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 ReportRequest 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).
*/
await gapi.client.servicecontrol.services.report({serviceName: 'serviceName'});
0.0.20241024

8 months ago

0.0.20241020

9 months ago

0.0.20240927

9 months ago

0.0.20241003

9 months ago

0.0.20240906

10 months ago

0.0.20240917

10 months ago

0.0.20240921

10 months ago

0.0.20240830

10 months ago

0.0.20240824

11 months ago

0.0.20240607

1 year ago

0.0.20240726

11 months ago

0.0.20240618

1 year ago

0.0.20240628

1 year ago

0.0.20240621

1 year ago

0.0.20240531

1 year ago

0.0.20240809

11 months ago

0.0.20240802

11 months ago

0.0.20240524

1 year ago

0.0.20240816

11 months ago

0.0.20240705

12 months ago

0.0.20240719

12 months ago

0.0.20240712

12 months ago

0.0.20240516

1 year ago

0.0.20240510

1 year ago

0.0.20240504

1 year ago

0.0.20240426

1 year ago

0.0.20240419

1 year ago

0.0.20240412

1 year ago

0.0.20240322

1 year ago

0.0.20240315

1 year ago

0.0.20240309

1 year ago

0.0.20240301

1 year ago

0.0.20240223

1 year ago

0.0.20240216

1 year ago

0.0.20240211

1 year ago

0.0.20240203

1 year ago

0.0.20240130

1 year ago

0.0.20240126

1 year ago

0.0.20240119

1 year ago

0.0.20240112

1 year ago

0.0.20240109

1 year ago

0.0.20240101

2 years ago

0.0.20231211

2 years ago

0.0.20231201

2 years ago

0.0.20231128

2 years ago

0.0.20230812

2 years ago

0.0.20231110

2 years ago

0.0.20231030

2 years ago

0.0.20230929

2 years ago

0.0.20230805

2 years ago

0.0.20230728

2 years ago

0.0.20230720

2 years ago

0.0.20231019

2 years ago

0.0.20230923

2 years ago

0.0.20231104

2 years ago

0.0.20230915

2 years ago

0.0.20230717

2 years ago

0.0.20231006

2 years ago

0.0.20230831

2 years ago

0.0.20231016

2 years ago

0.0.20230707

2 years ago

0.0.20230908

2 years ago

0.0.20230630

2 years ago

0.0.20230623

2 years ago

0.0.20230519

2 years ago

0.0.20230619

2 years ago

0.0.20230515

2 years ago

0.0.20230609

2 years ago

0.0.20230601

2 years ago

0.0.20230529

2 years ago

0.0.20230504

2 years ago

0.0.20230428

2 years ago

0.0.20230414

2 years ago

0.0.20230317

2 years ago

0.0.20230421

2 years ago

0.0.20230224

2 years ago

0.0.20230324

2 years ago

0.0.20230407

2 years ago

0.0.20230306

2 years ago

0.0.20230331

2 years ago

0.0.20230310

2 years ago

0.0.20230215

2 years ago

0.0.20230221

2 years ago

0.0.20230203

2 years ago

0.0.20230127

2 years ago

0.0.20230130

2 years ago

0.0.20230210

2 years ago

0.0.20221204

3 years ago

0.0.20221104

3 years ago

0.0.20230104

2 years ago

0.0.20221111

3 years ago

0.0.20230109

2 years ago

0.0.20230124

2 years ago

0.0.20221020

3 years ago

0.0.20221028

3 years ago

0.0.20221014

3 years ago

0.0.20220923

3 years ago

0.0.20220829

3 years ago

0.0.20220819

3 years ago

0.0.20220909

3 years ago

0.0.20220902

3 years ago

0.0.20220915

3 years ago

0.0.20220812

3 years ago

0.0.20220805

3 years ago

0.0.20220729

3 years ago