Skip to content

Commit

Permalink
feat: support regapic LRO (#137)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Jun 30, 2022
1 parent 6a11f1d commit 064efea
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
CallOptions,
Descriptors,
ClientOptions,
GrpcClientOptions,
LROperation,
PaginationCallback,
GaxCall,
Expand Down Expand Up @@ -103,7 +104,7 @@ export class ManagedIdentitiesServiceClient {
*
* @param {object} [options] - The configuration object.
* The options accepted by the constructor are described in detail
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
* The common options are:
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
Expand All @@ -126,11 +127,10 @@ export class ManagedIdentitiesServiceClient {
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
* In fallback mode, a special browser-compatible transport implementation is used
* instead of gRPC transport. In browser context (if the `window` object is defined)
* the fallback mode is enabled automatically; set `options.fallback` to `false`
* if you need to override this behavior.
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
* For more information, please check the
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
*/
constructor(opts?: ClientOptions) {
// Ensure that options include all the required fields.
Expand Down Expand Up @@ -221,16 +221,87 @@ export class ManagedIdentitiesServiceClient {
};

const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);

// This API contains "long-running operations", which return a
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.

const lroOptions: GrpcClientOptions = {
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
};
if (opts.fallback === 'rest') {
lroOptions.protoJson = protoFilesRoot;
lroOptions.httpRules = [
{
selector: 'google.cloud.location.Locations.GetLocation',
get: '/v1/{name=projects/*/locations/*}',
},
{
selector: 'google.cloud.location.Locations.ListLocations',
get: '/v1/{name=projects/*}/locations',
},
{
selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',
get: '/v1/{resource=projects/*/locations/global/domains/*}:getIamPolicy',
additional_bindings: [
{
get: '/v1/{resource=projects/*/locations/global/peerings/*}:getIamPolicy',
},
{
get: '/v1/{resource=projects/*/locations/global/domains/*/backups/*}:getIamPolicy',
},
],
},
{
selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',
post: '/v1/{resource=projects/*/locations/global/domains/*}:setIamPolicy',
body: '*',
additional_bindings: [
{
post: '/v1/{resource=projects/*/locations/global/peerings/*}:setIamPolicy',
body: '*',
},
{
post: '/v1/{resource=projects/*/locations/global/domains/*/backups/*}:setIamPolicy',
body: '*',
},
],
},
{
selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',
post: '/v1/{resource=projects/*/locations/global/domains/*}:testIamPermissions',
body: '*',
additional_bindings: [
{
post: '/v1/{resource=projects/*/locations/global/peerings/*}:testIamPermissions',
body: '*',
},
{
post: '/v1/{resource=projects/*/locations/global/domains/*/backups/*}:testIamPermissions',
body: '*',
},
],
},
{
selector: 'google.longrunning.Operations.CancelOperation',
post: '/v1/{name=projects/*/locations/global/operations/*}:cancel',
body: '*',
},
{
selector: 'google.longrunning.Operations.DeleteOperation',
delete: '/v1/{name=projects/*/locations/global/operations/*}',
},
{
selector: 'google.longrunning.Operations.GetOperation',
get: '/v1/{name=projects/*/locations/global/operations/*}',
},
{
selector: 'google.longrunning.Operations.ListOperations',
get: '/v1/{name=projects/*/locations/global/operations}',
},
];
}
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})
.lro(lroOptions)
.operationsClient(opts);
const createMicrosoftAdDomainResponse = protoFilesRoot.lookup(
'.google.cloud.managedidentities.v1.Domain'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
CallOptions,
Descriptors,
ClientOptions,
GrpcClientOptions,
LROperation,
PaginationCallback,
GaxCall,
Expand Down Expand Up @@ -71,7 +72,7 @@ export class ManagedIdentitiesServiceClient {
*
* @param {object} [options] - The configuration object.
* The options accepted by the constructor are described in detail
* in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
* in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance).
* The common options are:
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
Expand All @@ -94,11 +95,10 @@ export class ManagedIdentitiesServiceClient {
* API remote host.
* @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
* Follows the structure of {@link gapicConfig}.
* @param {boolean} [options.fallback] - Use HTTP fallback mode.
* In fallback mode, a special browser-compatible transport implementation is used
* instead of gRPC transport. In browser context (if the `window` object is defined)
* the fallback mode is enabled automatically; set `options.fallback` to `false`
* if you need to override this behavior.
* @param {boolean | "rest"} [options.fallback] - Use HTTP fallback mode.
* Pass "rest" to use HTTP/1.1 REST API instead of gRPC.
* For more information, please check the
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}.
*/
constructor(opts?: ClientOptions) {
// Ensure that options include all the required fields.
Expand Down Expand Up @@ -189,16 +189,87 @@ export class ManagedIdentitiesServiceClient {
};

const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);

// This API contains "long-running operations", which return a
// an Operation object that allows for tracking of the operation,
// rather than holding a request open.

const lroOptions: GrpcClientOptions = {
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
};
if (opts.fallback === 'rest') {
lroOptions.protoJson = protoFilesRoot;
lroOptions.httpRules = [
{
selector: 'google.cloud.location.Locations.GetLocation',
get: '/v1beta1/{name=projects/*/locations/*}',
},
{
selector: 'google.cloud.location.Locations.ListLocations',
get: '/v1beta1/{name=projects/*}/locations',
},
{
selector: 'google.iam.v1.IAMPolicy.GetIamPolicy',
get: '/v1beta1/{resource=projects/*/locations/global/domains/*}:getIamPolicy',
additional_bindings: [
{
get: '/v1beta1/{resource=projects/*/locations/global/peerings/*}:getIamPolicy',
},
{
get: '/v1beta1/{resource=projects/*/locations/global/domains/*/backups/*}:getIamPolicy',
},
],
},
{
selector: 'google.iam.v1.IAMPolicy.SetIamPolicy',
post: '/v1beta1/{resource=projects/*/locations/global/domains/*}:setIamPolicy',
body: '*',
additional_bindings: [
{
post: '/v1beta1/{resource=projects/*/locations/global/peerings/*}:setIamPolicy',
body: '*',
},
{
post: '/v1beta1/{resource=projects/*/locations/global/domains/*/backups/*}:setIamPolicy',
body: '*',
},
],
},
{
selector: 'google.iam.v1.IAMPolicy.TestIamPermissions',
post: '/v1beta1/{resource=projects/*/locations/global/domains/*}:testIamPermissions',
body: '*',
additional_bindings: [
{
post: '/v1beta1/{resource=projects/*/locations/global/peerings/*}:testIamPermissions',
body: '*',
},
{
post: '/v1beta1/{resource=projects/*/locations/global/domains/*/backups/*}:testIamPermissions',
body: '*',
},
],
},
{
selector: 'google.longrunning.Operations.CancelOperation',
post: '/v1beta1/{name=projects/*/locations/global/operations/*}:cancel',
body: '*',
},
{
selector: 'google.longrunning.Operations.DeleteOperation',
delete: '/v1beta1/{name=projects/*/locations/global/operations/*}',
},
{
selector: 'google.longrunning.Operations.GetOperation',
get: '/v1beta1/{name=projects/*/locations/global/operations/*}',
},
{
selector: 'google.longrunning.Operations.ListOperations',
get: '/v1beta1/{name=projects/*/locations/global/operations}',
},
];
}
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})
.lro(lroOptions)
.operationsClient(opts);
const createMicrosoftAdDomainResponse = protoFilesRoot.lookup(
'.google.cloud.managedidentities.v1beta1.Domain'
Expand Down

0 comments on commit 064efea

Please sign in to comment.