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

Commit a5f8f72

Browse files
gcf-owl-bot[bot]Benjamin E. Coe
andauthored
feat: support regapic LRO
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 Use gapic-generator-typescript v2.15.2. PiperOrigin-RevId: 458552034 Source-Link: googleapis/googleapis@ae65014 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b09ede435cce110446d4ab9f62a081b571d37e3f Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjA5ZWRlNDM1Y2NlMTEwNDQ2ZDRhYjlmNjJhMDgxYjU3MWQzN2UzZiJ9 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> Co-authored-by: Benjamin E. Coe <bencoe@google.com>
1 parent 12bd0f6 commit a5f8f72

File tree

8 files changed

+154
-90
lines changed

8 files changed

+154
-90
lines changed

src/v1/image_annotator_client.ts

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

@@ -70,7 +71,7 @@ export class ImageAnnotatorClient {
7071
*
7172
* @param {object} [options] - The configuration object.
7273
* 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).
74+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7475
* The common options are:
7576
* @param {object} [options.credentials] - Credentials object.
7677
* @param {string} [options.credentials.client_email]
@@ -93,11 +94,10 @@ export class ImageAnnotatorClient {
9394
* API remote host.
9495
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9596
* 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.
97+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
98+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
99+
* For more information, please check the
100+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
101101
*/
102102
constructor(opts?: ClientOptions) {
103103
// Ensure that options include all the required fields.
@@ -176,16 +176,29 @@ export class ImageAnnotatorClient {
176176
};
177177

178178
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
179-
180179
// This API contains "long-running operations", which return a
181180
// an Operation object that allows for tracking of the operation,
182181
// rather than holding a request open.
183-
182+
const lroOptions: GrpcClientOptions = {
183+
auth: this.auth,
184+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
185+
};
186+
if (opts.fallback === 'rest') {
187+
lroOptions.protoJson = protoFilesRoot;
188+
lroOptions.httpRules = [
189+
{
190+
selector: 'google.longrunning.Operations.GetOperation',
191+
get: '/v1/{name=projects/*/operations/*}',
192+
additional_bindings: [
193+
{get: '/v1/{name=projects/*/locations/*/operations/*}'},
194+
{get: '/v1/{name=operations/*}'},
195+
{get: '/v1/{name=locations/*/operations/*}'},
196+
],
197+
},
198+
];
199+
}
184200
this.operationsClient = this._gaxModule
185-
.lro({
186-
auth: this.auth,
187-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
188-
})
201+
.lro(lroOptions)
189202
.operationsClient(opts);
190203
const asyncBatchAnnotateImagesResponse = protoFilesRoot.lookup(
191204
'.google.cloud.vision.v1.AsyncBatchAnnotateImagesResponse'

src/v1/product_search_client.ts

Lines changed: 25 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 ProductSearchClient {
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 ProductSearchClient {
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.
@@ -220,16 +220,29 @@ export class ProductSearchClient {
220220
};
221221

222222
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
223-
224223
// This API contains "long-running operations", which return a
225224
// an Operation object that allows for tracking of the operation,
226225
// rather than holding a request open.
227-
226+
const lroOptions: GrpcClientOptions = {
227+
auth: this.auth,
228+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
229+
};
230+
if (opts.fallback === 'rest') {
231+
lroOptions.protoJson = protoFilesRoot;
232+
lroOptions.httpRules = [
233+
{
234+
selector: 'google.longrunning.Operations.GetOperation',
235+
get: '/v1/{name=projects/*/operations/*}',
236+
additional_bindings: [
237+
{get: '/v1/{name=projects/*/locations/*/operations/*}'},
238+
{get: '/v1/{name=operations/*}'},
239+
{get: '/v1/{name=locations/*/operations/*}'},
240+
],
241+
},
242+
];
243+
}
228244
this.operationsClient = this._gaxModule
229-
.lro({
230-
auth: this.auth,
231-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
232-
})
245+
.lro(lroOptions)
233246
.operationsClient(opts);
234247
const importProductSetsResponse = protoFilesRoot.lookup(
235248
'.google.cloud.vision.v1.ImportProductSetsResponse'

src/v1p1beta1/image_annotator_client.ts

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

src/v1p2beta1/image_annotator_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

@@ -69,7 +70,7 @@ export class ImageAnnotatorClient {
6970
*
7071
* @param {object} [options] - The configuration object.
7172
* 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).
73+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7374
* The common options are:
7475
* @param {object} [options.credentials] - Credentials object.
7576
* @param {string} [options.credentials.client_email]
@@ -92,11 +93,10 @@ export class ImageAnnotatorClient {
9293
* API remote host.
9394
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9495
* 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.
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}.
100100
*/
101101
constructor(opts?: ClientOptions) {
102102
// Ensure that options include all the required fields.
@@ -160,16 +160,19 @@ export class ImageAnnotatorClient {
160160
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
161161

162162
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
163-
164163
// This API contains "long-running operations", which return a
165164
// an Operation object that allows for tracking of the operation,
166165
// rather than holding a request open.
167-
166+
const lroOptions: GrpcClientOptions = {
167+
auth: this.auth,
168+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
169+
};
170+
if (opts.fallback === 'rest') {
171+
lroOptions.protoJson = protoFilesRoot;
172+
lroOptions.httpRules = [];
173+
}
168174
this.operationsClient = this._gaxModule
169-
.lro({
170-
auth: this.auth,
171-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
172-
})
175+
.lro(lroOptions)
173176
.operationsClient(opts);
174177
const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup(
175178
'.google.cloud.vision.v1p2beta1.AsyncBatchAnnotateFilesResponse'

src/v1p3beta1/image_annotator_client.ts

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

@@ -70,7 +71,7 @@ export class ImageAnnotatorClient {
7071
*
7172
* @param {object} [options] - The configuration object.
7273
* 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).
74+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7475
* The common options are:
7576
* @param {object} [options.credentials] - Credentials object.
7677
* @param {string} [options.credentials.client_email]
@@ -93,11 +94,10 @@ export class ImageAnnotatorClient {
9394
* API remote host.
9495
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9596
* 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.
97+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
98+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
99+
* For more information, please check the
100+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
101101
*/
102102
constructor(opts?: ClientOptions) {
103103
// Ensure that options include all the required fields.
@@ -176,16 +176,25 @@ export class ImageAnnotatorClient {
176176
};
177177

178178
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
179-
180179
// This API contains "long-running operations", which return a
181180
// an Operation object that allows for tracking of the operation,
182181
// rather than holding a request open.
183-
182+
const lroOptions: GrpcClientOptions = {
183+
auth: this.auth,
184+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
185+
};
186+
if (opts.fallback === 'rest') {
187+
lroOptions.protoJson = protoFilesRoot;
188+
lroOptions.httpRules = [
189+
{
190+
selector: 'google.longrunning.Operations.GetOperation',
191+
get: '/v1/{name=operations/*}',
192+
additional_bindings: [{get: '/v1/{name=locations/*/operations/*}'}],
193+
},
194+
];
195+
}
184196
this.operationsClient = this._gaxModule
185-
.lro({
186-
auth: this.auth,
187-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
188-
})
197+
.lro(lroOptions)
189198
.operationsClient(opts);
190199
const asyncBatchAnnotateFilesResponse = protoFilesRoot.lookup(
191200
'.google.cloud.vision.v1p3beta1.AsyncBatchAnnotateFilesResponse'

src/v1p3beta1/product_search_client.ts

Lines changed: 21 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 ProductSearchClient {
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 ProductSearchClient {
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.
@@ -220,16 +220,25 @@ export class ProductSearchClient {
220220
};
221221

222222
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
223-
224223
// This API contains "long-running operations", which return a
225224
// an Operation object that allows for tracking of the operation,
226225
// rather than holding a request open.
227-
226+
const lroOptions: GrpcClientOptions = {
227+
auth: this.auth,
228+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
229+
};
230+
if (opts.fallback === 'rest') {
231+
lroOptions.protoJson = protoFilesRoot;
232+
lroOptions.httpRules = [
233+
{
234+
selector: 'google.longrunning.Operations.GetOperation',
235+
get: '/v1/{name=operations/*}',
236+
additional_bindings: [{get: '/v1/{name=locations/*/operations/*}'}],
237+
},
238+
];
239+
}
228240
this.operationsClient = this._gaxModule
229-
.lro({
230-
auth: this.auth,
231-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
232-
})
241+
.lro(lroOptions)
233242
.operationsClient(opts);
234243
const importProductSetsResponse = protoFilesRoot.lookup(
235244
'.google.cloud.vision.v1p3beta1.ImportProductSetsResponse'

0 commit comments

Comments
 (0)