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

Commit 2b2f553

Browse files
feat: support regapic LRO (#187)
* 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 909cae4 commit 2b2f553

File tree

2 files changed

+98
-24
lines changed

2 files changed

+98
-24
lines changed

src/v1/certificate_authority_service_client.ts

+83-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,
@@ -79,7 +80,7 @@ export class CertificateAuthorityServiceClient {
7980
*
8081
* @param {object} [options] - The configuration object.
8182
* The options accepted by the constructor are described in detail
82-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
83+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
8384
* The common options are:
8485
* @param {object} [options.credentials] - Credentials object.
8586
* @param {string} [options.credentials.client_email]
@@ -102,11 +103,10 @@ export class CertificateAuthorityServiceClient {
102103
* API remote host.
103104
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
104105
* Follows the structure of {@link gapicConfig}.
105-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
106-
* In fallback mode, a special browser-compatible transport implementation is used
107-
* instead of gRPC transport. In browser context (if the `window` object is defined)
108-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
109-
* if you need to override this behavior.
106+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
107+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
108+
* For more information, please check the
109+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
110110
*/
111111
constructor(opts?: ClientOptions) {
112112
// Ensure that options include all the required fields.
@@ -229,16 +229,87 @@ export class CertificateAuthorityServiceClient {
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/*/caPools/*}:getIamPolicy',
253+
additional_bindings: [
254+
{
255+
get: '/v1/{resource=projects/*/locations/*/certificateTemplates/*}:getIamPolicy',
256+
},
257+
{
258+
get: '/v1/{resource=projects/*/locations/*/caPools/*/certificateAuthorities/*/certificateRevocationLists/*}:getIamPolicy',
259+
},
260+
],
261+
},
262+
{
263+
selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',
264+
post: '/v1/{resource=projects/*/locations/*/caPools/*}:setIamPolicy',
265+
body: '*',
266+
additional_bindings: [
267+
{
268+
post: '/v1/{resource=projects/*/locations/*/certificateTemplates/*}:setIamPolicy',
269+
body: '*',
270+
},
271+
{
272+
post: '/v1/{resource=projects/*/locations/*/caPools/*/certificateAuthorities/*/certificateRevocationLists/*}:setIamPolicy',
273+
body: '*',
274+
},
275+
],
276+
},
277+
{
278+
selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',
279+
post: '/v1/{resource=projects/*/locations/*/caPools/*}:testIamPermissions',
280+
body: '*',
281+
additional_bindings: [
282+
{
283+
post: '/v1/{resource=projects/*/locations/*/certificateTemplates/*}:testIamPermissions',
284+
body: '*',
285+
},
286+
{
287+
post: '/v1/{resource=projects/*/locations/*/caPools/*/certificateAuthorities/*/certificateRevocationLists/*}:testIamPermissions',
288+
body: '*',
289+
},
290+
],
291+
},
292+
{
293+
selector: 'google.longrunning.Operations.CancelOperation',
294+
post: '/v1/{name=projects/*/locations/*/operations/*}:cancel',
295+
body: '*',
296+
},
297+
{
298+
selector: 'google.longrunning.Operations.DeleteOperation',
299+
delete: '/v1/{name=projects/*/locations/*/operations/*}',
300+
},
301+
{
302+
selector: 'google.longrunning.Operations.GetOperation',
303+
get: '/v1/{name=projects/*/locations/*/operations/*}',
304+
},
305+
{
306+
selector: 'google.longrunning.Operations.ListOperations',
307+
get: '/v1/{name=projects/*/locations/*}/operations',
308+
},
309+
];
310+
}
237311
this.operationsClient = this._gaxModule
238-
.lro({
239-
auth: this.auth,
240-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
241-
})
312+
.lro(lroOptions)
242313
.operationsClient(opts);
243314
const activateCertificateAuthorityResponse = protoFilesRoot.lookup(
244315
'.google.cloud.security.privateca.v1.CertificateAuthority'

src/v1beta1/certificate_authority_service_client.ts

+15-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 CertificateAuthorityServiceClient {
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 CertificateAuthorityServiceClient {
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.
@@ -212,16 +212,19 @@ export class CertificateAuthorityServiceClient {
212212
};
213213

214214
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
215-
216215
// This API contains "long-running operations", which return a
217216
// an Operation object that allows for tracking of the operation,
218217
// rather than holding a request open.
219-
218+
const lroOptions: GrpcClientOptions = {
219+
auth: this.auth,
220+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
221+
};
222+
if (opts.fallback === 'rest') {
223+
lroOptions.protoJson = protoFilesRoot;
224+
lroOptions.httpRules = [];
225+
}
220226
this.operationsClient = this._gaxModule
221-
.lro({
222-
auth: this.auth,
223-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
224-
})
227+
.lro(lroOptions)
225228
.operationsClient(opts);
226229
const activateCertificateAuthorityResponse = protoFilesRoot.lookup(
227230
'.google.cloud.security.privateca.v1beta1.CertificateAuthority'

0 commit comments

Comments
 (0)