Skip to content

Commit 8846b1c

Browse files
feat: support regapic LRO (#89)
Use gapic-generator-typescript v2.15.1. PiperOrigin-RevId: 456946341 Source-Link: googleapis/googleapis@88fd18d Source-Link: googleapis/googleapis-gen@accfa37 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 7b76c54 commit 8846b1c

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

packages/google-cloud-vpc-access/src/v1/vpc_access_service_client.ts

+28-12
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 VpcAccessServiceClient {
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 VpcAccessServiceClient {
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,32 @@ export class VpcAccessServiceClient {
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.ListLocations',
203+
get: '/v1/{name=projects/*}/locations',
204+
},
205+
{
206+
selector: 'google.longrunning.Operations.GetOperation',
207+
get: '/v1/{name=projects/*/locations/*/operations/*}',
208+
},
209+
{
210+
selector: 'google.longrunning.Operations.ListOperations',
211+
get: '/v1/{name=projects/*/locations/*}/operations',
212+
},
213+
];
214+
}
196215
this.operationsClient = this._gaxModule
197-
.lro({
198-
auth: this.auth,
199-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
200-
})
216+
.lro(lroOptions)
201217
.operationsClient(opts);
202218
const createConnectorResponse = protoFilesRoot.lookup(
203219
'.google.cloud.vpcaccess.v1.Connector'

0 commit comments

Comments
 (0)