Skip to content

Commit 064efea

Browse files
feat: support regapic LRO (#137)
* 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 6a11f1d commit 064efea

File tree

2 files changed

+166
-24
lines changed

2 files changed

+166
-24
lines changed

packages/google-cloud-managedidentities/src/v1/managed_identities_service_client.ts

Lines changed: 83 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,
@@ -103,7 +104,7 @@ export class ManagedIdentitiesServiceClient {
103104
*
104105
* @param {object} [options] - The configuration object.
105106
* The options accepted by the constructor are described in detail
106-
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
107+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
107108
* The common options are:
108109
* @param {object} [options.credentials] - Credentials object.
109110
* @param {string} [options.credentials.client_email]
@@ -126,11 +127,10 @@ export class ManagedIdentitiesServiceClient {
126127
* API remote host.
127128
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
128129
* Follows the structure of {@link gapicConfig}.
129-
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
130-
* In fallback mode, a special browser-compatible transport implementation is used
131-
* instead of gRPC transport. In browser context (if the `window` object is defined)
132-
* the fallback mode is enabled automatically; set `options.fallback` to `false`
133-
* if you need to override this behavior.
130+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
131+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
132+
* For more information, please check the
133+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
134134
*/
135135
constructor(opts?: ClientOptions) {
136136
// Ensure that options include all the required fields.
@@ -221,16 +221,87 @@ export class ManagedIdentitiesServiceClient {
221221
};
222222

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

packages/google-cloud-managedidentities/src/v1beta1/managed_identities_service_client.ts

Lines changed: 83 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,
@@ -71,7 +72,7 @@ export class ManagedIdentitiesServiceClient {
7172
*
7273
* @param {object} [options] - The configuration object.
7374
* 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).
75+
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
7576
* The common options are:
7677
* @param {object} [options.credentials] - Credentials object.
7778
* @param {string} [options.credentials.client_email]
@@ -94,11 +95,10 @@ export class ManagedIdentitiesServiceClient {
9495
* API remote host.
9596
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
9697
* 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.
98+
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
99+
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
100+
* For more information, please check the
101+
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
102102
*/
103103
constructor(opts?: ClientOptions) {
104104
// Ensure that options include all the required fields.
@@ -189,16 +189,87 @@ export class ManagedIdentitiesServiceClient {
189189
};
190190

191191
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
192-
193192
// This API contains "long-running operations", which return a
194193
// an Operation object that allows for tracking of the operation,
195194
// rather than holding a request open.
196-
195+
const lroOptions: GrpcClientOptions = {
196+
auth: this.auth,
197+
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
198+
};
199+
if (opts.fallback === 'rest') {
200+
lroOptions.protoJson = protoFilesRoot;
201+
lroOptions.httpRules = [
202+
{
203+
selector: 'google.cloud.location.Locations.GetLocation',
204+
get: '/v1beta1/{name=projects/*/locations/*}',
205+
},
206+
{
207+
selector: 'google.cloud.location.Locations.ListLocations',
208+
get: '/v1beta1/{name=projects/*}/locations',
209+
},
210+
{
211+
selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',
212+
get: '/v1beta1/{resource=projects/*/locations/global/domains/*}:getIamPolicy',
213+
additional_bindings: [
214+
{
215+
get: '/v1beta1/{resource=projects/*/locations/global/peerings/*}:getIamPolicy',
216+
},
217+
{
218+
get: '/v1beta1/{resource=projects/*/locations/global/domains/*/backups/*}:getIamPolicy',
219+
},
220+
],
221+
},
222+
{
223+
selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',
224+
post: '/v1beta1/{resource=projects/*/locations/global/domains/*}:setIamPolicy',
225+
body: '*',
226+
additional_bindings: [
227+
{
228+
post: '/v1beta1/{resource=projects/*/locations/global/peerings/*}:setIamPolicy',
229+
body: '*',
230+
},
231+
{
232+
post: '/v1beta1/{resource=projects/*/locations/global/domains/*/backups/*}:setIamPolicy',
233+
body: '*',
234+
},
235+
],
236+
},
237+
{
238+
selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',
239+
post: '/v1beta1/{resource=projects/*/locations/global/domains/*}:testIamPermissions',
240+
body: '*',
241+
additional_bindings: [
242+
{
243+
post: '/v1beta1/{resource=projects/*/locations/global/peerings/*}:testIamPermissions',
244+
body: '*',
245+
},
246+
{
247+
post: '/v1beta1/{resource=projects/*/locations/global/domains/*/backups/*}:testIamPermissions',
248+
body: '*',
249+
},
250+
],
251+
},
252+
{
253+
selector: 'google.longrunning.Operations.CancelOperation',
254+
post: '/v1beta1/{name=projects/*/locations/global/operations/*}:cancel',
255+
body: '*',
256+
},
257+
{
258+
selector: 'google.longrunning.Operations.DeleteOperation',
259+
delete: '/v1beta1/{name=projects/*/locations/global/operations/*}',
260+
},
261+
{
262+
selector: 'google.longrunning.Operations.GetOperation',
263+
get: '/v1beta1/{name=projects/*/locations/global/operations/*}',
264+
},
265+
{
266+
selector: 'google.longrunning.Operations.ListOperations',
267+
get: '/v1beta1/{name=projects/*/locations/global/operations}',
268+
},
269+
];
270+
}
197271
this.operationsClient = this._gaxModule
198-
.lro({
199-
auth: this.auth,
200-
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
201-
})
272+
.lro(lroOptions)
202273
.operationsClient(opts);
203274
const createMicrosoftAdDomainResponse = protoFilesRoot.lookup(
204275
'.google.cloud.managedidentities.v1beta1.Domain'

0 commit comments

Comments
 (0)