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

Commit 8565d02

Browse files
feat: support regapic LRO (#158)
* 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 f94cd43 commit 8565d02

5 files changed

Lines changed: 326 additions & 60 deletions

File tree

src/v1/gke_hub_client.ts

Lines changed: 72 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,
@@ -85,7 +86,7 @@ export class GkeHubClient {
8586
*
8687
* @param {object} [options] - The configuration object.
8788
* The options accepted by the constructor are described in detail
88-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
89+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
8990
* The common options are:
9091
* @param {object} [options.credentials] - Credentials object.
9192
* @param {string} [options.credentials.client_email]
@@ -108,11 +109,10 @@ export class GkeHubClient {
108109
* API remote host.
109110
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
110111
* Follows the structure of {@link gapicConfig}.
111-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
112-
* In fallback mode, a special browser-compatible transport implementation is used
113-
* instead of gRPC transport. In browser context (if the `window` object is defined)
114-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
115-
* if you need to override this behavior.
112+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
113+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
114+
* For more information, please check the
115+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
116116
*/
117117
constructor(opts?: ClientOptions) {
118118
// Ensure that options include all the required fields.
@@ -210,16 +210,76 @@ export class GkeHubClient {
210210
};
211211

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

src/v1alpha/gke_hub_client.ts

Lines changed: 72 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,
@@ -85,7 +86,7 @@ export class GkeHubClient {
8586
*
8687
* @param {object} [options] - The configuration object.
8788
* The options accepted by the constructor are described in detail
88-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
89+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
8990
* The common options are:
9091
* @param {object} [options.credentials] - Credentials object.
9192
* @param {string} [options.credentials.client_email]
@@ -108,11 +109,10 @@ export class GkeHubClient {
108109
* API remote host.
109110
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
110111
* Follows the structure of {@link gapicConfig}.
111-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
112-
* In fallback mode, a special browser-compatible transport implementation is used
113-
* instead of gRPC transport. In browser context (if the `window` object is defined)
114-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
115-
* if you need to override this behavior.
112+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
113+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
114+
* For more information, please check the
115+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
116116
*/
117117
constructor(opts?: ClientOptions) {
118118
// Ensure that options include all the required fields.
@@ -196,16 +196,76 @@ export class GkeHubClient {
196196
};
197197

198198
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
199-
200199
// This API contains "long-running operations", which return a
201200
// an Operation object that allows for tracking of the operation,
202201
// rather than holding a request open.
203-
202+
const lroOptions: GrpcClientOptions = {
203+
auth: this.auth,
204+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
205+
};
206+
if (opts.fallback === 'rest') {
207+
lroOptions.protoJson = protoFilesRoot;
208+
lroOptions.httpRules = [
209+
{
210+
selector: 'google.cloud.location.Locations.GetLocation',
211+
get: '/v1alpha/{name=projects/*/locations/*}',
212+
},
213+
{
214+
selector: 'google.cloud.location.Locations.ListLocations',
215+
get: '/v1alpha/{name=projects/*}/locations',
216+
},
217+
{
218+
selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',
219+
get: '/v1alpha/{resource=projects/*/locations/*/memberships/*}:getIamPolicy',
220+
additional_bindings: [
221+
{
222+
get: '/v1alpha/{resource=projects/*/locations/*/features/*}:getIamPolicy',
223+
},
224+
],
225+
},
226+
{
227+
selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',
228+
post: '/v1alpha/{resource=projects/*/locations/*/memberships/*}:setIamPolicy',
229+
body: '*',
230+
additional_bindings: [
231+
{
232+
post: '/v1alpha/{resource=projects/*/locations/*/features/*}:setIamPolicy',
233+
body: '*',
234+
},
235+
],
236+
},
237+
{
238+
selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',
239+
post: '/v1alpha/{resource=projects/*/locations/*/memberships/*}:testIamPermissions',
240+
body: '*',
241+
additional_bindings: [
242+
{
243+
post: '/v1alpha/{resource=projects/*/locations/*/features/*}:testIamPermissions',
244+
body: '*',
245+
},
246+
],
247+
},
248+
{
249+
selector: 'google.longrunning.Operations.CancelOperation',
250+
post: '/v1alpha/{name=projects/*/locations/*/operations/*}:cancel',
251+
body: '*',
252+
},
253+
{
254+
selector: 'google.longrunning.Operations.DeleteOperation',
255+
delete: '/v1alpha/{name=projects/*/locations/*/operations/*}',
256+
},
257+
{
258+
selector: 'google.longrunning.Operations.GetOperation',
259+
get: '/v1alpha/{name=projects/*/locations/*/operations/*}',
260+
},
261+
{
262+
selector: 'google.longrunning.Operations.ListOperations',
263+
get: '/v1alpha/{name=projects/*/locations/*}/operations',
264+
},
265+
];
266+
}
204267
this.operationsClient = this._gaxModule
205-
.lro({
206-
auth: this.auth,
207-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
208-
})
268+
.lro(lroOptions)
209269
.operationsClient(opts);
210270
const createFeatureResponse = protoFilesRoot.lookup(
211271
'.google.cloud.gkehub.v1alpha.Feature'

src/v1alpha2/gke_hub_client.ts

Lines changed: 55 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,
@@ -79,7 +80,7 @@ export class GkeHubClient {
7980
*
8081
* @param {object} [options] - The configuration object.
8182
* The options accepted by the constructor are described in detail
82-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
83+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
8384
* The common options are:
8485
* @param {object} [options.credentials] - Credentials object.
8586
* @param {string} [options.credentials.client_email]
@@ -102,11 +103,10 @@ export class GkeHubClient {
102103
* API remote host.
103104
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
104105
* Follows the structure of {@link gapicConfig}.
105-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
106-
* In fallback mode, a special browser-compatible transport implementation is used
107-
* instead of gRPC transport. In browser context (if the `window` object is defined)
108-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
109-
* if you need to override this behavior.
106+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
107+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
108+
* For more information, please check the
109+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
110110
*/
111111
constructor(opts?: ClientOptions) {
112112
// Ensure that options include all the required fields.
@@ -196,16 +196,59 @@ export class GkeHubClient {
196196
};
197197

198198
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
199-
200199
// This API contains "long-running operations", which return a
201200
// an Operation object that allows for tracking of the operation,
202201
// rather than holding a request open.
203-
202+
const lroOptions: GrpcClientOptions = {
203+
auth: this.auth,
204+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
205+
};
206+
if (opts.fallback === 'rest') {
207+
lroOptions.protoJson = protoFilesRoot;
208+
lroOptions.httpRules = [
209+
{
210+
selector: 'google.cloud.location.Locations.GetLocation',
211+
get: '/v1alpha2/{name=projects/*/locations/*}',
212+
},
213+
{
214+
selector: 'google.cloud.location.Locations.ListLocations',
215+
get: '/v1alpha2/{name=projects/*}/locations',
216+
},
217+
{
218+
selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',
219+
get: '/v1alpha2/{resource=projects/*/locations/*/memberships/*}:getIamPolicy',
220+
},
221+
{
222+
selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',
223+
post: '/v1alpha2/{resource=projects/*/locations/*/memberships/*}:setIamPolicy',
224+
body: '*',
225+
},
226+
{
227+
selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',
228+
post: '/v1alpha2/{resource=projects/*/locations/*/memberships/*}:testIamPermissions',
229+
body: '*',
230+
},
231+
{
232+
selector: 'google.longrunning.Operations.CancelOperation',
233+
post: '/v1alpha2/{name=projects/*/locations/*/operations/*}:cancel',
234+
body: '*',
235+
},
236+
{
237+
selector: 'google.longrunning.Operations.DeleteOperation',
238+
delete: '/v1alpha2/{name=projects/*/locations/*/operations/*}',
239+
},
240+
{
241+
selector: 'google.longrunning.Operations.GetOperation',
242+
get: '/v1alpha2/{name=projects/*/locations/*/operations/*}',
243+
},
244+
{
245+
selector: 'google.longrunning.Operations.ListOperations',
246+
get: '/v1alpha2/{name=projects/*/locations/*}/operations',
247+
},
248+
];
249+
}
204250
this.operationsClient = this._gaxModule
205-
.lro({
206-
auth: this.auth,
207-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
208-
})
251+
.lro(lroOptions)
209252
.operationsClient(opts);
210253
const createMembershipResponse = protoFilesRoot.lookup(
211254
'.google.cloud.gkehub.v1alpha2.Membership'

0 commit comments

Comments
 (0)