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

Commit 140ce9d

Browse files
feat: support regapic LRO (#635)
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 e6f3f05 commit 140ce9d

5 files changed

Lines changed: 50 additions & 42 deletions

File tree

src/v1/asset_service_client.ts

Lines changed: 20 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,
@@ -72,7 +73,7 @@ export class AssetServiceClient {
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 AssetServiceClient {
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.
@@ -228,16 +228,24 @@ export class AssetServiceClient {
228228
};
229229

230230
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
231-
232231
// This API contains "long-running operations", which return a
233232
// an Operation object that allows for tracking of the operation,
234233
// rather than holding a request open.
235-
234+
const lroOptions: GrpcClientOptions = {
235+
auth: this.auth,
236+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
237+
};
238+
if (opts.fallback === 'rest') {
239+
lroOptions.protoJson = protoFilesRoot;
240+
lroOptions.httpRules = [
241+
{
242+
selector: 'google.longrunning.Operations.GetOperation',
243+
get: '/v1/{name=*/*/operations/*/**}',
244+
},
245+
];
246+
}
236247
this.operationsClient = this._gaxModule
237-
.lro({
238-
auth: this.auth,
239-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
240-
})
248+
.lro(lroOptions)
241249
.operationsClient(opts);
242250
const exportAssetsResponse = protoFilesRoot.lookup(
243251
'.google.cloud.asset.v1.ExportAssetsResponse'

src/v1p1beta1/asset_service_client.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class AssetServiceClient {
6969
*
7070
* @param {object} [options] - The configuration object.
7171
* The options accepted by the constructor are described in detail
72-
* 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).
7373
* The common options are:
7474
* @param {object} [options.credentials] - Credentials object.
7575
* @param {string} [options.credentials.client_email]
@@ -92,11 +92,10 @@ export class AssetServiceClient {
9292
* API remote host.
9393
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9494
* Follows the structure of {@link gapicConfig}.
95-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
96-
* In fallback mode, a special browser-compatible transport implementation is used
97-
* instead of gRPC transport. In browser context (if the `window` object is defined)
98-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
99-
* 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}.
10099
*/
101100
constructor(opts?: ClientOptions) {
102101
// Ensure that options include all the required fields.

src/v1p2beta1/asset_service_client.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class AssetServiceClient {
6161
*
6262
* @param {object} [options] - The configuration object.
6363
* The options accepted by the constructor are described in detail
64-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
64+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
6565
* The common options are:
6666
* @param {object} [options.credentials] - Credentials object.
6767
* @param {string} [options.credentials.client_email]
@@ -84,11 +84,10 @@ export class AssetServiceClient {
8484
* API remote host.
8585
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
8686
* Follows the structure of {@link gapicConfig}.
87-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
88-
* In fallback mode, a special browser-compatible transport implementation is used
89-
* instead of gRPC transport. In browser context (if the `window` object is defined)
90-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
91-
* if you need to override this behavior.
87+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
88+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
89+
* For more information, please check the
90+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
9291
*/
9392
constructor(opts?: ClientOptions) {
9493
// Ensure that options include all the required fields.

src/v1p4beta1/asset_service_client.ts

Lines changed: 15 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

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

160160
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
161-
162161
// This API contains "long-running operations", which return a
163162
// an Operation object that allows for tracking of the operation,
164163
// rather than holding a request open.
165-
164+
const lroOptions: GrpcClientOptions = {
165+
auth: this.auth,
166+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
167+
};
168+
if (opts.fallback === 'rest') {
169+
lroOptions.protoJson = protoFilesRoot;
170+
lroOptions.httpRules = [];
171+
}
166172
this.operationsClient = this._gaxModule
167-
.lro({
168-
auth: this.auth,
169-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
170-
})
173+
.lro(lroOptions)
171174
.operationsClient(opts);
172175
const exportIamPolicyAnalysisResponse = protoFilesRoot.lookup(
173176
'.google.cloud.asset.v1p4beta1.ExportIamPolicyAnalysisResponse'

src/v1p5beta1/asset_service_client.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class AssetServiceClient {
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 AssetServiceClient {
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.

0 commit comments

Comments
 (0)