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

Commit b3761fc

Browse files
feat: support regapic LRO (#116)
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 5e40ba2 commit b3761fc

File tree

1 file changed

+81
-12
lines changed

1 file changed

+81
-12
lines changed

src/v1/api_gateway_service_client.ts

+81-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,
@@ -72,7 +73,7 @@ export class ApiGatewayServiceClient {
7273
*
7374
* @param {object} [options] - The configuration object.
7475
* The options accepted by the constructor are described in detail
75-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
76+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7677
* The common options are:
7778
* @param {object} [options.credentials] - Credentials object.
7879
* @param {string} [options.credentials.client_email]
@@ -95,11 +96,10 @@ export class ApiGatewayServiceClient {
9596
* API remote host.
9697
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9798
* Follows the structure of {@link gapicConfig}.
98-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
99-
* In fallback mode, a special browser-compatible transport implementation is used
100-
* instead of gRPC transport. In browser context (if the `window` object is defined)
101-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
102-
* if you need to override this behavior.
99+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
100+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
101+
* For more information, please check the
102+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
103103
*/
104104
constructor(opts?: ClientOptions) {
105105
// Ensure that options include all the required fields.
@@ -199,16 +199,85 @@ export class ApiGatewayServiceClient {
199199
};
200200

201201
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
202-
203202
// This API contains "long-running operations", which return a
204203
// an Operation object that allows for tracking of the operation,
205204
// rather than holding a request open.
206-
205+
const lroOptions: GrpcClientOptions = {
206+
auth: this.auth,
207+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
208+
};
209+
if (opts.fallback === 'rest') {
210+
lroOptions.protoJson = protoFilesRoot;
211+
lroOptions.httpRules = [
212+
{
213+
selector: 'google.cloud.location.Locations.GetLocation',
214+
get: '/v1/{name=projects/*/locations/*}',
215+
},
216+
{
217+
selector: 'google.cloud.location.Locations.ListLocations',
218+
get: '/v1/{name=projects/*}/locations',
219+
},
220+
{
221+
selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',
222+
get: '/v1/{resource=projects/*/locations/*/gateways/*}:getIamPolicy',
223+
additional_bindings: [
224+
{get: '/v1/{resource=projects/*/locations/*/apis/*}:getIamPolicy'},
225+
{
226+
get: '/v1/{resource=projects/*/locations/*/apis/*/configs/*}:getIamPolicy',
227+
},
228+
],
229+
},
230+
{
231+
selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',
232+
post: '/v1/{resource=projects/*/locations/*/gateways/*}:setIamPolicy',
233+
body: '*',
234+
additional_bindings: [
235+
{
236+
post: '/v1/{resource=projects/*/locations/*/apis/*}:setIamPolicy',
237+
body: '*',
238+
},
239+
{
240+
post: '/v1/{resource=projects/*/locations/*/apis/*/configs/*}:setIamPolicy',
241+
body: '*',
242+
},
243+
],
244+
},
245+
{
246+
selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',
247+
post: '/v1/{resource=projects/*/locations/*/gateways/*}:testIamPermissions',
248+
body: '*',
249+
additional_bindings: [
250+
{
251+
post: '/v1/{resource=projects/*/locations/*/apis/*}:testIamPermissions',
252+
body: '*',
253+
},
254+
{
255+
post: '/v1/{resource=projects/*/locations/*/apis/*/configs/*}:testIamPermissions',
256+
body: '*',
257+
},
258+
],
259+
},
260+
{
261+
selector: 'google.longrunning.Operations.CancelOperation',
262+
post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',
263+
body: '*',
264+
},
265+
{
266+
selector: 'google.longrunning.Operations.DeleteOperation',
267+
delete: '/v1/{name=projects/*/locations/*/operations/*}',
268+
},
269+
{
270+
selector: 'google.longrunning.Operations.GetOperation',
271+
get: '/v1/{name=projects/*/locations/*/operations/*}',
272+
},
273+
{
274+
selector: 'google.longrunning.Operations.ListOperations',
275+
get: '/v1/{name=projects/*/locations/*}/operations',
276+
},
277+
];
278+
}
207279
this.operationsClient = this._gaxModule
208-
.lro({
209-
auth: this.auth,
210-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
211-
})
280+
.lro(lroOptions)
212281
.operationsClient(opts);
213282
const createGatewayResponse = protoFilesRoot.lookup(
214283
'.google.cloud.apigateway.v1.Gateway'

0 commit comments

Comments
 (0)