Skip to content

Commit 34bd650

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

File tree

6 files changed

+105
-66
lines changed

6 files changed

+105
-66
lines changed

packages/google-cloud-resourcemanager/src/v3/folders_client.ts

+20-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 FoldersClient {
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 FoldersClient {
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.
@@ -201,16 +201,24 @@ export class FoldersClient {
201201
};
202202

203203
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
204-
205204
// This API contains "long-running operations", which return a
206205
// an Operation object that allows for tracking of the operation,
207206
// rather than holding a request open.
208-
207+
const lroOptions: GrpcClientOptions = {
208+
auth: this.auth,
209+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
210+
};
211+
if (opts.fallback === 'rest') {
212+
lroOptions.protoJson = protoFilesRoot;
213+
lroOptions.httpRules = [
214+
{
215+
selector: 'google.longrunning.Operations.GetOperation',
216+
get: '/v3/{name=operations/**}',
217+
},
218+
];
219+
}
209220
this.operationsClient = this._gaxModule
210-
.lro({
211-
auth: this.auth,
212-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
213-
})
221+
.lro(lroOptions)
214222
.operationsClient(opts);
215223
const createFolderResponse = protoFilesRoot.lookup(
216224
'.google.cloud.resourcemanager.v3.Folder'

packages/google-cloud-resourcemanager/src/v3/organizations_client.ts

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

packages/google-cloud-resourcemanager/src/v3/projects_client.ts

+20-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 ProjectsClient {
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 ProjectsClient {
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,24 @@ export class ProjectsClient {
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.longrunning.Operations.GetOperation',
214+
get: '/v3/{name=operations/**}',
215+
},
216+
];
217+
}
207218
this.operationsClient = this._gaxModule
208-
.lro({
209-
auth: this.auth,
210-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
211-
})
219+
.lro(lroOptions)
212220
.operationsClient(opts);
213221
const createProjectResponse = protoFilesRoot.lookup(
214222
'.google.cloud.resourcemanager.v3.Project'

packages/google-cloud-resourcemanager/src/v3/tag_bindings_client.ts

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

197197
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
198-
199198
// This API contains "long-running operations", which return a
200199
// an Operation object that allows for tracking of the operation,
201200
// rather than holding a request open.
202-
201+
const lroOptions: GrpcClientOptions = {
202+
auth: this.auth,
203+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
204+
};
205+
if (opts.fallback === 'rest') {
206+
lroOptions.protoJson = protoFilesRoot;
207+
lroOptions.httpRules = [
208+
{
209+
selector: 'google.longrunning.Operations.GetOperation',
210+
get: '/v3/{name=operations/**}',
211+
},
212+
];
213+
}
203214
this.operationsClient = this._gaxModule
204-
.lro({
205-
auth: this.auth,
206-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
207-
})
215+
.lro(lroOptions)
208216
.operationsClient(opts);
209217
const createTagBindingResponse = protoFilesRoot.lookup(
210218
'.google.cloud.resourcemanager.v3.TagBinding'

packages/google-cloud-resourcemanager/src/v3/tag_keys_client.ts

+20-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 TagKeysClient {
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 TagKeysClient {
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.
@@ -194,16 +194,24 @@ export class TagKeysClient {
194194
};
195195

196196
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
197-
198197
// This API contains "long-running operations", which return a
199198
// an Operation object that allows for tracking of the operation,
200199
// rather than holding a request open.
201-
200+
const lroOptions: GrpcClientOptions = {
201+
auth: this.auth,
202+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
203+
};
204+
if (opts.fallback === 'rest') {
205+
lroOptions.protoJson = protoFilesRoot;
206+
lroOptions.httpRules = [
207+
{
208+
selector: 'google.longrunning.Operations.GetOperation',
209+
get: '/v3/{name=operations/**}',
210+
},
211+
];
212+
}
202213
this.operationsClient = this._gaxModule
203-
.lro({
204-
auth: this.auth,
205-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
206-
})
214+
.lro(lroOptions)
207215
.operationsClient(opts);
208216
const createTagKeyResponse = protoFilesRoot.lookup(
209217
'.google.cloud.resourcemanager.v3.TagKey'

packages/google-cloud-resourcemanager/src/v3/tag_values_client.ts

+20-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 TagValuesClient {
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 TagValuesClient {
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.
@@ -194,16 +194,24 @@ export class TagValuesClient {
194194
};
195195

196196
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
197-
198197
// This API contains "long-running operations", which return a
199198
// an Operation object that allows for tracking of the operation,
200199
// rather than holding a request open.
201-
200+
const lroOptions: GrpcClientOptions = {
201+
auth: this.auth,
202+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
203+
};
204+
if (opts.fallback === 'rest') {
205+
lroOptions.protoJson = protoFilesRoot;
206+
lroOptions.httpRules = [
207+
{
208+
selector: 'google.longrunning.Operations.GetOperation',
209+
get: '/v3/{name=operations/**}',
210+
},
211+
];
212+
}
202213
this.operationsClient = this._gaxModule
203-
.lro({
204-
auth: this.auth,
205-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
206-
})
214+
.lro(lroOptions)
207215
.operationsClient(opts);
208216
const createTagValueResponse = protoFilesRoot.lookup(
209217
'.google.cloud.resourcemanager.v3.TagValue'

0 commit comments

Comments
 (0)