Skip to content

Commit

Permalink
feat: support regapic LRO
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 456946341
Source-Link: googleapis/googleapis@88fd18d
Source-Link: googleapis/googleapis-gen@accfa37
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWNjZmEzNzFmNjY3NDM5MzEzMzM1YzY0MDQyYjA2M2MxYzUzMTAyZSJ9
Source-Link: googleapis/googleapis@ae65014
Source-Link: googleapis/googleapis-gen@b09ede4
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjA5ZWRlNDM1Y2NlMTEwNDQ2ZDRhYjlmNjJhMDgxYjU3MWQzN2UzZiJ9
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] committed Jul 4, 2022
1 parent 503216a commit e702831
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 31 deletions.
7 changes: 1 addition & 6 deletions .jsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,7 @@ module.exports = {
systemName: '@google-cloud/logging',
theme: 'lumen',
default: {
outputSourceFiles: false,
staticFiles: {
include: [
'_static'
]
}
outputSourceFiles: false
}
},
markdown: {
Expand Down
71 changes: 59 additions & 12 deletions src/v2/config_service_v2_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
CallOptions,
Descriptors,
ClientOptions,
GrpcClientOptions,
LROperation,
PaginationCallback,
GaxCall,
Expand Down Expand Up @@ -72,7 +73,7 @@ export class ConfigServiceV2Client {
*
* @param {object} [options] - The configuration object.
* The options accepted by the constructor are described in detail
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
* The common options are:
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
Expand All @@ -95,11 +96,10 @@ export class ConfigServiceV2Client {
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
* In fallback mode, a special browser-compatible transport implementation is used
* instead of gRPC transport. In browser context (if the `window` object is defined)
* the fallback mode is enabled automatically; set `options.fallback` to `false`
* if you need to override this behavior.
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
* For more information, please check the
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
*/
constructor(opts?: ClientOptions) {
// Ensure that options include all the required fields.
Expand Down Expand Up @@ -291,16 +291,63 @@ export class ConfigServiceV2Client {
};

const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);

// This API contains "long-running operations", which return a
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.

const lroOptions: GrpcClientOptions = {
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
};
if (opts.fallback === 'rest') {
lroOptions.protoJson = protoFilesRoot;
lroOptions.httpRules = [
{
selector: 'google.longrunning.Operations.CancelOperation',
post: '/v2/{name=*/*/locations/*/operations/*}:cancel',
body: '*',
additional_bindings: [
{
post: '/v2/{name=projects/*/locations/*/operations/*}:cancel',
body: '*',
},
{
post: '/v2/{name=organizations/*/locations/*/operations/*}:cancel',
body: '*',
},
{
post: '/v2/{name=folders/*/locations/*/operations/*}:cancel',
body: '*',
},
{
post: '/v2/{name=billingAccounts/*/locations/*/operations/*}:cancel',
body: '*',
},
],
},
{
selector: 'google.longrunning.Operations.GetOperation',
get: '/v2/{name=*/*/locations/*/operations/*}',
additional_bindings: [
{get: '/v2/{name=projects/*/locations/*/operations/*}'},
{get: '/v2/{name=organizations/*/locations/*/operations/*}'},
{get: '/v2/{name=folders/*/locations/*/operations/*}'},
{get: '/v2/{name=billingAccounts/*/operations/*}'},
],
},
{
selector: 'google.longrunning.Operations.ListOperations',
get: '/v2/{name=*/*/locations/*}/operations',
additional_bindings: [
{get: '/v2/{name=projects/*/locations/*}/operations'},
{get: '/v2/{name=organizations/*/locations/*}/operations'},
{get: '/v2/{name=folders/*/locations/*}/operations'},
{get: '/v2/{name=billingAccounts/*/locations/*}/operations'},
],
},
];
}
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})
.lro(lroOptions)
.operationsClient(opts);
const copyLogEntriesResponse = protoFilesRoot.lookup(
'.google.logging.v2.CopyLogEntriesResponse'
Expand Down
12 changes: 5 additions & 7 deletions src/v2/logging_service_v2_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class LoggingServiceV2Client {
*
* @param {object} [options] - The configuration object.
* The options accepted by the constructor are described in detail
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
* The common options are:
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
Expand All @@ -95,11 +95,10 @@ export class LoggingServiceV2Client {
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
* In fallback mode, a special browser-compatible transport implementation is used
* instead of gRPC transport. In browser context (if the `window` object is defined)
* the fallback mode is enabled automatically; set `options.fallback` to `false`
* if you need to override this behavior.
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
* For more information, please check the
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
*/
constructor(opts?: ClientOptions) {
// Ensure that options include all the required fields.
Expand Down Expand Up @@ -292,7 +291,6 @@ export class LoggingServiceV2Client {
};

const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);

// Some methods on this API support automatically batching
// requests; denote this.

Expand Down
11 changes: 5 additions & 6 deletions src/v2/metrics_service_v2_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class MetricsServiceV2Client {
*
* @param {object} [options] - The configuration object.
* The options accepted by the constructor are described in detail
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
* The common options are:
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
Expand All @@ -93,11 +93,10 @@ export class MetricsServiceV2Client {
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
* In fallback mode, a special browser-compatible transport implementation is used
* instead of gRPC transport. In browser context (if the `window` object is defined)
* the fallback mode is enabled automatically; set `options.fallback` to `false`
* if you need to override this behavior.
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
* For more information, please check the
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
*/
constructor(opts?: ClientOptions) {
// Ensure that options include all the required fields.
Expand Down

0 comments on commit e702831

Please sign in to comment.