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

Commit 31164e2

Browse files
feat: support regapic LRO (#87)
* feat: support regapic LRO Use gapic-generator-typescript v2.15.1. PiperOrigin-RevId: 456946341 Source-Link: googleapis/googleapis@88fd18d Source-Link: https://github.com/googleapis/googleapis-gen/commit/accfa371f667439313335c64042b063c1c53102e 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 0561fd9 commit 31164e2

2 files changed

Lines changed: 106 additions & 24 deletions

File tree

src/v1/tpu_client.ts

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

209209
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
210-
211210
// This API contains "long-running operations", which return a
212211
// an Operation object that allows for tracking of the operation,
213212
// rather than holding a request open.
214-
213+
const lroOptions: GrpcClientOptions = {
214+
auth: this.auth,
215+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
216+
};
217+
if (opts.fallback === 'rest') {
218+
lroOptions.protoJson = protoFilesRoot;
219+
lroOptions.httpRules = [
220+
{
221+
selector: 'google.cloud.location.Locations.GetLocation',
222+
get: '/v1/{name=projects/*/locations/*}',
223+
},
224+
{
225+
selector: 'google.cloud.location.Locations.ListLocations',
226+
get: '/v1/{name=projects/*}/locations',
227+
},
228+
{
229+
selector: 'google.longrunning.Operations.CancelOperation',
230+
post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',
231+
},
232+
{
233+
selector: 'google.longrunning.Operations.DeleteOperation',
234+
delete: '/v1/{name=projects/*/locations/*/operations/*}',
235+
},
236+
{
237+
selector: 'google.longrunning.Operations.GetOperation',
238+
get: '/v1/{name=projects/*/locations/*/operations/*}',
239+
},
240+
{
241+
selector: 'google.longrunning.Operations.ListOperations',
242+
get: '/v1/{name=projects/*/locations/*}/operations',
243+
},
244+
];
245+
}
215246
this.operationsClient = this._gaxModule
216-
.lro({
217-
auth: this.auth,
218-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
219-
})
247+
.lro(lroOptions)
220248
.operationsClient(opts);
221249
const createNodeResponse = protoFilesRoot.lookup(
222250
'.google.cloud.tpu.v1.Node'

src/v2alpha1/tpu_client.ts

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

206206
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
207-
208207
// This API contains "long-running operations", which return a
209208
// an Operation object that allows for tracking of the operation,
210209
// rather than holding a request open.
211-
210+
const lroOptions: GrpcClientOptions = {
211+
auth: this.auth,
212+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
213+
};
214+
if (opts.fallback === 'rest') {
215+
lroOptions.protoJson = protoFilesRoot;
216+
lroOptions.httpRules = [
217+
{
218+
selector: 'google.cloud.location.Locations.GetLocation',
219+
get: '/v1alpha1/{name=projects/*/locations/*}',
220+
additional_bindings: [
221+
{get: '/v1/{name=projects/*/locations/*}'},
222+
{get: '/v2alpha1/{name=projects/*/locations/*}'},
223+
],
224+
},
225+
{
226+
selector: 'google.cloud.location.Locations.ListLocations',
227+
get: '/v1alpha1/{name=projects/*}/locations',
228+
additional_bindings: [
229+
{get: '/v1/{name=projects/*}/locations'},
230+
{get: '/v2alpha1/{name=projects/*}/locations'},
231+
],
232+
},
233+
{
234+
selector: 'google.longrunning.Operations.CancelOperation',
235+
post: '/v1alpha1/{name=projects/*/locations/*/operations/*}:cancel',
236+
additional_bindings: [
237+
{post: '/v1/{name=projects/*/locations/*/operations/*}:cancel'},
238+
{
239+
post: '/v2alpha1/{name=projects/*/locations/*/operations/*}:cancel',
240+
},
241+
],
242+
},
243+
{
244+
selector: 'google.longrunning.Operations.DeleteOperation',
245+
delete: '/v1alpha1/{name=projects/*/locations/*/operations/*}',
246+
additional_bindings: [
247+
{delete: '/v1/{name=projects/*/locations/*/operations/*}'},
248+
{delete: '/v2alpha1/{name=projects/*/locations/*/operations/*}'},
249+
],
250+
},
251+
{
252+
selector: 'google.longrunning.Operations.GetOperation',
253+
get: '/v1alpha1/{name=projects/*/locations/*/operations/*}',
254+
additional_bindings: [
255+
{get: '/v1/{name=projects/*/locations/*/operations/*}'},
256+
{get: '/v2alpha1/{name=projects/*/locations/*/operations/*}'},
257+
],
258+
},
259+
{
260+
selector: 'google.longrunning.Operations.ListOperations',
261+
get: '/v1alpha1/{name=projects/*/locations/*}/operations',
262+
additional_bindings: [
263+
{get: '/v1/{name=projects/*/locations/*}/operations'},
264+
{get: '/v2alpha1/{name=projects/*/locations/*}/operations'},
265+
],
266+
},
267+
];
268+
}
212269
this.operationsClient = this._gaxModule
213-
.lro({
214-
auth: this.auth,
215-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
216-
})
270+
.lro(lroOptions)
217271
.operationsClient(opts);
218272
const createNodeResponse = protoFilesRoot.lookup(
219273
'.google.cloud.tpu.v2alpha1.Node'

0 commit comments

Comments
 (0)