Skip to content
This repository was archived by the owner on Jul 20, 2023. It is now read-only.

Commit a513afb

Browse files
feat: support regapic LRO (#146)
Use gapic-generator-typescript v2.15.1. PiperOrigin-RevId: 456946341 Source-Link: googleapis/googleapis@88fd18d Source-Link: https://github.com/googleapis/googleapis-gen/commit/accfa371f667439313335c64042b063c1c53102e Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWNjZmEzNzFmNjY3NDM5MzEzMzM1YzY0MDQyYjA2M2MxYzUzMTAyZSJ9 See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent ee63b3d commit a513afb

File tree

4 files changed

+82
-36
lines changed

4 files changed

+82
-36
lines changed

src/v1/executions_client.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class ExecutionsClient {
7171
*
7272
* @param {object} [options] - The configuration object.
7373
* The options accepted by the constructor are described in detail
74-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
74+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7575
* The common options are:
7676
* @param {object} [options.credentials] - Credentials object.
7777
* @param {string} [options.credentials.client_email]
@@ -94,11 +94,10 @@ export class ExecutionsClient {
9494
* API remote host.
9595
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9696
* Follows the structure of {@link gapicConfig}.
97-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
98-
* In fallback mode, a special browser-compatible transport implementation is used
99-
* instead of gRPC transport. In browser context (if the `window` object is defined)
100-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
101-
* if you need to override this behavior.
97+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
98+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
99+
* For more information, please check the
100+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
102101
*/
103102
constructor(opts?: ClientOptions) {
104103
// Ensure that options include all the required fields.

src/v1/workflows_client.ts

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
CallOptions,
2424
Descriptors,
2525
ClientOptions,
26+
GrpcClientOptions,
2627
LROperation,
2728
PaginationCallback,
2829
GaxCall,
@@ -74,7 +75,7 @@ export class WorkflowsClient {
7475
*
7576
* @param {object} [options] - The configuration object.
7677
* The options accepted by the constructor are described in detail
77-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
78+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7879
* The common options are:
7980
* @param {object} [options.credentials] - Credentials object.
8081
* @param {string} [options.credentials.client_email]
@@ -97,11 +98,10 @@ export class WorkflowsClient {
9798
* API remote host.
9899
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
99100
* Follows the structure of {@link gapicConfig}.
100-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
101-
* In fallback mode, a special browser-compatible transport implementation is used
102-
* instead of gRPC transport. In browser context (if the `window` object is defined)
103-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
104-
* if you need to override this behavior.
101+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
102+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
103+
* For more information, please check the
104+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
105105
*/
106106
constructor(opts?: ClientOptions) {
107107
// Ensure that options include all the required fields.
@@ -188,16 +188,40 @@ export class WorkflowsClient {
188188
};
189189

190190
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
191-
192191
// This API contains "long-running operations", which return a
193192
// an Operation object that allows for tracking of the operation,
194193
// rather than holding a request open.
195-
194+
const lroOptions: GrpcClientOptions = {
195+
auth: this.auth,
196+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
197+
};
198+
if (opts.fallback === 'rest') {
199+
lroOptions.protoJson = protoFilesRoot;
200+
lroOptions.httpRules = [
201+
{
202+
selector: 'google.cloud.location.Locations.GetLocation',
203+
get: '/v1/{name=projects/*/locations/*}',
204+
},
205+
{
206+
selector: 'google.cloud.location.Locations.ListLocations',
207+
get: '/v1/{name=projects/*}/locations',
208+
},
209+
{
210+
selector: 'google.longrunning.Operations.DeleteOperation',
211+
delete: '/v1/{name=projects/*/locations/*/operations/*}',
212+
},
213+
{
214+
selector: 'google.longrunning.Operations.GetOperation',
215+
get: '/v1/{name=projects/*/locations/*/operations/*}',
216+
},
217+
{
218+
selector: 'google.longrunning.Operations.ListOperations',
219+
get: '/v1/{name=projects/*/locations/*}/operations',
220+
},
221+
];
222+
}
196223
this.operationsClient = this._gaxModule
197-
.lro({
198-
auth: this.auth,
199-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
200-
})
224+
.lro(lroOptions)
201225
.operationsClient(opts);
202226
const createWorkflowResponse = protoFilesRoot.lookup(
203227
'.google.cloud.workflows.v1.Workflow'

src/v1beta/executions_client.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class ExecutionsClient {
7171
*
7272
* @param {object} [options] - The configuration object.
7373
* The options accepted by the constructor are described in detail
74-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
74+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7575
* The common options are:
7676
* @param {object} [options.credentials] - Credentials object.
7777
* @param {string} [options.credentials.client_email]
@@ -94,11 +94,10 @@ export class ExecutionsClient {
9494
* API remote host.
9595
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9696
* Follows the structure of {@link gapicConfig}.
97-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
98-
* In fallback mode, a special browser-compatible transport implementation is used
99-
* instead of gRPC transport. In browser context (if the `window` object is defined)
100-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
101-
* if you need to override this behavior.
97+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
98+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
99+
* For more information, please check the
100+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
102101
*/
103102
constructor(opts?: ClientOptions) {
104103
// Ensure that options include all the required fields.

src/v1beta/workflows_client.ts

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
CallOptions,
2424
Descriptors,
2525
ClientOptions,
26+
GrpcClientOptions,
2627
LROperation,
2728
PaginationCallback,
2829
GaxCall,
@@ -74,7 +75,7 @@ export class WorkflowsClient {
7475
*
7576
* @param {object} [options] - The configuration object.
7677
* The options accepted by the constructor are described in detail
77-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
78+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7879
* The common options are:
7980
* @param {object} [options.credentials] - Credentials object.
8081
* @param {string} [options.credentials.client_email]
@@ -97,11 +98,10 @@ export class WorkflowsClient {
9798
* API remote host.
9899
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
99100
* Follows the structure of {@link gapicConfig}.
100-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
101-
* In fallback mode, a special browser-compatible transport implementation is used
102-
* instead of gRPC transport. In browser context (if the `window` object is defined)
103-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
104-
* if you need to override this behavior.
101+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
102+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
103+
* For more information, please check the
104+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
105105
*/
106106
constructor(opts?: ClientOptions) {
107107
// Ensure that options include all the required fields.
@@ -188,16 +188,40 @@ export class WorkflowsClient {
188188
};
189189

190190
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
191-
192191
// This API contains "long-running operations", which return a
193192
// an Operation object that allows for tracking of the operation,
194193
// rather than holding a request open.
195-
194+
const lroOptions: GrpcClientOptions = {
195+
auth: this.auth,
196+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
197+
};
198+
if (opts.fallback === 'rest') {
199+
lroOptions.protoJson = protoFilesRoot;
200+
lroOptions.httpRules = [
201+
{
202+
selector: 'google.cloud.location.Locations.GetLocation',
203+
get: '/v1beta/{name=projects/*/locations/*}',
204+
},
205+
{
206+
selector: 'google.cloud.location.Locations.ListLocations',
207+
get: '/v1beta/{name=projects/*}/locations',
208+
},
209+
{
210+
selector: 'google.longrunning.Operations.DeleteOperation',
211+
delete: '/v1beta/{name=projects/*/locations/*/operations/*}',
212+
},
213+
{
214+
selector: 'google.longrunning.Operations.GetOperation',
215+
get: '/v1beta/{name=projects/*/locations/*/operations/*}',
216+
},
217+
{
218+
selector: 'google.longrunning.Operations.ListOperations',
219+
get: '/v1beta/{name=projects/*/locations/*}/operations',
220+
},
221+
];
222+
}
196223
this.operationsClient = this._gaxModule
197-
.lro({
198-
auth: this.auth,
199-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
200-
})
224+
.lro(lroOptions)
201225
.operationsClient(opts);
202226
const createWorkflowResponse = protoFilesRoot.lookup(
203227
'.google.cloud.workflows.v1beta.Workflow'

0 commit comments

Comments
 (0)