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

Commit 903e5ca

Browse files
feat: support regapic LRO (#720)
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 bf3a12a commit 903e5ca

6 files changed

+248
-66
lines changed

src/v1/video_intelligence_service_client.ts

Lines changed: 47 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 VideoIntelligenceServiceClient {
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 VideoIntelligenceServiceClient {
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.
@@ -159,16 +159,51 @@ export class VideoIntelligenceServiceClient {
159159
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
160160

161161
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
162-
163162
// This API contains "long-running operations", which return a
164163
// an Operation object that allows for tracking of the operation,
165164
// rather than holding a request open.
166-
165+
const lroOptions: GrpcClientOptions = {
166+
auth: this.auth,
167+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
168+
};
169+
if (opts.fallback === 'rest') {
170+
lroOptions.protoJson = protoFilesRoot;
171+
lroOptions.httpRules = [
172+
{
173+
selector: 'google.longrunning.Operations.CancelOperation',
174+
post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',
175+
body: '*',
176+
additional_bindings: [
177+
{
178+
post: '/v1/operations/{name=projects/*/locations/*/operations/*}:cancel',
179+
},
180+
],
181+
},
182+
{
183+
selector: 'google.longrunning.Operations.DeleteOperation',
184+
delete: '/v1/{name=projects/*/locations/*/operations/*}',
185+
additional_bindings: [
186+
{
187+
delete:
188+
'/v1/operations/{name=projects/*/locations/*/operations/*}',
189+
},
190+
],
191+
},
192+
{
193+
selector: 'google.longrunning.Operations.GetOperation',
194+
get: '/v1/{name=projects/*/locations/*/operations/*}',
195+
additional_bindings: [
196+
{get: '/v1/operations/{name=projects/*/locations/*/operations/*}'},
197+
],
198+
},
199+
{
200+
selector: 'google.longrunning.Operations.ListOperations',
201+
get: '/v1/{name=projects/*/locations/*}/operations',
202+
},
203+
];
204+
}
167205
this.operationsClient = this._gaxModule
168-
.lro({
169-
auth: this.auth,
170-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
171-
})
206+
.lro(lroOptions)
172207
.operationsClient(opts);
173208
const annotateVideoResponse = protoFilesRoot.lookup(
174209
'.google.cloud.videointelligence.v1.AnnotateVideoResponse'

src/v1beta2/video_intelligence_service_client.ts

Lines changed: 49 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 VideoIntelligenceServiceClient {
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 VideoIntelligenceServiceClient {
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.
@@ -159,16 +159,53 @@ export class VideoIntelligenceServiceClient {
159159
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
160160

161161
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
162-
163162
// This API contains "long-running operations", which return a
164163
// an Operation object that allows for tracking of the operation,
165164
// rather than holding a request open.
166-
165+
const lroOptions: GrpcClientOptions = {
166+
auth: this.auth,
167+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
168+
};
169+
if (opts.fallback === 'rest') {
170+
lroOptions.protoJson = protoFilesRoot;
171+
lroOptions.httpRules = [
172+
{
173+
selector: 'google.longrunning.Operations.ListOperations',
174+
get: '/v1beta2/{name=projects/*/locations/*}/operations',
175+
},
176+
{
177+
selector: 'google.longrunning.Operations.GetOperation',
178+
get: '/v1beta2/{name=projects/*/locations/*/operations/*}',
179+
additional_bindings: [
180+
{
181+
get: '/v1beta2/operations/{name=projects/*/locations/*/operations/*}',
182+
},
183+
],
184+
},
185+
{
186+
selector: 'google.longrunning.Operations.DeleteOperation',
187+
delete: '/v1beta2/{name=projects/*/locations/*/operations/*}',
188+
additional_bindings: [
189+
{
190+
delete:
191+
'/v1beta2/operations/{name=projects/*/locations/*/operations/*}',
192+
},
193+
],
194+
},
195+
{
196+
selector: 'google.longrunning.Operations.CancelOperation',
197+
post: '/v1beta2/{name=projects/*/locations/*/operations/*}:cancel',
198+
body: '*',
199+
additional_bindings: [
200+
{
201+
post: '/v1beta2/operations/{name=projects/*/locations/*/operations/*}:cancel',
202+
},
203+
],
204+
},
205+
];
206+
}
167207
this.operationsClient = this._gaxModule
168-
.lro({
169-
auth: this.auth,
170-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
171-
})
208+
.lro(lroOptions)
172209
.operationsClient(opts);
173210
const annotateVideoResponse = protoFilesRoot.lookup(
174211
'.google.cloud.videointelligence.v1beta2.AnnotateVideoResponse'

src/v1p1beta1/video_intelligence_service_client.ts

Lines changed: 49 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 VideoIntelligenceServiceClient {
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 VideoIntelligenceServiceClient {
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.
@@ -159,16 +159,53 @@ export class VideoIntelligenceServiceClient {
159159
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
160160

161161
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
162-
163162
// This API contains "long-running operations", which return a
164163
// an Operation object that allows for tracking of the operation,
165164
// rather than holding a request open.
166-
165+
const lroOptions: GrpcClientOptions = {
166+
auth: this.auth,
167+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
168+
};
169+
if (opts.fallback === 'rest') {
170+
lroOptions.protoJson = protoFilesRoot;
171+
lroOptions.httpRules = [
172+
{
173+
selector: 'google.longrunning.Operations.ListOperations',
174+
get: '/v1p1beta1/{name=projects/*/locations/*}/operations',
175+
},
176+
{
177+
selector: 'google.longrunning.Operations.GetOperation',
178+
get: '/v1p1beta1/{name=projects/*/locations/*/operations/*}',
179+
additional_bindings: [
180+
{
181+
get: '/v1p1beta1/operations/{name=projects/*/locations/*/operations/*}',
182+
},
183+
],
184+
},
185+
{
186+
selector: 'google.longrunning.Operations.DeleteOperation',
187+
delete: '/v1p1beta1/{name=projects/*/locations/*/operations/*}',
188+
additional_bindings: [
189+
{
190+
delete:
191+
'/v1p1beta1/operations/{name=projects/*/locations/*/operations/*}',
192+
},
193+
],
194+
},
195+
{
196+
selector: 'google.longrunning.Operations.CancelOperation',
197+
post: '/v1p1beta1/{name=projects/*/locations/*/operations/*}:cancel',
198+
body: '*',
199+
additional_bindings: [
200+
{
201+
post: '/v1p1beta1/operations/{name=projects/*/locations/*/operations/*}:cancel',
202+
},
203+
],
204+
},
205+
];
206+
}
167207
this.operationsClient = this._gaxModule
168-
.lro({
169-
auth: this.auth,
170-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
171-
})
208+
.lro(lroOptions)
172209
.operationsClient(opts);
173210
const annotateVideoResponse = protoFilesRoot.lookup(
174211
'.google.cloud.videointelligence.v1p1beta1.AnnotateVideoResponse'

src/v1p2beta1/video_intelligence_service_client.ts

Lines changed: 49 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 VideoIntelligenceServiceClient {
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 VideoIntelligenceServiceClient {
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.
@@ -159,16 +159,53 @@ export class VideoIntelligenceServiceClient {
159159
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
160160

161161
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
162-
163162
// This API contains "long-running operations", which return a
164163
// an Operation object that allows for tracking of the operation,
165164
// rather than holding a request open.
166-
165+
const lroOptions: GrpcClientOptions = {
166+
auth: this.auth,
167+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
168+
};
169+
if (opts.fallback === 'rest') {
170+
lroOptions.protoJson = protoFilesRoot;
171+
lroOptions.httpRules = [
172+
{
173+
selector: 'google.longrunning.Operations.ListOperations',
174+
get: '/v1p2beta1/{name=projects/*/locations/*}/operations',
175+
},
176+
{
177+
selector: 'google.longrunning.Operations.GetOperation',
178+
get: '/v1p2beta1/{name=projects/*/locations/*/operations/*}',
179+
additional_bindings: [
180+
{
181+
get: '/v1p2beta1/operations/{name=projects/*/locations/*/operations/*}',
182+
},
183+
],
184+
},
185+
{
186+
selector: 'google.longrunning.Operations.DeleteOperation',
187+
delete: '/v1p2beta1/{name=projects/*/locations/*/operations/*}',
188+
additional_bindings: [
189+
{
190+
delete:
191+
'/v1p2beta1/operations/{name=projects/*/locations/*/operations/*}',
192+
},
193+
],
194+
},
195+
{
196+
selector: 'google.longrunning.Operations.CancelOperation',
197+
post: '/v1p2beta1/{name=projects/*/locations/*/operations/*}:cancel',
198+
body: '*',
199+
additional_bindings: [
200+
{
201+
post: '/v1p2beta1/operations/{name=projects/*/locations/*/operations/*}:cancel',
202+
},
203+
],
204+
},
205+
];
206+
}
167207
this.operationsClient = this._gaxModule
168-
.lro({
169-
auth: this.auth,
170-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
171-
})
208+
.lro(lroOptions)
172209
.operationsClient(opts);
173210
const annotateVideoResponse = protoFilesRoot.lookup(
174211
'.google.cloud.videointelligence.v1p2beta1.AnnotateVideoResponse'

src/v1p3beta1/streaming_video_intelligence_service_client.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class StreamingVideoIntelligenceServiceClient {
6767
*
6868
* @param {object} [options] - The configuration object.
6969
* 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).
70+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7171
* The common options are:
7272
* @param {object} [options.credentials] - Credentials object.
7373
* @param {string} [options.credentials.client_email]
@@ -90,11 +90,10 @@ export class StreamingVideoIntelligenceServiceClient {
9090
* API remote host.
9191
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9292
* 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.
93+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
94+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
95+
* For more information, please check the
96+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
9897
*/
9998
constructor(opts?: ClientOptions) {
10099
// Ensure that options include all the required fields.

0 commit comments

Comments
 (0)