Skip to content

Commit b1a7c38

Browse files
feat: support regapic LRO (#962)
* 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 7906019 commit b1a7c38

32 files changed

+650
-264
lines changed

packages/google-cloud-dialogflow/src/v2/agents_client.ts

+45-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 AgentsClient {
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 AgentsClient {
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.
@@ -320,16 +320,49 @@ export class AgentsClient {
320320
};
321321

322322
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
323-
324323
// This API contains "long-running operations", which return a
325324
// an Operation object that allows for tracking of the operation,
326325
// rather than holding a request open.
327-
326+
const lroOptions: GrpcClientOptions = {
327+
auth: this.auth,
328+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
329+
};
330+
if (opts.fallback === 'rest') {
331+
lroOptions.protoJson = protoFilesRoot;
332+
lroOptions.httpRules = [
333+
{
334+
selector: 'google.cloud.location.Locations.GetLocation',
335+
get: '/v2/{name=projects/*/locations/*}',
336+
},
337+
{
338+
selector: 'google.cloud.location.Locations.ListLocations',
339+
get: '/v2/{name=projects/*}/locations',
340+
},
341+
{
342+
selector: 'google.longrunning.Operations.CancelOperation',
343+
post: '/v2/{name=projects/*/operations/*}:cancel',
344+
additional_bindings: [
345+
{post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'},
346+
],
347+
},
348+
{
349+
selector: 'google.longrunning.Operations.GetOperation',
350+
get: '/v2/{name=projects/*/operations/*}',
351+
additional_bindings: [
352+
{get: '/v2/{name=projects/*/locations/*/operations/*}'},
353+
],
354+
},
355+
{
356+
selector: 'google.longrunning.Operations.ListOperations',
357+
get: '/v2/{name=projects/*}/operations',
358+
additional_bindings: [
359+
{get: '/v2/{name=projects/*/locations/*}/operations'},
360+
],
361+
},
362+
];
363+
}
328364
this.operationsClient = this._gaxModule
329-
.lro({
330-
auth: this.auth,
331-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
332-
})
365+
.lro(lroOptions)
333366
.operationsClient(opts);
334367
const trainAgentResponse = protoFilesRoot.lookup(
335368
'.google.protobuf.Empty'

packages/google-cloud-dialogflow/src/v2/answer_records_client.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class AnswerRecordsClient {
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 AnswerRecordsClient {
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-dialogflow/src/v2/contexts_client.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class ContextsClient {
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 ContextsClient {
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-dialogflow/src/v2/conversation_datasets_client.ts

+45-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,
@@ -75,7 +76,7 @@ export class ConversationDatasetsClient {
7576
*
7677
* @param {object} [options] - The configuration object.
7778
* The options accepted by the constructor are described in detail
78-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
79+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7980
* The common options are:
8081
* @param {object} [options.credentials] - Credentials object.
8182
* @param {string} [options.credentials.client_email]
@@ -98,11 +99,10 @@ export class ConversationDatasetsClient {
9899
* API remote host.
99100
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
100101
* Follows the structure of {@link gapicConfig}.
101-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
102-
* In fallback mode, a special browser-compatible transport implementation is used
103-
* instead of gRPC transport. In browser context (if the `window` object is defined)
104-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
105-
* if you need to override this behavior.
102+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
103+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
104+
* For more information, please check the
105+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
106106
*/
107107
constructor(opts?: ClientOptions) {
108108
// Ensure that options include all the required fields.
@@ -326,16 +326,49 @@ export class ConversationDatasetsClient {
326326
};
327327

328328
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
329-
330329
// This API contains "long-running operations", which return a
331330
// an Operation object that allows for tracking of the operation,
332331
// rather than holding a request open.
333-
332+
const lroOptions: GrpcClientOptions = {
333+
auth: this.auth,
334+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
335+
};
336+
if (opts.fallback === 'rest') {
337+
lroOptions.protoJson = protoFilesRoot;
338+
lroOptions.httpRules = [
339+
{
340+
selector: 'google.cloud.location.Locations.GetLocation',
341+
get: '/v2/{name=projects/*/locations/*}',
342+
},
343+
{
344+
selector: 'google.cloud.location.Locations.ListLocations',
345+
get: '/v2/{name=projects/*}/locations',
346+
},
347+
{
348+
selector: 'google.longrunning.Operations.CancelOperation',
349+
post: '/v2/{name=projects/*/operations/*}:cancel',
350+
additional_bindings: [
351+
{post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'},
352+
],
353+
},
354+
{
355+
selector: 'google.longrunning.Operations.GetOperation',
356+
get: '/v2/{name=projects/*/operations/*}',
357+
additional_bindings: [
358+
{get: '/v2/{name=projects/*/locations/*/operations/*}'},
359+
],
360+
},
361+
{
362+
selector: 'google.longrunning.Operations.ListOperations',
363+
get: '/v2/{name=projects/*}/operations',
364+
additional_bindings: [
365+
{get: '/v2/{name=projects/*/locations/*}/operations'},
366+
],
367+
},
368+
];
369+
}
334370
this.operationsClient = this._gaxModule
335-
.lro({
336-
auth: this.auth,
337-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
338-
})
371+
.lro(lroOptions)
339372
.operationsClient(opts);
340373
const createConversationDatasetResponse = protoFilesRoot.lookup(
341374
'.google.cloud.dialogflow.v2.ConversationDataset'

packages/google-cloud-dialogflow/src/v2/conversation_models_client.ts

+45-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 ConversationModelsClient {
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 ConversationModelsClient {
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.
@@ -325,16 +325,49 @@ export class ConversationModelsClient {
325325
};
326326

327327
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
328-
329328
// This API contains "long-running operations", which return a
330329
// an Operation object that allows for tracking of the operation,
331330
// rather than holding a request open.
332-
331+
const lroOptions: GrpcClientOptions = {
332+
auth: this.auth,
333+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
334+
};
335+
if (opts.fallback === 'rest') {
336+
lroOptions.protoJson = protoFilesRoot;
337+
lroOptions.httpRules = [
338+
{
339+
selector: 'google.cloud.location.Locations.GetLocation',
340+
get: '/v2/{name=projects/*/locations/*}',
341+
},
342+
{
343+
selector: 'google.cloud.location.Locations.ListLocations',
344+
get: '/v2/{name=projects/*}/locations',
345+
},
346+
{
347+
selector: 'google.longrunning.Operations.CancelOperation',
348+
post: '/v2/{name=projects/*/operations/*}:cancel',
349+
additional_bindings: [
350+
{post: '/v2/{name=projects/*/locations/*/operations/*}:cancel'},
351+
],
352+
},
353+
{
354+
selector: 'google.longrunning.Operations.GetOperation',
355+
get: '/v2/{name=projects/*/operations/*}',
356+
additional_bindings: [
357+
{get: '/v2/{name=projects/*/locations/*/operations/*}'},
358+
],
359+
},
360+
{
361+
selector: 'google.longrunning.Operations.ListOperations',
362+
get: '/v2/{name=projects/*}/operations',
363+
additional_bindings: [
364+
{get: '/v2/{name=projects/*/locations/*}/operations'},
365+
],
366+
},
367+
];
368+
}
333369
this.operationsClient = this._gaxModule
334-
.lro({
335-
auth: this.auth,
336-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
337-
})
370+
.lro(lroOptions)
338371
.operationsClient(opts);
339372
const createConversationModelResponse = protoFilesRoot.lookup(
340373
'.google.cloud.dialogflow.v2.ConversationModel'

0 commit comments

Comments
 (0)