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

Commit 5c7ba12

Browse files
feat: support regapic LRO (#55)
* 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 6a0a863 commit 5c7ba12

1 file changed

Lines changed: 72 additions & 12 deletions

File tree

src/v1/cloud_deploy_client.ts

Lines changed: 72 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,
@@ -73,7 +74,7 @@ export class CloudDeployClient {
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 CloudDeployClient {
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.
@@ -229,16 +229,76 @@ export class CloudDeployClient {
229229
};
230230

231231
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
232-
233232
// This API contains "long-running operations", which return a
234233
// an Operation object that allows for tracking of the operation,
235234
// rather than holding a request open.
236-
235+
const lroOptions: GrpcClientOptions = {
236+
auth: this.auth,
237+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
238+
};
239+
if (opts.fallback === 'rest') {
240+
lroOptions.protoJson = protoFilesRoot;
241+
lroOptions.httpRules = [
242+
{
243+
selector: 'google.cloud.location.Locations.GetLocation',
244+
get: '/v1/{name=projects/*/locations/*}',
245+
},
246+
{
247+
selector: 'google.cloud.location.Locations.ListLocations',
248+
get: '/v1/{name=projects/*}/locations',
249+
},
250+
{
251+
selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',
252+
get: '/v1/{resource=projects/*/locations/*/deliveryPipelines/*}:getIamPolicy',
253+
additional_bindings: [
254+
{
255+
get: '/v1/{resource=projects/*/locations/*/targets/*}:getIamPolicy',
256+
},
257+
],
258+
},
259+
{
260+
selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',
261+
post: '/v1/{resource=projects/*/locations/*/deliveryPipelines/*}:setIamPolicy',
262+
body: '*',
263+
additional_bindings: [
264+
{
265+
post: '/v1/{resource=projects/*/locations/*/targets/*}:setIamPolicy',
266+
body: '*',
267+
},
268+
],
269+
},
270+
{
271+
selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',
272+
post: '/v1/{resource=projects/*/locations/*/deliveryPipelines/*}:testIamPermissions',
273+
body: '*',
274+
additional_bindings: [
275+
{
276+
post: '/v1/{resource=projects/*/locations/*/targets/*}:testIamPermissions',
277+
body: '*',
278+
},
279+
],
280+
},
281+
{
282+
selector: 'google.longrunning.Operations.CancelOperation',
283+
post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',
284+
body: '*',
285+
},
286+
{
287+
selector: 'google.longrunning.Operations.DeleteOperation',
288+
delete: '/v1/{name=projects/*/locations/*/operations/*}',
289+
},
290+
{
291+
selector: 'google.longrunning.Operations.GetOperation',
292+
get: '/v1/{name=projects/*/locations/*/operations/*}',
293+
},
294+
{
295+
selector: 'google.longrunning.Operations.ListOperations',
296+
get: '/v1/{name=projects/*/locations/*}/operations',
297+
},
298+
];
299+
}
237300
this.operationsClient = this._gaxModule
238-
.lro({
239-
auth: this.auth,
240-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
241-
})
301+
.lro(lroOptions)
242302
.operationsClient(opts);
243303
const createDeliveryPipelineResponse = protoFilesRoot.lookup(
244304
'.google.cloud.deploy.v1.DeliveryPipeline'

0 commit comments

Comments
 (0)