0.0.20240504 • Published 3 days ago

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

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days 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.20240504

3 days ago

0.0.20240426

10 days ago

0.0.20240419

16 days ago

0.0.20240412

24 days ago

0.0.20240322

2 months ago

0.0.20240315

2 months ago

0.0.20240309

2 months ago

0.0.20240301

2 months ago

0.0.20240223

2 months ago

0.0.20240216

3 months ago

0.0.20240211

3 months ago

0.0.20240203

3 months ago

0.0.20240130

3 months ago

0.0.20240126

3 months ago

0.0.20240119

4 months ago

0.0.20240112

4 months ago

0.0.20240109

4 months ago

0.0.20240101

4 months ago

0.0.20231211

5 months ago

0.0.20231201

5 months ago

0.0.20231128

5 months ago

0.0.20230812

9 months ago

0.0.20231110

6 months ago

0.0.20231030

6 months ago

0.0.20230929

7 months ago

0.0.20230805

9 months ago

0.0.20230728

10 months ago

0.0.20230720

10 months ago

0.0.20231019

7 months ago

0.0.20230923

8 months ago

0.0.20231104

6 months ago

0.0.20230915

8 months ago

0.0.20230717

10 months ago

0.0.20231006

7 months ago

0.0.20230831

8 months ago

0.0.20231016

7 months ago

0.0.20230707

10 months ago

0.0.20230908

8 months ago

0.0.20230630

10 months ago

0.0.20230623

11 months ago

0.0.20230519

12 months ago

0.0.20230619

11 months ago

0.0.20230515

12 months ago

0.0.20230609

11 months ago

0.0.20230601

11 months ago

0.0.20230529

11 months ago

0.0.20230504

1 year ago

0.0.20230428

1 year ago

0.0.20230414

1 year ago

0.0.20230317

1 year ago

0.0.20230421

1 year ago

0.0.20230224

1 year ago

0.0.20230324

1 year ago

0.0.20230407

1 year ago

0.0.20230306

1 year ago

0.0.20230331

1 year ago

0.0.20230310

1 year ago

0.0.20230215

1 year ago

0.0.20230221

1 year ago

0.0.20230203

1 year ago

0.0.20230127

1 year ago

0.0.20230130

1 year ago

0.0.20230210

1 year ago

0.0.20221204

1 year ago

0.0.20221104

1 year ago

0.0.20230104

1 year ago

0.0.20221111

1 year ago

0.0.20230109

1 year ago

0.0.20230124

1 year ago

0.0.20221020

2 years ago

0.0.20221028

2 years ago

0.0.20221014

2 years ago

0.0.20220923

2 years ago

0.0.20220829

2 years ago

0.0.20220819

2 years ago

0.0.20220909

2 years ago

0.0.20220902

2 years ago

0.0.20220915

2 years ago

0.0.20220812

2 years ago

0.0.20220805

2 years ago

0.0.20220729

2 years ago