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

Commit c43760a

Browse files
feat: support regapic LRO (#83)
* feat: support regapic LRO 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 * 🦉 Updates from OwlBot post-processor 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 77b07fa commit c43760a

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

src/v2beta/workflows_service_v2_beta_client.ts

Lines changed: 37 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
} from 'google-gax';
2829

@@ -68,7 +69,7 @@ export class WorkflowsServiceV2BetaClient {
6869
*
6970
* @param {object} [options] - The configuration object.
7071
* The options accepted by the constructor are described in detail
71-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
72+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7273
* The common options are:
7374
* @param {object} [options.credentials] - Credentials object.
7475
* @param {string} [options.credentials.client_email]
@@ -91,11 +92,10 @@ export class WorkflowsServiceV2BetaClient {
9192
* API remote host.
9293
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9394
* Follows the structure of {@link gapicConfig}.
94-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
95-
* In fallback mode, a special browser-compatible transport implementation is used
96-
* instead of gRPC transport. In browser context (if the `window` object is defined)
97-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
98-
* if you need to override this behavior.
95+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
96+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
97+
* For more information, please check the
98+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
9999
*/
100100
constructor(opts?: ClientOptions) {
101101
// Ensure that options include all the required fields.
@@ -160,16 +160,41 @@ export class WorkflowsServiceV2BetaClient {
160160
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
161161

162162
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
163-
164163
// This API contains "long-running operations", which return a
165164
// an Operation object that allows for tracking of the operation,
166165
// rather than holding a request open.
167-
166+
const lroOptions: GrpcClientOptions = {
167+
auth: this.auth,
168+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
169+
};
170+
if (opts.fallback === 'rest') {
171+
lroOptions.protoJson = protoFilesRoot;
172+
lroOptions.httpRules = [
173+
{
174+
selector: 'google.cloud.location.Locations.GetLocation',
175+
get: '/v2beta/{name=projects/*/locations/*}',
176+
},
177+
{
178+
selector: 'google.cloud.location.Locations.ListLocations',
179+
get: '/v2beta/{name=projects/*}/locations',
180+
},
181+
{
182+
selector: 'google.longrunning.Operations.CancelOperation',
183+
post: '/v2beta/{name=projects/*/locations/*/operations/*}:cancel',
184+
body: '*',
185+
},
186+
{
187+
selector: 'google.longrunning.Operations.GetOperation',
188+
get: '/v2beta/{name=projects/*/locations/*/operations/*}',
189+
},
190+
{
191+
selector: 'google.longrunning.Operations.ListOperations',
192+
get: '/v2beta/{name=projects/*/locations/*}/operations',
193+
},
194+
];
195+
}
168196
this.operationsClient = this._gaxModule
169-
.lro({
170-
auth: this.auth,
171-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
172-
})
197+
.lro(lroOptions)
173198
.operationsClient(opts);
174199
const runPipelineResponse = protoFilesRoot.lookup(
175200
'.google.cloud.lifesciences.v2beta.RunPipelineResponse'

0 commit comments

Comments
 (0)