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

Commit 350626e

Browse files
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 PiperOrigin-RevId: 458552034 Source-Link: googleapis/googleapis@ae65014 Source-Link: https://github.com/googleapis/googleapis-gen/commit/b09ede435cce110446d4ab9f62a081b571d37e3f Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjA5ZWRlNDM1Y2NlMTEwNDQ2ZDRhYjlmNjJhMDgxYjU3MWQzN2UzZiJ9 Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Benjamin E. Coe <[email protected]>
1 parent 58abc39 commit 350626e

5 files changed

+505
-54
lines changed

src/v1/autoscaling_policy_service_client.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class AutoscalingPolicyServiceClient {
7171
*
7272
* @param {object} [options] - The configuration object.
7373
* The options accepted by the constructor are described in detail
74-
* 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).
7575
* The common options are:
7676
* @param {object} [options.credentials] - Credentials object.
7777
* @param {string} [options.credentials.client_email]
@@ -94,11 +94,10 @@ export class AutoscalingPolicyServiceClient {
9494
* API remote host.
9595
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9696
* Follows the structure of {@link gapicConfig}.
97-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
98-
* In fallback mode, a special browser-compatible transport implementation is used
99-
* instead of gRPC transport. In browser context (if the `window` object is defined)
100-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
101-
* 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}.
102101
*/
103102
constructor(opts?: ClientOptions) {
104103
// Ensure that options include all the required fields.

src/v1/batch_controller_client.ts

+125-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 BatchControllerClient {
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 BatchControllerClient {
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.
@@ -205,16 +205,129 @@ export class BatchControllerClient {
205205
};
206206

207207
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
208-
209208
// This API contains "long-running operations", which return a
210209
// an Operation object that allows for tracking of the operation,
211210
// rather than holding a request open.
212-
211+
const lroOptions: GrpcClientOptions = {
212+
auth: this.auth,
213+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
214+
};
215+
if (opts.fallback === 'rest') {
216+
lroOptions.protoJson = protoFilesRoot;
217+
lroOptions.httpRules = [
218+
{
219+
selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',
220+
post: '/v1/{resource=projects/*/regions/*/clusters/*}:getIamPolicy',
221+
body: '*',
222+
additional_bindings: [
223+
{
224+
post: '/v1/{resource=projects/*/regions/*/jobs/*}:getIamPolicy',
225+
body: '*',
226+
},
227+
{
228+
post: '/v1/{resource=projects/*/regions/*/operations/*}:getIamPolicy',
229+
body: '*',
230+
},
231+
{
232+
post: '/v1/{resource=projects/*/regions/*/workflowTemplates/*}:getIamPolicy',
233+
body: '*',
234+
},
235+
{
236+
post: '/v1/{resource=projects/*/locations/*/workflowTemplates/*}:getIamPolicy',
237+
body: '*',
238+
},
239+
{
240+
post: '/v1/{resource=projects/*/regions/*/autoscalingPolicies/*}:getIamPolicy',
241+
body: '*',
242+
},
243+
{
244+
post: '/v1/{resource=projects/*/locations/*/autoscalingPolicies/*}:getIamPolicy',
245+
body: '*',
246+
},
247+
],
248+
},
249+
{
250+
selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',
251+
post: '/v1/{resource=projects/*/regions/*/clusters/*}:setIamPolicy',
252+
body: '*',
253+
additional_bindings: [
254+
{
255+
post: '/v1/{resource=projects/*/regions/*/jobs/*}:setIamPolicy',
256+
body: '*',
257+
},
258+
{
259+
post: '/v1/{resource=projects/*/regions/*/operations/*}:setIamPolicy',
260+
body: '*',
261+
},
262+
{
263+
post: '/v1/{resource=projects/*/regions/*/workflowTemplates/*}:setIamPolicy',
264+
body: '*',
265+
},
266+
{
267+
post: '/v1/{resource=projects/*/locations/*/workflowTemplates/*}:setIamPolicy',
268+
body: '*',
269+
},
270+
{
271+
post: '/v1/{resource=projects/*/regions/*/autoscalingPolicies/*}:setIamPolicy',
272+
body: '*',
273+
},
274+
{
275+
post: '/v1/{resource=projects/*/locations/*/autoscalingPolicies/*}:setIamPolicy',
276+
body: '*',
277+
},
278+
],
279+
},
280+
{
281+
selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',
282+
post: '/v1/{resource=projects/*/regions/*/clusters/*}:testIamPermissions',
283+
body: '*',
284+
additional_bindings: [
285+
{
286+
post: '/v1/{resource=projects/*/regions/*/jobs/*}:testIamPermissions',
287+
body: '*',
288+
},
289+
{
290+
post: '/v1/{resource=projects/*/regions/*/operations/*}:testIamPermissions',
291+
body: '*',
292+
},
293+
{
294+
post: '/v1/{resource=projects/*/regions/*/workflowTemplates/*}:testIamPermissions',
295+
body: '*',
296+
},
297+
{
298+
post: '/v1/{resource=projects/*/locations/*/workflowTemplates/*}:testIamPermissions',
299+
body: '*',
300+
},
301+
{
302+
post: '/v1/{resource=projects/*/regions/*/autoscalingPolicies/*}:testIamPermissions',
303+
body: '*',
304+
},
305+
{
306+
post: '/v1/{resource=projects/*/locations/*/autoscalingPolicies/*}:testIamPermissions',
307+
body: '*',
308+
},
309+
],
310+
},
311+
{
312+
selector: 'google.longrunning.Operations.CancelOperation',
313+
post: '/v1/{name=projects/*/regions/*/operations/*}:cancel',
314+
},
315+
{
316+
selector: 'google.longrunning.Operations.DeleteOperation',
317+
delete: '/v1/{name=projects/*/regions/*/operations/*}',
318+
},
319+
{
320+
selector: 'google.longrunning.Operations.GetOperation',
321+
get: '/v1/{name=projects/*/regions/*/operations/*}',
322+
},
323+
{
324+
selector: 'google.longrunning.Operations.ListOperations',
325+
get: '/v1/{name=projects/*/regions/*/operations}',
326+
},
327+
];
328+
}
213329
this.operationsClient = this._gaxModule
214-
.lro({
215-
auth: this.auth,
216-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
217-
})
330+
.lro(lroOptions)
218331
.operationsClient(opts);
219332
const createBatchResponse = protoFilesRoot.lookup(
220333
'.google.cloud.dataproc.v1.Batch'

src/v1/cluster_controller_client.ts

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

205205
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
206-
207206
// This API contains "long-running operations", which return a
208207
// an Operation object that allows for tracking of the operation,
209208
// rather than holding a request open.
210-
209+
const lroOptions: GrpcClientOptions = {
210+
auth: this.auth,
211+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
212+
};
213+
if (opts.fallback === 'rest') {
214+
lroOptions.protoJson = protoFilesRoot;
215+
lroOptions.httpRules = [
216+
{
217+
selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',
218+
post: '/v1/{resource=projects/*/regions/*/clusters/*}:getIamPolicy',
219+
body: '*',
220+
additional_bindings: [
221+
{
222+
post: '/v1/{resource=projects/*/regions/*/jobs/*}:getIamPolicy',
223+
body: '*',
224+
},
225+
{
226+
post: '/v1/{resource=projects/*/regions/*/operations/*}:getIamPolicy',
227+
body: '*',
228+
},
229+
{
230+
post: '/v1/{resource=projects/*/regions/*/workflowTemplates/*}:getIamPolicy',
231+
body: '*',
232+
},
233+
{
234+
post: '/v1/{resource=projects/*/locations/*/workflowTemplates/*}:getIamPolicy',
235+
body: '*',
236+
},
237+
{
238+
post: '/v1/{resource=projects/*/regions/*/autoscalingPolicies/*}:getIamPolicy',
239+
body: '*',
240+
},
241+
{
242+
post: '/v1/{resource=projects/*/locations/*/autoscalingPolicies/*}:getIamPolicy',
243+
body: '*',
244+
},
245+
],
246+
},
247+
{
248+
selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',
249+
post: '/v1/{resource=projects/*/regions/*/clusters/*}:setIamPolicy',
250+
body: '*',
251+
additional_bindings: [
252+
{
253+
post: '/v1/{resource=projects/*/regions/*/jobs/*}:setIamPolicy',
254+
body: '*',
255+
},
256+
{
257+
post: '/v1/{resource=projects/*/regions/*/operations/*}:setIamPolicy',
258+
body: '*',
259+
},
260+
{
261+
post: '/v1/{resource=projects/*/regions/*/workflowTemplates/*}:setIamPolicy',
262+
body: '*',
263+
},
264+
{
265+
post: '/v1/{resource=projects/*/locations/*/workflowTemplates/*}:setIamPolicy',
266+
body: '*',
267+
},
268+
{
269+
post: '/v1/{resource=projects/*/regions/*/autoscalingPolicies/*}:setIamPolicy',
270+
body: '*',
271+
},
272+
{
273+
post: '/v1/{resource=projects/*/locations/*/autoscalingPolicies/*}:setIamPolicy',
274+
body: '*',
275+
},
276+
],
277+
},
278+
{
279+
selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',
280+
post: '/v1/{resource=projects/*/regions/*/clusters/*}:testIamPermissions',
281+
body: '*',
282+
additional_bindings: [
283+
{
284+
post: '/v1/{resource=projects/*/regions/*/jobs/*}:testIamPermissions',
285+
body: '*',
286+
},
287+
{
288+
post: '/v1/{resource=projects/*/regions/*/operations/*}:testIamPermissions',
289+
body: '*',
290+
},
291+
{
292+
post: '/v1/{resource=projects/*/regions/*/workflowTemplates/*}:testIamPermissions',
293+
body: '*',
294+
},
295+
{
296+
post: '/v1/{resource=projects/*/locations/*/workflowTemplates/*}:testIamPermissions',
297+
body: '*',
298+
},
299+
{
300+
post: '/v1/{resource=projects/*/regions/*/autoscalingPolicies/*}:testIamPermissions',
301+
body: '*',
302+
},
303+
{
304+
post: '/v1/{resource=projects/*/locations/*/autoscalingPolicies/*}:testIamPermissions',
305+
body: '*',
306+
},
307+
],
308+
},
309+
{
310+
selector: 'google.longrunning.Operations.CancelOperation',
311+
post: '/v1/{name=projects/*/regions/*/operations/*}:cancel',
312+
},
313+
{
314+
selector: 'google.longrunning.Operations.DeleteOperation',
315+
delete: '/v1/{name=projects/*/regions/*/operations/*}',
316+
},
317+
{
318+
selector: 'google.longrunning.Operations.GetOperation',
319+
get: '/v1/{name=projects/*/regions/*/operations/*}',
320+
},
321+
{
322+
selector: 'google.longrunning.Operations.ListOperations',
323+
get: '/v1/{name=projects/*/regions/*/operations}',
324+
},
325+
];
326+
}
211327
this.operationsClient = this._gaxModule
212-
.lro({
213-
auth: this.auth,
214-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
215-
})
328+
.lro(lroOptions)
216329
.operationsClient(opts);
217330
const createClusterResponse = protoFilesRoot.lookup(
218331
'.google.cloud.dataproc.v1.Cluster'

0 commit comments

Comments
 (0)