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

feat: support regapic LRO #140

Merged
merged 2 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions src/v1/applications_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
CallOptions,
Descriptors,
ClientOptions,
GrpcClientOptions,
LROperation,
} from 'google-gax';

Expand Down Expand Up @@ -68,7 +69,7 @@ export class ApplicationsClient {
*
* @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 @@ -91,11 +92,10 @@ export class ApplicationsClient {
* 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 @@ -168,16 +168,36 @@ export class ApplicationsClient {
};

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=apps/*/locations/*}',
},
{
selector: 'google.cloud.location.Locations.ListLocations',
get: '/v1/{name=apps/*}/locations',
},
{
selector: 'google.longrunning.Operations.GetOperation',
get: '/v1/{name=apps/*/operations/*}',
},
{
selector: 'google.longrunning.Operations.ListOperations',
get: '/v1/{name=apps/*}/operations',
},
];
}
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})
.lro(lroOptions)
.operationsClient(opts);
const createApplicationResponse = protoFilesRoot.lookup(
'.google.appengine.v1.Application'
Expand Down
11 changes: 5 additions & 6 deletions src/v1/authorized_certificates_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class AuthorizedCertificatesClient {
*
* @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 +94,10 @@ export class AuthorizedCertificatesClient {
* 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
11 changes: 5 additions & 6 deletions src/v1/authorized_domains_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class AuthorizedDomainsClient {
*
* @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 @@ -95,11 +95,10 @@ export class AuthorizedDomainsClient {
* 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
44 changes: 32 additions & 12 deletions src/v1/domain_mappings_client.ts
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 @@ -72,7 +73,7 @@ export class DomainMappingsClient {
*
* @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 @@ -95,11 +96,10 @@ export class DomainMappingsClient {
* 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 @@ -183,16 +183,36 @@ export class DomainMappingsClient {
};

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=apps/*/locations/*}',
},
{
selector: 'google.cloud.location.Locations.ListLocations',
get: '/v1/{name=apps/*}/locations',
},
{
selector: 'google.longrunning.Operations.GetOperation',
get: '/v1/{name=apps/*/operations/*}',
},
{
selector: 'google.longrunning.Operations.ListOperations',
get: '/v1/{name=apps/*}/operations',
},
];
}
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})
.lro(lroOptions)
.operationsClient(opts);
const createDomainMappingResponse = protoFilesRoot.lookup(
'.google.appengine.v1.DomainMapping'
Expand Down
11 changes: 5 additions & 6 deletions src/v1/firewall_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class FirewallClient {
*
* @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 @@ -102,11 +102,10 @@ export class FirewallClient {
* 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
44 changes: 32 additions & 12 deletions src/v1/instances_client.ts
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 @@ -72,7 +73,7 @@ export class InstancesClient {
*
* @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 @@ -95,11 +96,10 @@ export class InstancesClient {
* 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 @@ -183,16 +183,36 @@ export class InstancesClient {
};

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=apps/*/locations/*}',
},
{
selector: 'google.cloud.location.Locations.ListLocations',
get: '/v1/{name=apps/*}/locations',
},
{
selector: 'google.longrunning.Operations.GetOperation',
get: '/v1/{name=apps/*/operations/*}',
},
{
selector: 'google.longrunning.Operations.ListOperations',
get: '/v1/{name=apps/*}/operations',
},
];
}
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})
.lro(lroOptions)
.operationsClient(opts);
const deleteInstanceResponse = protoFilesRoot.lookup(
'.google.protobuf.Empty'
Expand Down
44 changes: 32 additions & 12 deletions src/v1/services_client.ts
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 @@ -72,7 +73,7 @@ export class ServicesClient {
*
* @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 @@ -95,11 +96,10 @@ export class ServicesClient {
* 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 @@ -183,16 +183,36 @@ export class ServicesClient {
};

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=apps/*/locations/*}',
},
{
selector: 'google.cloud.location.Locations.ListLocations',
get: '/v1/{name=apps/*}/locations',
},
{
selector: 'google.longrunning.Operations.GetOperation',
get: '/v1/{name=apps/*/operations/*}',
},
{
selector: 'google.longrunning.Operations.ListOperations',
get: '/v1/{name=apps/*}/operations',
},
];
}
this.operationsClient = this._gaxModule
.lro({
auth: this.auth,
grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined,
})
.lro(lroOptions)
.operationsClient(opts);
const updateServiceResponse = protoFilesRoot.lookup(
'.google.appengine.v1.Service'
Expand Down
Loading