Skip to content

Commit 99778fb

Browse files
feat: support regapic LRO (#957)
* 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 d7a84e4 commit 99778fb

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

src/v1/datastore_admin_client.ts

Lines changed: 32 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,
@@ -131,7 +132,7 @@ export class DatastoreAdminClient {
131132
*
132133
* @param {object} [options] - The configuration object.
133134
* The options accepted by the constructor are described in detail
134-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
135+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
135136
* The common options are:
136137
* @param {object} [options.credentials] - Credentials object.
137138
* @param {string} [options.credentials.client_email]
@@ -154,11 +155,10 @@ export class DatastoreAdminClient {
154155
* API remote host.
155156
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
156157
* Follows the structure of {@link gapicConfig}.
157-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
158-
* In fallback mode, a special browser-compatible transport implementation is used
159-
* instead of gRPC transport. In browser context (if the `window` object is defined)
160-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
161-
* if you need to override this behavior.
158+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
159+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
160+
* For more information, please check the
161+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
162162
*/
163163
constructor(opts?: ClientOptions) {
164164
// Ensure that options include all the required fields.
@@ -233,16 +233,36 @@ export class DatastoreAdminClient {
233233
};
234234

235235
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
236-
237236
// This API contains "long-running operations", which return a
238237
// an Operation object that allows for tracking of the operation,
239238
// rather than holding a request open.
240-
239+
const lroOptions: GrpcClientOptions = {
240+
auth: this.auth,
241+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
242+
};
243+
if (opts.fallback === 'rest') {
244+
lroOptions.protoJson = protoFilesRoot;
245+
lroOptions.httpRules = [
246+
{
247+
selector: 'google.longrunning.Operations.CancelOperation',
248+
post: '/v1/{name=projects/*/operations/*}:cancel',
249+
},
250+
{
251+
selector: 'google.longrunning.Operations.DeleteOperation',
252+
delete: '/v1/{name=projects/*/operations/*}',
253+
},
254+
{
255+
selector: 'google.longrunning.Operations.GetOperation',
256+
get: '/v1/{name=projects/*/operations/*}',
257+
},
258+
{
259+
selector: 'google.longrunning.Operations.ListOperations',
260+
get: '/v1/{name=projects/*}/operations',
261+
},
262+
];
263+
}
241264
this.operationsClient = this._gaxModule
242-
.lro({
243-
auth: this.auth,
244-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
245-
})
265+
.lro(lroOptions)
246266
.operationsClient(opts);
247267
const exportEntitiesResponse = protoFilesRoot.lookup(
248268
'.google.datastore.admin.v1.ExportEntitiesResponse'

src/v1/datastore_client.ts

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

0 commit comments

Comments
 (0)