diff --git a/baselines/bigquery-storage/package.json b/baselines/bigquery-storage/package.json index d61217cac..52afe72c8 100644 --- a/baselines/bigquery-storage/package.json +++ b/baselines/bigquery-storage/package.json @@ -24,7 +24,7 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^2.0.0" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/baselines/bigquery-storage/src/v1beta1/big_query_storage_client.ts.baseline b/baselines/bigquery-storage/src/v1beta1/big_query_storage_client.ts.baseline index 165cebad2..eaef8271c 100644 --- a/baselines/bigquery-storage/src/v1beta1/big_query_storage_client.ts.baseline +++ b/baselines/bigquery-storage/src/v1beta1/big_query_storage_client.ts.baseline @@ -17,7 +17,7 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; import * as path from 'path'; import * as protos from '../../protos/protos'; @@ -194,9 +194,8 @@ export class BigQueryStorageClient { // and create an API call method for each. const bigQueryStorageStubMethods = ['createReadSession', 'readRows', 'batchCreateReadSessionStreams', 'finalizeStream', 'splitReadStream']; - for (const methodName of bigQueryStorageStubMethods) { - const innerCallPromise = this.bigQueryStorageStub.then( + const callPromise = this.bigQueryStorageStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -209,20 +208,14 @@ export class BigQueryStorageClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.bigQueryStorageStub; @@ -293,14 +286,14 @@ export class BigQueryStorageClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.bigquery.storage.v1beta1.IReadSession, - protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|null|undefined, + {}|null|undefined>): void; createReadSession( request: protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest, callback: Callback< protos.google.cloud.bigquery.storage.v1beta1.IReadSession, - protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a new read session. A read session divides the contents of a * BigQuery table into one or more streams, which can then be used to read @@ -350,11 +343,12 @@ export class BigQueryStorageClient { request: protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.bigquery.storage.v1beta1.IReadSession, - protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|undefined, {}|undefined>, + protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.bigquery.storage.v1beta1.IReadSession, - protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|undefined, - {}|undefined>): + protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.bigquery.storage.v1beta1.IReadSession, protos.google.cloud.bigquery.storage.v1beta1.ICreateReadSessionRequest|undefined, {}|undefined @@ -392,14 +386,14 @@ export class BigQueryStorageClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsResponse, - protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|undefined, - {}|undefined>): void; + protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|null|undefined, + {}|null|undefined>): void; batchCreateReadSessionStreams( request: protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest, callback: Callback< protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsResponse, - protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|undefined, - {}|undefined>): void; + protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|null|undefined, + {}|null|undefined>): void; /** * Creates additional streams for a ReadSession. This API can be used to * dynamically adjust the parallelism of a batch processing task upwards by @@ -424,11 +418,12 @@ export class BigQueryStorageClient { request: protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsResponse, - protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|undefined, {}|undefined>, + protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsResponse, - protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|undefined, - {}|undefined>): + protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsResponse, protos.google.cloud.bigquery.storage.v1beta1.IBatchCreateReadSessionStreamsRequest|undefined, {}|undefined @@ -465,14 +460,14 @@ export class BigQueryStorageClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|undefined, - {}|undefined>): void; + protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|null|undefined, + {}|null|undefined>): void; finalizeStream( request: protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|undefined, - {}|undefined>): void; + protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|null|undefined, + {}|null|undefined>): void; /** * Triggers the graceful termination of a single stream in a ReadSession. This * API can be used to dynamically adjust the parallelism of a batch processing @@ -503,11 +498,12 @@ export class BigQueryStorageClient { request: protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|undefined, {}|undefined>, + protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|undefined, - {}|undefined>): + protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.cloud.bigquery.storage.v1beta1.IFinalizeStreamRequest|undefined, {}|undefined @@ -544,14 +540,14 @@ export class BigQueryStorageClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamResponse, - protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|undefined, - {}|undefined>): void; + protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|null|undefined, + {}|null|undefined>): void; splitReadStream( request: protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest, callback: Callback< protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamResponse, - protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|undefined, - {}|undefined>): void; + protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|null|undefined, + {}|null|undefined>): void; /** * Splits a given read stream into two Streams. These streams are referred to * as the primary and the residual of the split. The original stream can still @@ -589,11 +585,12 @@ export class BigQueryStorageClient { request: protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamResponse, - protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|undefined, {}|undefined>, + protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamResponse, - protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|undefined, - {}|undefined>): + protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamResponse, protos.google.cloud.bigquery.storage.v1beta1.ISplitReadStreamRequest|undefined, {}|undefined diff --git a/baselines/disable-packing-test/package.json b/baselines/disable-packing-test/package.json index eb9adc8a8..77baff6da 100644 --- a/baselines/disable-packing-test/package.json +++ b/baselines/disable-packing-test/package.json @@ -24,7 +24,7 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^2.0.0" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline index a950db818..e04650406 100644 --- a/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/echo_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './echo_client_config.json'; @@ -248,9 +249,8 @@ export class EchoClient { // and create an API call method for each. const echoStubMethods = ['echo', 'expand', 'collect', 'chat', 'pagedExpand', 'wait', 'block']; - for (const methodName of echoStubMethods) { - const innerCallPromise = this.echoStub.then( + const callPromise = this.echoStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -263,20 +263,14 @@ export class EchoClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.echoStub; @@ -343,14 +337,14 @@ export class EchoClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): void; echo( request: protos.google.showcase.v1beta1.IEchoRequest, callback: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): void; /** * @param {Object} request * The request object that will be sent. @@ -368,11 +362,12 @@ export class EchoClient { request: protos.google.showcase.v1beta1.IEchoRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IEchoResponse, protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined @@ -402,14 +397,14 @@ export class EchoClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IBlockResponse, - protos.google.showcase.v1beta1.IBlockRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IBlockRequest|null|undefined, + {}|null|undefined>): void; block( request: protos.google.showcase.v1beta1.IBlockRequest, callback: Callback< protos.google.showcase.v1beta1.IBlockResponse, - protos.google.showcase.v1beta1.IBlockRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IBlockRequest|null|undefined, + {}|null|undefined>): void; /** * This method will block (wait) for the requested amount of time * and then return the response or error. @@ -434,11 +429,12 @@ export class EchoClient { request: protos.google.showcase.v1beta1.IBlockRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IBlockResponse, - protos.google.showcase.v1beta1.IBlockRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IBlockRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IBlockResponse, - protos.google.showcase.v1beta1.IBlockRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IBlockRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IBlockResponse, protos.google.showcase.v1beta1.IBlockRequest|undefined, {}|undefined @@ -486,12 +482,14 @@ export class EchoClient { options?: gax.CallOptions, callback?: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream; collect( callback?: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream; /** * This method will collect the words given to it. When the stream is closed @@ -506,10 +504,12 @@ export class EchoClient { collect( optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream { if (optionsOrCallback instanceof Function && callback === undefined) { callback = optionsOrCallback; @@ -551,14 +551,14 @@ export class EchoClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; wait( request: protos.google.showcase.v1beta1.IWaitRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * This method will wait the requested amount of and then return. * This method showcases how a client handles a request timing out. @@ -584,11 +584,12 @@ export class EchoClient { request: protos.google.showcase.v1beta1.IWaitRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -619,13 +620,13 @@ export class EchoClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IPagedExpandRequest, - protos.google.showcase.v1beta1.IPagedExpandResponse|null, + protos.google.showcase.v1beta1.IPagedExpandResponse|null|undefined, protos.google.showcase.v1beta1.IEchoResponse>): void; pagedExpand( request: protos.google.showcase.v1beta1.IPagedExpandRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IPagedExpandRequest, - protos.google.showcase.v1beta1.IPagedExpandResponse|null, + protos.google.showcase.v1beta1.IPagedExpandResponse|null|undefined, protos.google.showcase.v1beta1.IEchoResponse>): void; /** * This is similar to the Expand method but instead of returning a stream of @@ -661,11 +662,11 @@ export class EchoClient { request: protos.google.showcase.v1beta1.IPagedExpandRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IPagedExpandRequest, - protos.google.showcase.v1beta1.IPagedExpandResponse|null, + protos.google.showcase.v1beta1.IPagedExpandResponse|null|undefined, protos.google.showcase.v1beta1.IEchoResponse>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IPagedExpandRequest, - protos.google.showcase.v1beta1.IPagedExpandResponse|null, + protos.google.showcase.v1beta1.IPagedExpandResponse|null|undefined, protos.google.showcase.v1beta1.IEchoResponse>): Promise<[ protos.google.showcase.v1beta1.IEchoResponse[], @@ -726,6 +727,40 @@ export class EchoClient { callSettings ); } + +/** + * Equivalent to {@link pagedExpand}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.content + * The string to expand. + * @param {number} request.pageSize + * The amount of words to returned in each page. + * @param {string} request.pageToken + * The position of the page to be returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + pagedExpandAsync( + request?: protos.google.showcase.v1beta1.IPagedExpandRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.pagedExpand.asyncIterate( + this.innerApiCalls['pagedExpand'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline index 74a2e42dd..d248053df 100644 --- a/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/identity_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './identity_client_config.json'; @@ -210,9 +211,8 @@ export class IdentityClient { // and create an API call method for each. const identityStubMethods = ['createUser', 'getUser', 'updateUser', 'deleteUser', 'listUsers']; - for (const methodName of identityStubMethods) { - const innerCallPromise = this.identityStub.then( + const callPromise = this.identityStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -225,20 +225,14 @@ export class IdentityClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.identityStub; @@ -305,14 +299,14 @@ export class IdentityClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.ICreateUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateUserRequest|null|undefined, + {}|null|undefined>): void; createUser( request: protos.google.showcase.v1beta1.ICreateUserRequest, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.ICreateUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateUserRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a user. * @@ -330,11 +324,12 @@ export class IdentityClient { request: protos.google.showcase.v1beta1.ICreateUserRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.ICreateUserRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.ICreateUserRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.ICreateUserRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.ICreateUserRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IUser, protos.google.showcase.v1beta1.ICreateUserRequest|undefined, {}|undefined @@ -364,14 +359,14 @@ export class IdentityClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IGetUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetUserRequest|null|undefined, + {}|null|undefined>): void; getUser( request: protos.google.showcase.v1beta1.IGetUserRequest, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IGetUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetUserRequest|null|undefined, + {}|null|undefined>): void; /** * Retrieves the User with the given uri. * @@ -389,11 +384,12 @@ export class IdentityClient { request: protos.google.showcase.v1beta1.IGetUserRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IGetUserRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IGetUserRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IGetUserRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IGetUserRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IUser, protos.google.showcase.v1beta1.IGetUserRequest|undefined, {}|undefined @@ -430,14 +426,14 @@ export class IdentityClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IUpdateUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateUserRequest|null|undefined, + {}|null|undefined>): void; updateUser( request: protos.google.showcase.v1beta1.IUpdateUserRequest, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IUpdateUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateUserRequest|null|undefined, + {}|null|undefined>): void; /** * Updates a user. * @@ -458,11 +454,12 @@ export class IdentityClient { request: protos.google.showcase.v1beta1.IUpdateUserRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IUpdateUserRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IUpdateUserRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IUpdateUserRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IUpdateUserRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IUser, protos.google.showcase.v1beta1.IUpdateUserRequest|undefined, {}|undefined @@ -499,14 +496,14 @@ export class IdentityClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteUserRequest|null|undefined, + {}|null|undefined>): void; deleteUser( request: protos.google.showcase.v1beta1.IDeleteUserRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteUserRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a user, their profile, and all of their authored messages. * @@ -524,11 +521,12 @@ export class IdentityClient { request: protos.google.showcase.v1beta1.IDeleteUserRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteUserRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IDeleteUserRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteUserRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IDeleteUserRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.showcase.v1beta1.IDeleteUserRequest|undefined, {}|undefined @@ -567,13 +565,13 @@ export class IdentityClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IListUsersRequest, - protos.google.showcase.v1beta1.IListUsersResponse|null, + protos.google.showcase.v1beta1.IListUsersResponse|null|undefined, protos.google.showcase.v1beta1.IUser>): void; listUsers( request: protos.google.showcase.v1beta1.IListUsersRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IListUsersRequest, - protos.google.showcase.v1beta1.IListUsersResponse|null, + protos.google.showcase.v1beta1.IListUsersResponse|null|undefined, protos.google.showcase.v1beta1.IUser>): void; /** * Lists all users. @@ -609,11 +607,11 @@ export class IdentityClient { request: protos.google.showcase.v1beta1.IListUsersRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IListUsersRequest, - protos.google.showcase.v1beta1.IListUsersResponse|null, + protos.google.showcase.v1beta1.IListUsersResponse|null|undefined, protos.google.showcase.v1beta1.IUser>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IListUsersRequest, - protos.google.showcase.v1beta1.IListUsersResponse|null, + protos.google.showcase.v1beta1.IListUsersResponse|null|undefined, protos.google.showcase.v1beta1.IUser>): Promise<[ protos.google.showcase.v1beta1.IUser[], @@ -675,6 +673,41 @@ export class IdentityClient { callSettings ); } + +/** + * Equivalent to {@link listUsers}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.pageSize + * The maximum number of users to return. Server may return fewer users + * than requested. If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * The value of google.showcase.v1beta1.ListUsersResponse.next_page_token + * returned from the previous call to + * `google.showcase.v1beta1.Identity\ListUsers` method. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listUsersAsync( + request?: protos.google.showcase.v1beta1.IListUsersRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listUsers.asyncIterate( + this.innerApiCalls['listUsers'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline index 836c26d23..da65fd669 100644 --- a/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/messaging_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './messaging_client_config.json'; @@ -249,9 +250,8 @@ export class MessagingClient { // and create an API call method for each. const messagingStubMethods = ['createRoom', 'getRoom', 'updateRoom', 'deleteRoom', 'listRooms', 'createBlurb', 'getBlurb', 'updateBlurb', 'deleteBlurb', 'listBlurbs', 'searchBlurbs', 'streamBlurbs', 'sendBlurbs', 'connect']; - for (const methodName of messagingStubMethods) { - const innerCallPromise = this.messagingStub.then( + const callPromise = this.messagingStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -264,20 +264,14 @@ export class MessagingClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.messagingStub; @@ -344,14 +338,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.ICreateRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateRoomRequest|null|undefined, + {}|null|undefined>): void; createRoom( request: protos.google.showcase.v1beta1.ICreateRoomRequest, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.ICreateRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateRoomRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a room. * @@ -369,11 +363,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.ICreateRoomRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.ICreateRoomRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.ICreateRoomRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.ICreateRoomRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.ICreateRoomRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IRoom, protos.google.showcase.v1beta1.ICreateRoomRequest|undefined, {}|undefined @@ -403,14 +398,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IGetRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetRoomRequest|null|undefined, + {}|null|undefined>): void; getRoom( request: protos.google.showcase.v1beta1.IGetRoomRequest, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IGetRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetRoomRequest|null|undefined, + {}|null|undefined>): void; /** * Retrieves the Room with the given resource name. * @@ -428,11 +423,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IGetRoomRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IGetRoomRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IGetRoomRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IGetRoomRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IGetRoomRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IRoom, protos.google.showcase.v1beta1.IGetRoomRequest|undefined, {}|undefined @@ -469,14 +465,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IUpdateRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateRoomRequest|null|undefined, + {}|null|undefined>): void; updateRoom( request: protos.google.showcase.v1beta1.IUpdateRoomRequest, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IUpdateRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateRoomRequest|null|undefined, + {}|null|undefined>): void; /** * Updates a room. * @@ -497,11 +493,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IUpdateRoomRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IUpdateRoomRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IUpdateRoomRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IUpdateRoomRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IUpdateRoomRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IRoom, protos.google.showcase.v1beta1.IUpdateRoomRequest|undefined, {}|undefined @@ -538,14 +535,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteRoomRequest|null|undefined, + {}|null|undefined>): void; deleteRoom( request: protos.google.showcase.v1beta1.IDeleteRoomRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteRoomRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a room and all of its blurbs. * @@ -563,11 +560,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IDeleteRoomRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteRoomRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IDeleteRoomRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteRoomRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IDeleteRoomRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.showcase.v1beta1.IDeleteRoomRequest|undefined, {}|undefined @@ -604,14 +602,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): void; createBlurb( request: protos.google.showcase.v1beta1.ICreateBlurbRequest, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a blurb. If the parent is a room, the blurb is understood to be a * message in that room. If the parent is a profile, the blurb is understood @@ -634,11 +632,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.ICreateBlurbRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IBlurb, protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined @@ -675,14 +674,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IGetBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetBlurbRequest|null|undefined, + {}|null|undefined>): void; getBlurb( request: protos.google.showcase.v1beta1.IGetBlurbRequest, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IGetBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetBlurbRequest|null|undefined, + {}|null|undefined>): void; /** * Retrieves the Blurb with the given resource name. * @@ -700,11 +699,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IGetBlurbRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IGetBlurbRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IGetBlurbRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IGetBlurbRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IGetBlurbRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IBlurb, protos.google.showcase.v1beta1.IGetBlurbRequest|undefined, {}|undefined @@ -741,14 +741,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IUpdateBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateBlurbRequest|null|undefined, + {}|null|undefined>): void; updateBlurb( request: protos.google.showcase.v1beta1.IUpdateBlurbRequest, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IUpdateBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateBlurbRequest|null|undefined, + {}|null|undefined>): void; /** * Updates a blurb. * @@ -769,11 +769,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IUpdateBlurbRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IUpdateBlurbRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IUpdateBlurbRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IUpdateBlurbRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IUpdateBlurbRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IBlurb, protos.google.showcase.v1beta1.IUpdateBlurbRequest|undefined, {}|undefined @@ -810,14 +811,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteBlurbRequest|null|undefined, + {}|null|undefined>): void; deleteBlurb( request: protos.google.showcase.v1beta1.IDeleteBlurbRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteBlurbRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a blurb. * @@ -835,11 +836,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IDeleteBlurbRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteBlurbRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IDeleteBlurbRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteBlurbRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IDeleteBlurbRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.showcase.v1beta1.IDeleteBlurbRequest|undefined, {}|undefined @@ -901,12 +903,14 @@ export class MessagingClient { options?: gax.CallOptions, callback?: Callback< protos.google.showcase.v1beta1.ISendBlurbsResponse, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream; sendBlurbs( callback?: Callback< protos.google.showcase.v1beta1.ISendBlurbsResponse, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream; /** * This is a stream to create multiple blurbs. If an invalid blurb is @@ -920,10 +924,12 @@ export class MessagingClient { sendBlurbs( optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.ISendBlurbsResponse, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.ISendBlurbsResponse, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream { if (optionsOrCallback instanceof Function && callback === undefined) { callback = optionsOrCallback; @@ -966,14 +972,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; searchBlurbs( request: protos.google.showcase.v1beta1.ISearchBlurbsRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * This method searches through all blurbs across all rooms and profiles * for blurbs containing to words found in the query. Only posts that @@ -1006,11 +1012,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.ISearchBlurbsRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -1048,13 +1055,13 @@ export class MessagingClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IListRoomsRequest, - protos.google.showcase.v1beta1.IListRoomsResponse|null, + protos.google.showcase.v1beta1.IListRoomsResponse|null|undefined, protos.google.showcase.v1beta1.IRoom>): void; listRooms( request: protos.google.showcase.v1beta1.IListRoomsRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IListRoomsRequest, - protos.google.showcase.v1beta1.IListRoomsResponse|null, + protos.google.showcase.v1beta1.IListRoomsResponse|null|undefined, protos.google.showcase.v1beta1.IRoom>): void; /** * Lists all chat rooms. @@ -1090,11 +1097,11 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IListRoomsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IListRoomsRequest, - protos.google.showcase.v1beta1.IListRoomsResponse|null, + protos.google.showcase.v1beta1.IListRoomsResponse|null|undefined, protos.google.showcase.v1beta1.IRoom>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IListRoomsRequest, - protos.google.showcase.v1beta1.IListRoomsResponse|null, + protos.google.showcase.v1beta1.IListRoomsResponse|null|undefined, protos.google.showcase.v1beta1.IRoom>): Promise<[ protos.google.showcase.v1beta1.IRoom[], @@ -1156,6 +1163,41 @@ export class MessagingClient { callSettings ); } + +/** + * Equivalent to {@link listRooms}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.pageSize + * The maximum number of rooms return. Server may return fewer rooms + * than requested. If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * The value of google.showcase.v1beta1.ListRoomsResponse.next_page_token + * returned from the previous call to + * `google.showcase.v1beta1.Messaging\ListRooms` method. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listRoomsAsync( + request?: protos.google.showcase.v1beta1.IListRoomsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listRooms.asyncIterate( + this.innerApiCalls['listRooms'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listBlurbs( request: protos.google.showcase.v1beta1.IListBlurbsRequest, options?: gax.CallOptions): @@ -1169,13 +1211,13 @@ export class MessagingClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IListBlurbsRequest, - protos.google.showcase.v1beta1.IListBlurbsResponse|null, + protos.google.showcase.v1beta1.IListBlurbsResponse|null|undefined, protos.google.showcase.v1beta1.IBlurb>): void; listBlurbs( request: protos.google.showcase.v1beta1.IListBlurbsRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IListBlurbsRequest, - protos.google.showcase.v1beta1.IListBlurbsResponse|null, + protos.google.showcase.v1beta1.IListBlurbsResponse|null|undefined, protos.google.showcase.v1beta1.IBlurb>): void; /** * Lists blurbs for a specific chat room or user profile depending on the @@ -1215,11 +1257,11 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IListBlurbsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IListBlurbsRequest, - protos.google.showcase.v1beta1.IListBlurbsResponse|null, + protos.google.showcase.v1beta1.IListBlurbsResponse|null|undefined, protos.google.showcase.v1beta1.IBlurb>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IListBlurbsRequest, - protos.google.showcase.v1beta1.IListBlurbsResponse|null, + protos.google.showcase.v1beta1.IListBlurbsResponse|null|undefined, protos.google.showcase.v1beta1.IBlurb>): Promise<[ protos.google.showcase.v1beta1.IBlurb[], @@ -1298,6 +1340,51 @@ export class MessagingClient { callSettings ); } + +/** + * Equivalent to {@link listBlurbs}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The resource name of the requested room or profile whos blurbs to list. + * @param {number} request.pageSize + * The maximum number of blurbs to return. Server may return fewer + * blurbs than requested. If unspecified, server will pick an appropriate + * default. + * @param {string} request.pageToken + * The value of google.showcase.v1beta1.ListBlurbsResponse.next_page_token + * returned from the previous call to + * `google.showcase.v1beta1.Messaging\ListBlurbs` method. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listBlurbsAsync( + request?: protos.google.showcase.v1beta1.IListBlurbsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listBlurbs.asyncIterate( + this.innerApiCalls['listBlurbs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline b/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline index 140bdb537..892df6b4f 100644 --- a/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline +++ b/baselines/disable-packing-test/src/v1beta1/testing_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './testing_client_config.json'; @@ -213,9 +214,8 @@ export class TestingClient { // and create an API call method for each. const testingStubMethods = ['createSession', 'getSession', 'listSessions', 'deleteSession', 'reportSession', 'listTests', 'deleteTest', 'verifyTest']; - for (const methodName of testingStubMethods) { - const innerCallPromise = this.testingStub.then( + const callPromise = this.testingStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -228,20 +228,14 @@ export class TestingClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.testingStub; @@ -308,14 +302,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.ICreateSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateSessionRequest|null|undefined, + {}|null|undefined>): void; createSession( request: protos.google.showcase.v1beta1.ICreateSessionRequest, callback: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.ICreateSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateSessionRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a new testing session. * @@ -335,11 +329,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.ICreateSessionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.ICreateSessionRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.ICreateSessionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.ICreateSessionRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.ICreateSessionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.ISession, protos.google.showcase.v1beta1.ICreateSessionRequest|undefined, {}|undefined @@ -369,14 +364,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.IGetSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetSessionRequest|null|undefined, + {}|null|undefined>): void; getSession( request: protos.google.showcase.v1beta1.IGetSessionRequest, callback: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.IGetSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetSessionRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a testing session. * @@ -394,11 +389,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IGetSessionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.IGetSessionRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IGetSessionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.IGetSessionRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IGetSessionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.ISession, protos.google.showcase.v1beta1.IGetSessionRequest|undefined, {}|undefined @@ -435,14 +431,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>): void; deleteSession( request: protos.google.showcase.v1beta1.IDeleteSessionRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>): void; /** * Delete a test session. * @@ -460,11 +456,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IDeleteSessionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteSessionRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteSessionRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.showcase.v1beta1.IDeleteSessionRequest|undefined, {}|undefined @@ -501,14 +498,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IReportSessionResponse, - protos.google.showcase.v1beta1.IReportSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IReportSessionRequest|null|undefined, + {}|null|undefined>): void; reportSession( request: protos.google.showcase.v1beta1.IReportSessionRequest, callback: Callback< protos.google.showcase.v1beta1.IReportSessionResponse, - protos.google.showcase.v1beta1.IReportSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IReportSessionRequest|null|undefined, + {}|null|undefined>): void; /** * Report on the status of a session. * This generates a report detailing which tests have been completed, @@ -528,11 +525,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IReportSessionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IReportSessionResponse, - protos.google.showcase.v1beta1.IReportSessionRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IReportSessionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IReportSessionResponse, - protos.google.showcase.v1beta1.IReportSessionRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IReportSessionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IReportSessionResponse, protos.google.showcase.v1beta1.IReportSessionRequest|undefined, {}|undefined @@ -569,14 +567,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteTestRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteTestRequest|null|undefined, + {}|null|undefined>): void; deleteTest( request: protos.google.showcase.v1beta1.IDeleteTestRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteTestRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteTestRequest|null|undefined, + {}|null|undefined>): void; /** * Explicitly decline to implement a test. * @@ -599,11 +597,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IDeleteTestRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteTestRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IDeleteTestRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteTestRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IDeleteTestRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.showcase.v1beta1.IDeleteTestRequest|undefined, {}|undefined @@ -640,14 +639,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IVerifyTestResponse, - protos.google.showcase.v1beta1.IVerifyTestRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IVerifyTestRequest|null|undefined, + {}|null|undefined>): void; verifyTest( request: protos.google.showcase.v1beta1.IVerifyTestRequest, callback: Callback< protos.google.showcase.v1beta1.IVerifyTestResponse, - protos.google.showcase.v1beta1.IVerifyTestRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IVerifyTestRequest|null|undefined, + {}|null|undefined>): void; /** * Register a response to a test. * @@ -672,11 +671,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IVerifyTestRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IVerifyTestResponse, - protos.google.showcase.v1beta1.IVerifyTestRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IVerifyTestRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IVerifyTestResponse, - protos.google.showcase.v1beta1.IVerifyTestRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IVerifyTestRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IVerifyTestResponse, protos.google.showcase.v1beta1.IVerifyTestRequest|undefined, {}|undefined @@ -715,13 +715,13 @@ export class TestingClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IListSessionsRequest, - protos.google.showcase.v1beta1.IListSessionsResponse|null, + protos.google.showcase.v1beta1.IListSessionsResponse|null|undefined, protos.google.showcase.v1beta1.ISession>): void; listSessions( request: protos.google.showcase.v1beta1.IListSessionsRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IListSessionsRequest, - protos.google.showcase.v1beta1.IListSessionsResponse|null, + protos.google.showcase.v1beta1.IListSessionsResponse|null|undefined, protos.google.showcase.v1beta1.ISession>): void; /** * Lists the current test sessions. @@ -754,11 +754,11 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IListSessionsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IListSessionsRequest, - protos.google.showcase.v1beta1.IListSessionsResponse|null, + protos.google.showcase.v1beta1.IListSessionsResponse|null|undefined, protos.google.showcase.v1beta1.ISession>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IListSessionsRequest, - protos.google.showcase.v1beta1.IListSessionsResponse|null, + protos.google.showcase.v1beta1.IListSessionsResponse|null|undefined, protos.google.showcase.v1beta1.ISession>): Promise<[ protos.google.showcase.v1beta1.ISession[], @@ -817,6 +817,38 @@ export class TestingClient { callSettings ); } + +/** + * Equivalent to {@link listSessions}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.pageSize + * The maximum number of sessions to return per page. + * @param {string} request.pageToken + * The page token, for retrieving subsequent pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listSessionsAsync( + request?: protos.google.showcase.v1beta1.IListSessionsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listSessions.asyncIterate( + this.innerApiCalls['listSessions'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listTests( request: protos.google.showcase.v1beta1.IListTestsRequest, options?: gax.CallOptions): @@ -830,13 +862,13 @@ export class TestingClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IListTestsRequest, - protos.google.showcase.v1beta1.IListTestsResponse|null, + protos.google.showcase.v1beta1.IListTestsResponse|null|undefined, protos.google.showcase.v1beta1.ITest>): void; listTests( request: protos.google.showcase.v1beta1.IListTestsRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IListTestsRequest, - protos.google.showcase.v1beta1.IListTestsResponse|null, + protos.google.showcase.v1beta1.IListTestsResponse|null|undefined, protos.google.showcase.v1beta1.ITest>): void; /** * List the tests of a sessesion. @@ -871,11 +903,11 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IListTestsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IListTestsRequest, - protos.google.showcase.v1beta1.IListTestsResponse|null, + protos.google.showcase.v1beta1.IListTestsResponse|null|undefined, protos.google.showcase.v1beta1.ITest>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IListTestsRequest, - protos.google.showcase.v1beta1.IListTestsResponse|null, + protos.google.showcase.v1beta1.IListTestsResponse|null|undefined, protos.google.showcase.v1beta1.ITest>): Promise<[ protos.google.showcase.v1beta1.ITest[], @@ -950,6 +982,47 @@ export class TestingClient { callSettings ); } + +/** + * Equivalent to {@link listTests}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The session. + * @param {number} request.pageSize + * The maximum number of tests to return per page. + * @param {string} request.pageToken + * The page token, for retrieving subsequent pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listTestsAsync( + request?: protos.google.showcase.v1beta1.IListTestsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listTests.asyncIterate( + this.innerApiCalls['listTests'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/disable-packing-test/test/gapic_echo_v1beta1.ts.baseline b/baselines/disable-packing-test/test/gapic_echo_v1beta1.ts.baseline index cf686819a..cff616f0c 100644 --- a/baselines/disable-packing-test/test/gapic_echo_v1beta1.ts.baseline +++ b/baselines/disable-packing-test/test/gapic_echo_v1beta1.ts.baseline @@ -115,6 +115,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v1beta1.EchoClient', () => { it('has servicePath', () => { const servicePath = echoModule.v1beta1.EchoClient.servicePath; @@ -684,6 +704,49 @@ describe('v1beta1.EchoClient', () => { assert((client.descriptors.page.pagedExpand.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.pagedExpand, request)); }); + + it('uses async iteration with pagedExpand without error', async () => { + const client = new echoModule.v1beta1.EchoClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.PagedExpandRequest());const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.EchoResponse()), + generateSampleMessage(new protos.google.showcase.v1beta1.EchoResponse()), + generateSampleMessage(new protos.google.showcase.v1beta1.EchoResponse()), + ]; + client.descriptors.page.pagedExpand.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.IEchoResponse[] = []; + const iterable = client.pagedExpandAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.pagedExpand.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with pagedExpand with error', async () => { + const client = new echoModule.v1beta1.EchoClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.PagedExpandRequest());const expectedError = new Error('expected'); + client.descriptors.page.pagedExpand.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.pagedExpandAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.IEchoResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.pagedExpand.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); }); describe('Path templates', () => { diff --git a/baselines/disable-packing-test/test/gapic_identity_v1beta1.ts.baseline b/baselines/disable-packing-test/test/gapic_identity_v1beta1.ts.baseline index bb9538d45..5c6eb6ace 100644 --- a/baselines/disable-packing-test/test/gapic_identity_v1beta1.ts.baseline +++ b/baselines/disable-packing-test/test/gapic_identity_v1beta1.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v1beta1.IdentityClient', () => { it('has servicePath', () => { const servicePath = identityModule.v1beta1.IdentityClient.servicePath; @@ -585,6 +605,49 @@ describe('v1beta1.IdentityClient', () => { assert((client.descriptors.page.listUsers.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listUsers, request)); }); + + it('uses async iteration with listUsers without error', async () => { + const client = new identityModule.v1beta1.IdentityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListUsersRequest());const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.User()), + generateSampleMessage(new protos.google.showcase.v1beta1.User()), + generateSampleMessage(new protos.google.showcase.v1beta1.User()), + ]; + client.descriptors.page.listUsers.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.IUser[] = []; + const iterable = client.listUsersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listUsers.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listUsers with error', async () => { + const client = new identityModule.v1beta1.IdentityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListUsersRequest());const expectedError = new Error('expected'); + client.descriptors.page.listUsers.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listUsersAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.IUser[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listUsers.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); }); describe('Path templates', () => { diff --git a/baselines/disable-packing-test/test/gapic_messaging_v1beta1.ts.baseline b/baselines/disable-packing-test/test/gapic_messaging_v1beta1.ts.baseline index 4209dabcf..184156ed4 100644 --- a/baselines/disable-packing-test/test/gapic_messaging_v1beta1.ts.baseline +++ b/baselines/disable-packing-test/test/gapic_messaging_v1beta1.ts.baseline @@ -115,6 +115,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v1beta1.MessagingClient', () => { it('has servicePath', () => { const servicePath = messagingModule.v1beta1.MessagingClient.servicePath; @@ -1266,6 +1286,49 @@ describe('v1beta1.MessagingClient', () => { assert((client.descriptors.page.listRooms.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listRooms, request)); }); + + it('uses async iteration with listRooms without error', async () => { + const client = new messagingModule.v1beta1.MessagingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListRoomsRequest());const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.Room()), + generateSampleMessage(new protos.google.showcase.v1beta1.Room()), + generateSampleMessage(new protos.google.showcase.v1beta1.Room()), + ]; + client.descriptors.page.listRooms.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.IRoom[] = []; + const iterable = client.listRoomsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRooms.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listRooms with error', async () => { + const client = new messagingModule.v1beta1.MessagingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListRoomsRequest());const expectedError = new Error('expected'); + client.descriptors.page.listRooms.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRoomsAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.IRoom[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRooms.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); }); describe('listBlurbs', () => { @@ -1391,7 +1454,7 @@ describe('v1beta1.MessagingClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listBlurbs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listBlurbs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listBlurbs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -1425,12 +1488,69 @@ describe('v1beta1.MessagingClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listBlurbs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listBlurbs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listBlurbs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listBlurbs without error', async () => { + const client = new messagingModule.v1beta1.MessagingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListBlurbsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.Blurb()), + generateSampleMessage(new protos.google.showcase.v1beta1.Blurb()), + generateSampleMessage(new protos.google.showcase.v1beta1.Blurb()), + ]; + client.descriptors.page.listBlurbs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.IBlurb[] = []; + const iterable = client.listBlurbsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBlurbs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listBlurbs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listBlurbs with error', async () => { + const client = new messagingModule.v1beta1.MessagingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListBlurbsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listBlurbs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBlurbsAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.IBlurb[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBlurbs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listBlurbs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/disable-packing-test/test/gapic_testing_v1beta1.ts.baseline b/baselines/disable-packing-test/test/gapic_testing_v1beta1.ts.baseline index a49d849e7..8c434c389 100644 --- a/baselines/disable-packing-test/test/gapic_testing_v1beta1.ts.baseline +++ b/baselines/disable-packing-test/test/gapic_testing_v1beta1.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v1beta1.TestingClient', () => { it('has servicePath', () => { const servicePath = testingModule.v1beta1.TestingClient.servicePath; @@ -750,6 +770,49 @@ describe('v1beta1.TestingClient', () => { assert((client.descriptors.page.listSessions.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listSessions, request)); }); + + it('uses async iteration with listSessions without error', async () => { + const client = new testingModule.v1beta1.TestingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListSessionsRequest());const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.Session()), + generateSampleMessage(new protos.google.showcase.v1beta1.Session()), + generateSampleMessage(new protos.google.showcase.v1beta1.Session()), + ]; + client.descriptors.page.listSessions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.ISession[] = []; + const iterable = client.listSessionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSessions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listSessions with error', async () => { + const client = new testingModule.v1beta1.TestingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListSessionsRequest());const expectedError = new Error('expected'); + client.descriptors.page.listSessions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSessionsAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.ISession[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSessions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); }); describe('listTests', () => { @@ -875,7 +938,7 @@ describe('v1beta1.TestingClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listTests.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listTests, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listTests.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -909,12 +972,69 @@ describe('v1beta1.TestingClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listTests.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listTests, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listTests.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listTests without error', async () => { + const client = new testingModule.v1beta1.TestingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListTestsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.Test()), + generateSampleMessage(new protos.google.showcase.v1beta1.Test()), + generateSampleMessage(new protos.google.showcase.v1beta1.Test()), + ]; + client.descriptors.page.listTests.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.ITest[] = []; + const iterable = client.listTestsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTests.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listTests.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listTests with error', async () => { + const client = new testingModule.v1beta1.TestingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListTestsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listTests.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTestsAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.ITest[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTests.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listTests.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/dlp/package.json b/baselines/dlp/package.json index 271b21867..e0738f031 100644 --- a/baselines/dlp/package.json +++ b/baselines/dlp/package.json @@ -24,7 +24,7 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^2.0.0" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/baselines/dlp/src/v2/dlp_service_client.ts.baseline b/baselines/dlp/src/v2/dlp_service_client.ts.baseline index 721d3626e..e9ae47f50 100644 --- a/baselines/dlp/src/v2/dlp_service_client.ts.baseline +++ b/baselines/dlp/src/v2/dlp_service_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './dlp_service_client_config.json'; @@ -235,9 +236,8 @@ export class DlpServiceClient { // and create an API call method for each. const dlpServiceStubMethods = ['inspectContent', 'redactImage', 'deidentifyContent', 'reidentifyContent', 'listInfoTypes', 'createInspectTemplate', 'updateInspectTemplate', 'getInspectTemplate', 'listInspectTemplates', 'deleteInspectTemplate', 'createDeidentifyTemplate', 'updateDeidentifyTemplate', 'getDeidentifyTemplate', 'listDeidentifyTemplates', 'deleteDeidentifyTemplate', 'createJobTrigger', 'updateJobTrigger', 'getJobTrigger', 'listJobTriggers', 'deleteJobTrigger', 'activateJobTrigger', 'createDlpJob', 'listDlpJobs', 'getDlpJob', 'deleteDlpJob', 'cancelDlpJob', 'createStoredInfoType', 'updateStoredInfoType', 'getStoredInfoType', 'listStoredInfoTypes', 'deleteStoredInfoType']; - for (const methodName of dlpServiceStubMethods) { - const innerCallPromise = this.dlpServiceStub.then( + const callPromise = this.dlpServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -250,20 +250,14 @@ export class DlpServiceClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.dlpServiceStub; @@ -332,14 +326,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IInspectContentResponse, - protos.google.privacy.dlp.v2.IInspectContentRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IInspectContentRequest|null|undefined, + {}|null|undefined>): void; inspectContent( request: protos.google.privacy.dlp.v2.IInspectContentRequest, callback: Callback< protos.google.privacy.dlp.v2.IInspectContentResponse, - protos.google.privacy.dlp.v2.IInspectContentRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IInspectContentRequest|null|undefined, + {}|null|undefined>): void; /** * Finds potentially sensitive info in content. * This method has limits on input size, processing time, and output size. @@ -379,11 +373,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IInspectContentRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IInspectContentResponse, - protos.google.privacy.dlp.v2.IInspectContentRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IInspectContentRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IInspectContentResponse, - protos.google.privacy.dlp.v2.IInspectContentRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IInspectContentRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IInspectContentResponse, protos.google.privacy.dlp.v2.IInspectContentRequest|undefined, {}|undefined @@ -420,14 +415,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IRedactImageResponse, - protos.google.privacy.dlp.v2.IRedactImageRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IRedactImageRequest|null|undefined, + {}|null|undefined>): void; redactImage( request: protos.google.privacy.dlp.v2.IRedactImageRequest, callback: Callback< protos.google.privacy.dlp.v2.IRedactImageResponse, - protos.google.privacy.dlp.v2.IRedactImageRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IRedactImageRequest|null|undefined, + {}|null|undefined>): void; /** * Redacts potentially sensitive info from an image. * This method has limits on input size, processing time, and output size. @@ -464,11 +459,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IRedactImageRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IRedactImageResponse, - protos.google.privacy.dlp.v2.IRedactImageRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IRedactImageRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IRedactImageResponse, - protos.google.privacy.dlp.v2.IRedactImageRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IRedactImageRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IRedactImageResponse, protos.google.privacy.dlp.v2.IRedactImageRequest|undefined, {}|undefined @@ -505,14 +501,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IDeidentifyContentResponse, - protos.google.privacy.dlp.v2.IDeidentifyContentRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeidentifyContentRequest|null|undefined, + {}|null|undefined>): void; deidentifyContent( request: protos.google.privacy.dlp.v2.IDeidentifyContentRequest, callback: Callback< protos.google.privacy.dlp.v2.IDeidentifyContentResponse, - protos.google.privacy.dlp.v2.IDeidentifyContentRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeidentifyContentRequest|null|undefined, + {}|null|undefined>): void; /** * De-identifies potentially sensitive info from a ContentItem. * This method has limits on input size and output size. @@ -562,11 +558,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IDeidentifyContentRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IDeidentifyContentResponse, - protos.google.privacy.dlp.v2.IDeidentifyContentRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IDeidentifyContentRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IDeidentifyContentResponse, - protos.google.privacy.dlp.v2.IDeidentifyContentRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IDeidentifyContentRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IDeidentifyContentResponse, protos.google.privacy.dlp.v2.IDeidentifyContentRequest|undefined, {}|undefined @@ -603,14 +600,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IReidentifyContentResponse, - protos.google.privacy.dlp.v2.IReidentifyContentRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IReidentifyContentRequest|null|undefined, + {}|null|undefined>): void; reidentifyContent( request: protos.google.privacy.dlp.v2.IReidentifyContentRequest, callback: Callback< protos.google.privacy.dlp.v2.IReidentifyContentResponse, - protos.google.privacy.dlp.v2.IReidentifyContentRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IReidentifyContentRequest|null|undefined, + {}|null|undefined>): void; /** * Re-identifies content that has been de-identified. * See @@ -662,11 +659,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IReidentifyContentRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IReidentifyContentResponse, - protos.google.privacy.dlp.v2.IReidentifyContentRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IReidentifyContentRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IReidentifyContentResponse, - protos.google.privacy.dlp.v2.IReidentifyContentRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IReidentifyContentRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IReidentifyContentResponse, protos.google.privacy.dlp.v2.IReidentifyContentRequest|undefined, {}|undefined @@ -703,14 +701,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IListInfoTypesResponse, - protos.google.privacy.dlp.v2.IListInfoTypesRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IListInfoTypesRequest|null|undefined, + {}|null|undefined>): void; listInfoTypes( request: protos.google.privacy.dlp.v2.IListInfoTypesRequest, callback: Callback< protos.google.privacy.dlp.v2.IListInfoTypesResponse, - protos.google.privacy.dlp.v2.IListInfoTypesRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IListInfoTypesRequest|null|undefined, + {}|null|undefined>): void; /** * Returns a list of the sensitive information types that the DLP API * supports. See https://cloud.google.com/dlp/docs/infotypes-reference to @@ -738,11 +736,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IListInfoTypesRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IListInfoTypesResponse, - protos.google.privacy.dlp.v2.IListInfoTypesRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IListInfoTypesRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IListInfoTypesResponse, - protos.google.privacy.dlp.v2.IListInfoTypesRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IListInfoTypesRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IListInfoTypesResponse, protos.google.privacy.dlp.v2.IListInfoTypesRequest|undefined, {}|undefined @@ -772,14 +771,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest|null|undefined, + {}|null|undefined>): void; createInspectTemplate( request: protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest, callback: Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest|null|undefined, + {}|null|undefined>): void; /** * Creates an InspectTemplate for re-using frequently used configuration * for inspecting content, images, and storage. @@ -810,11 +809,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IInspectTemplate, protos.google.privacy.dlp.v2.ICreateInspectTemplateRequest|undefined, {}|undefined @@ -851,14 +851,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.IUpdateInspectTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IUpdateInspectTemplateRequest|null|undefined, + {}|null|undefined>): void; updateInspectTemplate( request: protos.google.privacy.dlp.v2.IUpdateInspectTemplateRequest, callback: Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.IUpdateInspectTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IUpdateInspectTemplateRequest|null|undefined, + {}|null|undefined>): void; /** * Updates the InspectTemplate. * See https://cloud.google.com/dlp/docs/creating-templates to learn more. @@ -883,11 +883,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IUpdateInspectTemplateRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.IUpdateInspectTemplateRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IUpdateInspectTemplateRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.IUpdateInspectTemplateRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IUpdateInspectTemplateRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IInspectTemplate, protos.google.privacy.dlp.v2.IUpdateInspectTemplateRequest|undefined, {}|undefined @@ -924,14 +925,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.IGetInspectTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IGetInspectTemplateRequest|null|undefined, + {}|null|undefined>): void; getInspectTemplate( request: protos.google.privacy.dlp.v2.IGetInspectTemplateRequest, callback: Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.IGetInspectTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IGetInspectTemplateRequest|null|undefined, + {}|null|undefined>): void; /** * Gets an InspectTemplate. * See https://cloud.google.com/dlp/docs/creating-templates to learn more. @@ -952,11 +953,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IGetInspectTemplateRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.IGetInspectTemplateRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IGetInspectTemplateRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IInspectTemplate, - protos.google.privacy.dlp.v2.IGetInspectTemplateRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IGetInspectTemplateRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IInspectTemplate, protos.google.privacy.dlp.v2.IGetInspectTemplateRequest|undefined, {}|undefined @@ -993,14 +995,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteInspectTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeleteInspectTemplateRequest|null|undefined, + {}|null|undefined>): void; deleteInspectTemplate( request: protos.google.privacy.dlp.v2.IDeleteInspectTemplateRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteInspectTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeleteInspectTemplateRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes an InspectTemplate. * See https://cloud.google.com/dlp/docs/creating-templates to learn more. @@ -1021,11 +1023,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IDeleteInspectTemplateRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteInspectTemplateRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IDeleteInspectTemplateRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteInspectTemplateRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IDeleteInspectTemplateRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.privacy.dlp.v2.IDeleteInspectTemplateRequest|undefined, {}|undefined @@ -1062,14 +1065,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.ICreateDeidentifyTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICreateDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): void; createDeidentifyTemplate( request: protos.google.privacy.dlp.v2.ICreateDeidentifyTemplateRequest, callback: Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.ICreateDeidentifyTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICreateDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a DeidentifyTemplate for re-using frequently used configuration * for de-identifying content, images, and storage. @@ -1101,11 +1104,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.ICreateDeidentifyTemplateRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.ICreateDeidentifyTemplateRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.ICreateDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.ICreateDeidentifyTemplateRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.ICreateDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IDeidentifyTemplate, protos.google.privacy.dlp.v2.ICreateDeidentifyTemplateRequest|undefined, {}|undefined @@ -1142,14 +1146,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.IUpdateDeidentifyTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IUpdateDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): void; updateDeidentifyTemplate( request: protos.google.privacy.dlp.v2.IUpdateDeidentifyTemplateRequest, callback: Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.IUpdateDeidentifyTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IUpdateDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): void; /** * Updates the DeidentifyTemplate. * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn @@ -1175,11 +1179,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IUpdateDeidentifyTemplateRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.IUpdateDeidentifyTemplateRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IUpdateDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.IUpdateDeidentifyTemplateRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IUpdateDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IDeidentifyTemplate, protos.google.privacy.dlp.v2.IUpdateDeidentifyTemplateRequest|undefined, {}|undefined @@ -1216,14 +1221,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.IGetDeidentifyTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IGetDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): void; getDeidentifyTemplate( request: protos.google.privacy.dlp.v2.IGetDeidentifyTemplateRequest, callback: Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.IGetDeidentifyTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IGetDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a DeidentifyTemplate. * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn @@ -1245,11 +1250,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IGetDeidentifyTemplateRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.IGetDeidentifyTemplateRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IGetDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IDeidentifyTemplate, - protos.google.privacy.dlp.v2.IGetDeidentifyTemplateRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IGetDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IDeidentifyTemplate, protos.google.privacy.dlp.v2.IGetDeidentifyTemplateRequest|undefined, {}|undefined @@ -1286,14 +1292,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteDeidentifyTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeleteDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): void; deleteDeidentifyTemplate( request: protos.google.privacy.dlp.v2.IDeleteDeidentifyTemplateRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteDeidentifyTemplateRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeleteDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a DeidentifyTemplate. * See https://cloud.google.com/dlp/docs/creating-templates-deid to learn @@ -1315,11 +1321,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IDeleteDeidentifyTemplateRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteDeidentifyTemplateRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IDeleteDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteDeidentifyTemplateRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IDeleteDeidentifyTemplateRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.privacy.dlp.v2.IDeleteDeidentifyTemplateRequest|undefined, {}|undefined @@ -1356,14 +1363,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.ICreateJobTriggerRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICreateJobTriggerRequest|null|undefined, + {}|null|undefined>): void; createJobTrigger( request: protos.google.privacy.dlp.v2.ICreateJobTriggerRequest, callback: Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.ICreateJobTriggerRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICreateJobTriggerRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a job trigger to run DLP actions such as scanning storage for * sensitive information on a set schedule. @@ -1393,11 +1400,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.ICreateJobTriggerRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.ICreateJobTriggerRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.ICreateJobTriggerRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.ICreateJobTriggerRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.ICreateJobTriggerRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IJobTrigger, protos.google.privacy.dlp.v2.ICreateJobTriggerRequest|undefined, {}|undefined @@ -1434,14 +1442,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.IUpdateJobTriggerRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IUpdateJobTriggerRequest|null|undefined, + {}|null|undefined>): void; updateJobTrigger( request: protos.google.privacy.dlp.v2.IUpdateJobTriggerRequest, callback: Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.IUpdateJobTriggerRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IUpdateJobTriggerRequest|null|undefined, + {}|null|undefined>): void; /** * Updates a job trigger. * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. @@ -1465,11 +1473,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IUpdateJobTriggerRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.IUpdateJobTriggerRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IUpdateJobTriggerRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.IUpdateJobTriggerRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IUpdateJobTriggerRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IJobTrigger, protos.google.privacy.dlp.v2.IUpdateJobTriggerRequest|undefined, {}|undefined @@ -1506,14 +1515,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.IGetJobTriggerRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IGetJobTriggerRequest|null|undefined, + {}|null|undefined>): void; getJobTrigger( request: protos.google.privacy.dlp.v2.IGetJobTriggerRequest, callback: Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.IGetJobTriggerRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IGetJobTriggerRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a job trigger. * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. @@ -1533,11 +1542,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IGetJobTriggerRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.IGetJobTriggerRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IGetJobTriggerRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IJobTrigger, - protos.google.privacy.dlp.v2.IGetJobTriggerRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IGetJobTriggerRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IJobTrigger, protos.google.privacy.dlp.v2.IGetJobTriggerRequest|undefined, {}|undefined @@ -1574,14 +1584,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteJobTriggerRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeleteJobTriggerRequest|null|undefined, + {}|null|undefined>): void; deleteJobTrigger( request: protos.google.privacy.dlp.v2.IDeleteJobTriggerRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteJobTriggerRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeleteJobTriggerRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a job trigger. * See https://cloud.google.com/dlp/docs/creating-job-triggers to learn more. @@ -1601,11 +1611,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IDeleteJobTriggerRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteJobTriggerRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IDeleteJobTriggerRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteJobTriggerRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IDeleteJobTriggerRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.privacy.dlp.v2.IDeleteJobTriggerRequest|undefined, {}|undefined @@ -1642,14 +1653,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.IActivateJobTriggerRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IActivateJobTriggerRequest|null|undefined, + {}|null|undefined>): void; activateJobTrigger( request: protos.google.privacy.dlp.v2.IActivateJobTriggerRequest, callback: Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.IActivateJobTriggerRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IActivateJobTriggerRequest|null|undefined, + {}|null|undefined>): void; /** * Activate a job trigger. Causes the immediate execute of a trigger * instead of waiting on the trigger event to occur. @@ -1669,11 +1680,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IActivateJobTriggerRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.IActivateJobTriggerRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IActivateJobTriggerRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.IActivateJobTriggerRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IActivateJobTriggerRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IDlpJob, protos.google.privacy.dlp.v2.IActivateJobTriggerRequest|undefined, {}|undefined @@ -1710,14 +1722,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.ICreateDlpJobRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICreateDlpJobRequest|null|undefined, + {}|null|undefined>): void; createDlpJob( request: protos.google.privacy.dlp.v2.ICreateDlpJobRequest, callback: Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.ICreateDlpJobRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICreateDlpJobRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a new job to inspect storage or calculate risk metrics. * See https://cloud.google.com/dlp/docs/inspecting-storage and @@ -1753,11 +1765,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.ICreateDlpJobRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.ICreateDlpJobRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.ICreateDlpJobRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.ICreateDlpJobRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.ICreateDlpJobRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IDlpJob, protos.google.privacy.dlp.v2.ICreateDlpJobRequest|undefined, {}|undefined @@ -1794,14 +1807,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.IGetDlpJobRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IGetDlpJobRequest|null|undefined, + {}|null|undefined>): void; getDlpJob( request: protos.google.privacy.dlp.v2.IGetDlpJobRequest, callback: Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.IGetDlpJobRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IGetDlpJobRequest|null|undefined, + {}|null|undefined>): void; /** * Gets the latest state of a long-running DlpJob. * See https://cloud.google.com/dlp/docs/inspecting-storage and @@ -1821,11 +1834,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IGetDlpJobRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.IGetDlpJobRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IGetDlpJobRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IDlpJob, - protos.google.privacy.dlp.v2.IGetDlpJobRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IGetDlpJobRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IDlpJob, protos.google.privacy.dlp.v2.IGetDlpJobRequest|undefined, {}|undefined @@ -1862,14 +1876,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteDlpJobRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeleteDlpJobRequest|null|undefined, + {}|null|undefined>): void; deleteDlpJob( request: protos.google.privacy.dlp.v2.IDeleteDlpJobRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteDlpJobRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeleteDlpJobRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a long-running DlpJob. This method indicates that the client is * no longer interested in the DlpJob result. The job will be cancelled if @@ -1891,11 +1905,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IDeleteDlpJobRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteDlpJobRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IDeleteDlpJobRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteDlpJobRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IDeleteDlpJobRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.privacy.dlp.v2.IDeleteDlpJobRequest|undefined, {}|undefined @@ -1932,14 +1947,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.ICancelDlpJobRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICancelDlpJobRequest|null|undefined, + {}|null|undefined>): void; cancelDlpJob( request: protos.google.privacy.dlp.v2.ICancelDlpJobRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.ICancelDlpJobRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICancelDlpJobRequest|null|undefined, + {}|null|undefined>): void; /** * Starts asynchronous cancellation on a long-running DlpJob. The server * makes a best effort to cancel the DlpJob, but success is not @@ -1961,11 +1976,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.ICancelDlpJobRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.ICancelDlpJobRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.ICancelDlpJobRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.ICancelDlpJobRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.ICancelDlpJobRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.privacy.dlp.v2.ICancelDlpJobRequest|undefined, {}|undefined @@ -2002,14 +2018,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.ICreateStoredInfoTypeRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICreateStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): void; createStoredInfoType( request: protos.google.privacy.dlp.v2.ICreateStoredInfoTypeRequest, callback: Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.ICreateStoredInfoTypeRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.ICreateStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a pre-built stored infoType to be used for inspection. * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to @@ -2040,11 +2056,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.ICreateStoredInfoTypeRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.ICreateStoredInfoTypeRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.ICreateStoredInfoTypeRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.ICreateStoredInfoTypeRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.ICreateStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IStoredInfoType, protos.google.privacy.dlp.v2.ICreateStoredInfoTypeRequest|undefined, {}|undefined @@ -2081,14 +2098,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.IUpdateStoredInfoTypeRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IUpdateStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): void; updateStoredInfoType( request: protos.google.privacy.dlp.v2.IUpdateStoredInfoTypeRequest, callback: Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.IUpdateStoredInfoTypeRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IUpdateStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): void; /** * Updates the stored infoType by creating a new version. The existing version * will continue to be used until the new version is ready. @@ -2117,11 +2134,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IUpdateStoredInfoTypeRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.IUpdateStoredInfoTypeRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IUpdateStoredInfoTypeRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.IUpdateStoredInfoTypeRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IUpdateStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IStoredInfoType, protos.google.privacy.dlp.v2.IUpdateStoredInfoTypeRequest|undefined, {}|undefined @@ -2158,14 +2176,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.IGetStoredInfoTypeRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IGetStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): void; getStoredInfoType( request: protos.google.privacy.dlp.v2.IGetStoredInfoTypeRequest, callback: Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.IGetStoredInfoTypeRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IGetStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a stored infoType. * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to @@ -2187,11 +2205,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IGetStoredInfoTypeRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.IGetStoredInfoTypeRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IGetStoredInfoTypeRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.privacy.dlp.v2.IStoredInfoType, - protos.google.privacy.dlp.v2.IGetStoredInfoTypeRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IGetStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.privacy.dlp.v2.IStoredInfoType, protos.google.privacy.dlp.v2.IGetStoredInfoTypeRequest|undefined, {}|undefined @@ -2228,14 +2247,14 @@ export class DlpServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteStoredInfoTypeRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeleteStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): void; deleteStoredInfoType( request: protos.google.privacy.dlp.v2.IDeleteStoredInfoTypeRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteStoredInfoTypeRequest|undefined, - {}|undefined>): void; + protos.google.privacy.dlp.v2.IDeleteStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a stored infoType. * See https://cloud.google.com/dlp/docs/creating-stored-infotypes to @@ -2257,11 +2276,12 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IDeleteStoredInfoTypeRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteStoredInfoTypeRequest|undefined, {}|undefined>, + protos.google.privacy.dlp.v2.IDeleteStoredInfoTypeRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.privacy.dlp.v2.IDeleteStoredInfoTypeRequest|undefined, - {}|undefined>): + protos.google.privacy.dlp.v2.IDeleteStoredInfoTypeRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.privacy.dlp.v2.IDeleteStoredInfoTypeRequest|undefined, {}|undefined @@ -2300,13 +2320,13 @@ export class DlpServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.privacy.dlp.v2.IListInspectTemplatesRequest, - protos.google.privacy.dlp.v2.IListInspectTemplatesResponse|null, + protos.google.privacy.dlp.v2.IListInspectTemplatesResponse|null|undefined, protos.google.privacy.dlp.v2.IInspectTemplate>): void; listInspectTemplates( request: protos.google.privacy.dlp.v2.IListInspectTemplatesRequest, callback: PaginationCallback< protos.google.privacy.dlp.v2.IListInspectTemplatesRequest, - protos.google.privacy.dlp.v2.IListInspectTemplatesResponse|null, + protos.google.privacy.dlp.v2.IListInspectTemplatesResponse|null|undefined, protos.google.privacy.dlp.v2.IInspectTemplate>): void; /** * Lists InspectTemplates. @@ -2362,11 +2382,11 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IListInspectTemplatesRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.privacy.dlp.v2.IListInspectTemplatesRequest, - protos.google.privacy.dlp.v2.IListInspectTemplatesResponse|null, + protos.google.privacy.dlp.v2.IListInspectTemplatesResponse|null|undefined, protos.google.privacy.dlp.v2.IInspectTemplate>, callback?: PaginationCallback< protos.google.privacy.dlp.v2.IListInspectTemplatesRequest, - protos.google.privacy.dlp.v2.IListInspectTemplatesResponse|null, + protos.google.privacy.dlp.v2.IListInspectTemplatesResponse|null|undefined, protos.google.privacy.dlp.v2.IInspectTemplate>): Promise<[ protos.google.privacy.dlp.v2.IInspectTemplate[], @@ -2461,6 +2481,67 @@ export class DlpServiceClient { callSettings ); } + +/** + * Equivalent to {@link listInspectTemplates}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, for example projects/my-project-id or + * organizations/my-org-id. + * @param {string} request.pageToken + * Page token to continue retrieval. Comes from previous call + * to `ListInspectTemplates`. + * @param {number} request.pageSize + * Size of the page, can be limited by server. If zero server returns + * a page of max size 100. + * @param {string} request.orderBy + * Comma separated list of fields to order by, + * followed by `asc` or `desc` postfix. This list is case-insensitive, + * default sorting order is ascending, redundant space characters are + * insignificant. + * + * Example: `name asc,update_time, create_time desc` + * + * Supported fields are: + * + * - `create_time`: corresponds to time the template was created. + * - `update_time`: corresponds to time the template was last updated. + * - `name`: corresponds to template's name. + * - `display_name`: corresponds to template's display name. + * @param {string} request.locationId + * The geographic location where inspection templates will be retrieved from. + * Use `-` for all locations. Reserved for future extensions. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listInspectTemplatesAsync( + request?: protos.google.privacy.dlp.v2.IListInspectTemplatesRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listInspectTemplates.asyncIterate( + this.innerApiCalls['listInspectTemplates'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listDeidentifyTemplates( request: protos.google.privacy.dlp.v2.IListDeidentifyTemplatesRequest, options?: gax.CallOptions): @@ -2474,13 +2555,13 @@ export class DlpServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.privacy.dlp.v2.IListDeidentifyTemplatesRequest, - protos.google.privacy.dlp.v2.IListDeidentifyTemplatesResponse|null, + protos.google.privacy.dlp.v2.IListDeidentifyTemplatesResponse|null|undefined, protos.google.privacy.dlp.v2.IDeidentifyTemplate>): void; listDeidentifyTemplates( request: protos.google.privacy.dlp.v2.IListDeidentifyTemplatesRequest, callback: PaginationCallback< protos.google.privacy.dlp.v2.IListDeidentifyTemplatesRequest, - protos.google.privacy.dlp.v2.IListDeidentifyTemplatesResponse|null, + protos.google.privacy.dlp.v2.IListDeidentifyTemplatesResponse|null|undefined, protos.google.privacy.dlp.v2.IDeidentifyTemplate>): void; /** * Lists DeidentifyTemplates. @@ -2537,11 +2618,11 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IListDeidentifyTemplatesRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.privacy.dlp.v2.IListDeidentifyTemplatesRequest, - protos.google.privacy.dlp.v2.IListDeidentifyTemplatesResponse|null, + protos.google.privacy.dlp.v2.IListDeidentifyTemplatesResponse|null|undefined, protos.google.privacy.dlp.v2.IDeidentifyTemplate>, callback?: PaginationCallback< protos.google.privacy.dlp.v2.IListDeidentifyTemplatesRequest, - protos.google.privacy.dlp.v2.IListDeidentifyTemplatesResponse|null, + protos.google.privacy.dlp.v2.IListDeidentifyTemplatesResponse|null|undefined, protos.google.privacy.dlp.v2.IDeidentifyTemplate>): Promise<[ protos.google.privacy.dlp.v2.IDeidentifyTemplate[], @@ -2636,6 +2717,67 @@ export class DlpServiceClient { callSettings ); } + +/** + * Equivalent to {@link listDeidentifyTemplates}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, for example projects/my-project-id or + * organizations/my-org-id. + * @param {string} request.pageToken + * Page token to continue retrieval. Comes from previous call + * to `ListDeidentifyTemplates`. + * @param {number} request.pageSize + * Size of the page, can be limited by server. If zero server returns + * a page of max size 100. + * @param {string} request.orderBy + * Comma separated list of fields to order by, + * followed by `asc` or `desc` postfix. This list is case-insensitive, + * default sorting order is ascending, redundant space characters are + * insignificant. + * + * Example: `name asc,update_time, create_time desc` + * + * Supported fields are: + * + * - `create_time`: corresponds to time the template was created. + * - `update_time`: corresponds to time the template was last updated. + * - `name`: corresponds to template's name. + * - `display_name`: corresponds to template's display name. + * @param {string} request.locationId + * The geographic location where deidentifications templates will be retrieved + * from. Use `-` for all locations. Reserved for future extensions. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listDeidentifyTemplatesAsync( + request?: protos.google.privacy.dlp.v2.IListDeidentifyTemplatesRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listDeidentifyTemplates.asyncIterate( + this.innerApiCalls['listDeidentifyTemplates'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listJobTriggers( request: protos.google.privacy.dlp.v2.IListJobTriggersRequest, options?: gax.CallOptions): @@ -2649,13 +2791,13 @@ export class DlpServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.privacy.dlp.v2.IListJobTriggersRequest, - protos.google.privacy.dlp.v2.IListJobTriggersResponse|null, + protos.google.privacy.dlp.v2.IListJobTriggersResponse|null|undefined, protos.google.privacy.dlp.v2.IJobTrigger>): void; listJobTriggers( request: protos.google.privacy.dlp.v2.IListJobTriggersRequest, callback: PaginationCallback< protos.google.privacy.dlp.v2.IListJobTriggersRequest, - protos.google.privacy.dlp.v2.IListJobTriggersResponse|null, + protos.google.privacy.dlp.v2.IListJobTriggersResponse|null|undefined, protos.google.privacy.dlp.v2.IJobTrigger>): void; /** * Lists job triggers. @@ -2737,11 +2879,11 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IListJobTriggersRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.privacy.dlp.v2.IListJobTriggersRequest, - protos.google.privacy.dlp.v2.IListJobTriggersResponse|null, + protos.google.privacy.dlp.v2.IListJobTriggersResponse|null|undefined, protos.google.privacy.dlp.v2.IJobTrigger>, callback?: PaginationCallback< protos.google.privacy.dlp.v2.IListJobTriggersRequest, - protos.google.privacy.dlp.v2.IListJobTriggersResponse|null, + protos.google.privacy.dlp.v2.IListJobTriggersResponse|null|undefined, protos.google.privacy.dlp.v2.IJobTrigger>): Promise<[ protos.google.privacy.dlp.v2.IJobTrigger[], @@ -2862,6 +3004,93 @@ export class DlpServiceClient { callSettings ); } + +/** + * Equivalent to {@link listJobTriggers}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, for example `projects/my-project-id`. + * @param {string} request.pageToken + * Page token to continue retrieval. Comes from previous call + * to ListJobTriggers. `order_by` field must not + * change for subsequent calls. + * @param {number} request.pageSize + * Size of the page, can be limited by a server. + * @param {string} request.orderBy + * Comma separated list of triggeredJob fields to order by, + * followed by `asc` or `desc` postfix. This list is case-insensitive, + * default sorting order is ascending, redundant space characters are + * insignificant. + * + * Example: `name asc,update_time, create_time desc` + * + * Supported fields are: + * + * - `create_time`: corresponds to time the JobTrigger was created. + * - `update_time`: corresponds to time the JobTrigger was last updated. + * - `last_run_time`: corresponds to the last time the JobTrigger ran. + * - `name`: corresponds to JobTrigger's name. + * - `display_name`: corresponds to JobTrigger's display name. + * - `status`: corresponds to JobTrigger's status. + * @param {string} request.filter + * Allows filtering. + * + * Supported syntax: + * + * * Filter expressions are made up of one or more restrictions. + * * Restrictions can be combined by `AND` or `OR` logical operators. A + * sequence of restrictions implicitly uses `AND`. + * * A restriction has the form of `{field} {operator} {value}`. + * * Supported fields/values for inspect jobs: + * - `status` - HEALTHY|PAUSED|CANCELLED + * - `inspected_storage` - DATASTORE|CLOUD_STORAGE|BIGQUERY + * - 'last_run_time` - RFC 3339 formatted timestamp, surrounded by + * quotation marks. Nanoseconds are ignored. + * - 'error_count' - Number of errors that have occurred while running. + * * The operator must be `=` or `!=` for status and inspected_storage. + * + * Examples: + * + * * inspected_storage = cloud_storage AND status = HEALTHY + * * inspected_storage = cloud_storage OR inspected_storage = bigquery + * * inspected_storage = cloud_storage AND (state = PAUSED OR state = HEALTHY) + * * last_run_time > \"2017-12-12T00:00:00+00:00\" + * + * The length of this field should be no more than 500 characters. + * @param {string} request.locationId + * The geographic location where job triggers will be retrieved from. + * Use `-` for all locations. Reserved for future extensions. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listJobTriggersAsync( + request?: protos.google.privacy.dlp.v2.IListJobTriggersRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listJobTriggers.asyncIterate( + this.innerApiCalls['listJobTriggers'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listDlpJobs( request: protos.google.privacy.dlp.v2.IListDlpJobsRequest, options?: gax.CallOptions): @@ -2875,13 +3104,13 @@ export class DlpServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.privacy.dlp.v2.IListDlpJobsRequest, - protos.google.privacy.dlp.v2.IListDlpJobsResponse|null, + protos.google.privacy.dlp.v2.IListDlpJobsResponse|null|undefined, protos.google.privacy.dlp.v2.IDlpJob>): void; listDlpJobs( request: protos.google.privacy.dlp.v2.IListDlpJobsRequest, callback: PaginationCallback< protos.google.privacy.dlp.v2.IListDlpJobsRequest, - protos.google.privacy.dlp.v2.IListDlpJobsResponse|null, + protos.google.privacy.dlp.v2.IListDlpJobsResponse|null|undefined, protos.google.privacy.dlp.v2.IDlpJob>): void; /** * Lists DlpJobs that match the specified filter in the request. @@ -2966,11 +3195,11 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IListDlpJobsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.privacy.dlp.v2.IListDlpJobsRequest, - protos.google.privacy.dlp.v2.IListDlpJobsResponse|null, + protos.google.privacy.dlp.v2.IListDlpJobsResponse|null|undefined, protos.google.privacy.dlp.v2.IDlpJob>, callback?: PaginationCallback< protos.google.privacy.dlp.v2.IListDlpJobsRequest, - protos.google.privacy.dlp.v2.IListDlpJobsResponse|null, + protos.google.privacy.dlp.v2.IListDlpJobsResponse|null|undefined, protos.google.privacy.dlp.v2.IDlpJob>): Promise<[ protos.google.privacy.dlp.v2.IDlpJob[], @@ -3093,6 +3322,95 @@ export class DlpServiceClient { callSettings ); } + +/** + * Equivalent to {@link listDlpJobs}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, for example projects/my-project-id. + * @param {string} request.filter + * Allows filtering. + * + * Supported syntax: + * + * * Filter expressions are made up of one or more restrictions. + * * Restrictions can be combined by `AND` or `OR` logical operators. A + * sequence of restrictions implicitly uses `AND`. + * * A restriction has the form of `{field} {operator} {value}`. + * * Supported fields/values for inspect jobs: + * - `state` - PENDING|RUNNING|CANCELED|FINISHED|FAILED + * - `inspected_storage` - DATASTORE|CLOUD_STORAGE|BIGQUERY + * - `trigger_name` - The resource name of the trigger that created job. + * - 'end_time` - Corresponds to time the job finished. + * - 'start_time` - Corresponds to time the job finished. + * * Supported fields for risk analysis jobs: + * - `state` - RUNNING|CANCELED|FINISHED|FAILED + * - 'end_time` - Corresponds to time the job finished. + * - 'start_time` - Corresponds to time the job finished. + * * The operator must be `=` or `!=`. + * + * Examples: + * + * * inspected_storage = cloud_storage AND state = done + * * inspected_storage = cloud_storage OR inspected_storage = bigquery + * * inspected_storage = cloud_storage AND (state = done OR state = canceled) + * * end_time > \"2017-12-12T00:00:00+00:00\" + * + * The length of this field should be no more than 500 characters. + * @param {number} request.pageSize + * The standard list page size. + * @param {string} request.pageToken + * The standard list page token. + * @param {google.privacy.dlp.v2.DlpJobType} request.type + * The type of job. Defaults to `DlpJobType.INSPECT` + * @param {string} request.orderBy + * Comma separated list of fields to order by, + * followed by `asc` or `desc` postfix. This list is case-insensitive, + * default sorting order is ascending, redundant space characters are + * insignificant. + * + * Example: `name asc, end_time asc, create_time desc` + * + * Supported fields are: + * + * - `create_time`: corresponds to time the job was created. + * - `end_time`: corresponds to time the job ended. + * - `name`: corresponds to job's name. + * - `state`: corresponds to `state` + * @param {string} request.locationId + * The geographic location where jobs will be retrieved from. + * Use `-` for all locations. Reserved for future extensions. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listDlpJobsAsync( + request?: protos.google.privacy.dlp.v2.IListDlpJobsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listDlpJobs.asyncIterate( + this.innerApiCalls['listDlpJobs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listStoredInfoTypes( request: protos.google.privacy.dlp.v2.IListStoredInfoTypesRequest, options?: gax.CallOptions): @@ -3106,13 +3424,13 @@ export class DlpServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.privacy.dlp.v2.IListStoredInfoTypesRequest, - protos.google.privacy.dlp.v2.IListStoredInfoTypesResponse|null, + protos.google.privacy.dlp.v2.IListStoredInfoTypesResponse|null|undefined, protos.google.privacy.dlp.v2.IStoredInfoType>): void; listStoredInfoTypes( request: protos.google.privacy.dlp.v2.IListStoredInfoTypesRequest, callback: PaginationCallback< protos.google.privacy.dlp.v2.IListStoredInfoTypesRequest, - protos.google.privacy.dlp.v2.IListStoredInfoTypesResponse|null, + protos.google.privacy.dlp.v2.IListStoredInfoTypesResponse|null|undefined, protos.google.privacy.dlp.v2.IStoredInfoType>): void; /** * Lists stored infoTypes. @@ -3170,11 +3488,11 @@ export class DlpServiceClient { request: protos.google.privacy.dlp.v2.IListStoredInfoTypesRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.privacy.dlp.v2.IListStoredInfoTypesRequest, - protos.google.privacy.dlp.v2.IListStoredInfoTypesResponse|null, + protos.google.privacy.dlp.v2.IListStoredInfoTypesResponse|null|undefined, protos.google.privacy.dlp.v2.IStoredInfoType>, callback?: PaginationCallback< protos.google.privacy.dlp.v2.IListStoredInfoTypesRequest, - protos.google.privacy.dlp.v2.IListStoredInfoTypesResponse|null, + protos.google.privacy.dlp.v2.IListStoredInfoTypesResponse|null|undefined, protos.google.privacy.dlp.v2.IStoredInfoType>): Promise<[ protos.google.privacy.dlp.v2.IStoredInfoType[], @@ -3270,6 +3588,68 @@ export class DlpServiceClient { callSettings ); } + +/** + * Equivalent to {@link listStoredInfoTypes}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource name, for example projects/my-project-id or + * organizations/my-org-id. + * @param {string} request.pageToken + * Page token to continue retrieval. Comes from previous call + * to `ListStoredInfoTypes`. + * @param {number} request.pageSize + * Size of the page, can be limited by server. If zero server returns + * a page of max size 100. + * @param {string} request.orderBy + * Comma separated list of fields to order by, + * followed by `asc` or `desc` postfix. This list is case-insensitive, + * default sorting order is ascending, redundant space characters are + * insignificant. + * + * Example: `name asc, display_name, create_time desc` + * + * Supported fields are: + * + * - `create_time`: corresponds to time the most recent version of the + * resource was created. + * - `state`: corresponds to the state of the resource. + * - `name`: corresponds to resource name. + * - `display_name`: corresponds to info type's display name. + * @param {string} request.locationId + * The geographic location where stored infoTypes will be retrieved from. + * Use `-` for all locations. Reserved for future extensions. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listStoredInfoTypesAsync( + request?: protos.google.privacy.dlp.v2.IListStoredInfoTypesRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listStoredInfoTypes.asyncIterate( + this.innerApiCalls['listStoredInfoTypes'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/dlp/test/gapic_dlp_service_v2.ts.baseline b/baselines/dlp/test/gapic_dlp_service_v2.ts.baseline index a47daa8db..cc069be9e 100644 --- a/baselines/dlp/test/gapic_dlp_service_v2.ts.baseline +++ b/baselines/dlp/test/gapic_dlp_service_v2.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v2.DlpServiceClient', () => { it('has servicePath', () => { const servicePath = dlpserviceModule.v2.DlpServiceClient.servicePath; @@ -2428,7 +2448,7 @@ describe('v2.DlpServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listInspectTemplates.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listInspectTemplates, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listInspectTemplates.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -2462,12 +2482,69 @@ describe('v2.DlpServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listInspectTemplates.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listInspectTemplates, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listInspectTemplates.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listInspectTemplates without error', async () => { + const client = new dlpserviceModule.v2.DlpServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListInspectTemplatesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.privacy.dlp.v2.InspectTemplate()), + generateSampleMessage(new protos.google.privacy.dlp.v2.InspectTemplate()), + generateSampleMessage(new protos.google.privacy.dlp.v2.InspectTemplate()), + ]; + client.descriptors.page.listInspectTemplates.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.privacy.dlp.v2.IInspectTemplate[] = []; + const iterable = client.listInspectTemplatesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInspectTemplates.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listInspectTemplates.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listInspectTemplates with error', async () => { + const client = new dlpserviceModule.v2.DlpServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListInspectTemplatesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listInspectTemplates.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInspectTemplatesAsync(request); + assert.rejects(async () => { + const responses: protos.google.privacy.dlp.v2.IInspectTemplate[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInspectTemplates.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listInspectTemplates.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listDeidentifyTemplates', () => { @@ -2593,7 +2670,7 @@ describe('v2.DlpServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listDeidentifyTemplates.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listDeidentifyTemplates, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listDeidentifyTemplates.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -2627,12 +2704,69 @@ describe('v2.DlpServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listDeidentifyTemplates.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listDeidentifyTemplates, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listDeidentifyTemplates.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listDeidentifyTemplates without error', async () => { + const client = new dlpserviceModule.v2.DlpServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListDeidentifyTemplatesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.privacy.dlp.v2.DeidentifyTemplate()), + generateSampleMessage(new protos.google.privacy.dlp.v2.DeidentifyTemplate()), + generateSampleMessage(new protos.google.privacy.dlp.v2.DeidentifyTemplate()), + ]; + client.descriptors.page.listDeidentifyTemplates.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.privacy.dlp.v2.IDeidentifyTemplate[] = []; + const iterable = client.listDeidentifyTemplatesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDeidentifyTemplates.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDeidentifyTemplates.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDeidentifyTemplates with error', async () => { + const client = new dlpserviceModule.v2.DlpServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListDeidentifyTemplatesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listDeidentifyTemplates.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDeidentifyTemplatesAsync(request); + assert.rejects(async () => { + const responses: protos.google.privacy.dlp.v2.IDeidentifyTemplate[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDeidentifyTemplates.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDeidentifyTemplates.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listJobTriggers', () => { @@ -2758,7 +2892,7 @@ describe('v2.DlpServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listJobTriggers.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listJobTriggers, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listJobTriggers.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -2792,12 +2926,69 @@ describe('v2.DlpServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listJobTriggers.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listJobTriggers, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listJobTriggers.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listJobTriggers without error', async () => { + const client = new dlpserviceModule.v2.DlpServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListJobTriggersRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.privacy.dlp.v2.JobTrigger()), + generateSampleMessage(new protos.google.privacy.dlp.v2.JobTrigger()), + generateSampleMessage(new protos.google.privacy.dlp.v2.JobTrigger()), + ]; + client.descriptors.page.listJobTriggers.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.privacy.dlp.v2.IJobTrigger[] = []; + const iterable = client.listJobTriggersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listJobTriggers.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listJobTriggers.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listJobTriggers with error', async () => { + const client = new dlpserviceModule.v2.DlpServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListJobTriggersRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listJobTriggers.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listJobTriggersAsync(request); + assert.rejects(async () => { + const responses: protos.google.privacy.dlp.v2.IJobTrigger[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listJobTriggers.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listJobTriggers.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listDlpJobs', () => { @@ -2923,7 +3114,7 @@ describe('v2.DlpServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listDlpJobs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listDlpJobs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listDlpJobs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -2957,12 +3148,69 @@ describe('v2.DlpServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listDlpJobs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listDlpJobs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listDlpJobs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listDlpJobs without error', async () => { + const client = new dlpserviceModule.v2.DlpServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListDlpJobsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.privacy.dlp.v2.DlpJob()), + generateSampleMessage(new protos.google.privacy.dlp.v2.DlpJob()), + generateSampleMessage(new protos.google.privacy.dlp.v2.DlpJob()), + ]; + client.descriptors.page.listDlpJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.privacy.dlp.v2.IDlpJob[] = []; + const iterable = client.listDlpJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listDlpJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDlpJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listDlpJobs with error', async () => { + const client = new dlpserviceModule.v2.DlpServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListDlpJobsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listDlpJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listDlpJobsAsync(request); + assert.rejects(async () => { + const responses: protos.google.privacy.dlp.v2.IDlpJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listDlpJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listDlpJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listStoredInfoTypes', () => { @@ -3088,7 +3336,7 @@ describe('v2.DlpServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listStoredInfoTypes.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listStoredInfoTypes, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listStoredInfoTypes.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -3122,12 +3370,69 @@ describe('v2.DlpServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listStoredInfoTypes.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listStoredInfoTypes, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listStoredInfoTypes.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listStoredInfoTypes without error', async () => { + const client = new dlpserviceModule.v2.DlpServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListStoredInfoTypesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.privacy.dlp.v2.StoredInfoType()), + generateSampleMessage(new protos.google.privacy.dlp.v2.StoredInfoType()), + generateSampleMessage(new protos.google.privacy.dlp.v2.StoredInfoType()), + ]; + client.descriptors.page.listStoredInfoTypes.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.privacy.dlp.v2.IStoredInfoType[] = []; + const iterable = client.listStoredInfoTypesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listStoredInfoTypes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listStoredInfoTypes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listStoredInfoTypes with error', async () => { + const client = new dlpserviceModule.v2.DlpServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.privacy.dlp.v2.ListStoredInfoTypesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listStoredInfoTypes.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listStoredInfoTypesAsync(request); + assert.rejects(async () => { + const responses: protos.google.privacy.dlp.v2.IStoredInfoType[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listStoredInfoTypes.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listStoredInfoTypes.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/kms/package.json b/baselines/kms/package.json index dacb3576d..5232d42b9 100644 --- a/baselines/kms/package.json +++ b/baselines/kms/package.json @@ -24,7 +24,7 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^2.0.0" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/baselines/kms/src/v1/key_management_service_client.ts.baseline b/baselines/kms/src/v1/key_management_service_client.ts.baseline index 70c012895..69729e344 100644 --- a/baselines/kms/src/v1/key_management_service_client.ts.baseline +++ b/baselines/kms/src/v1/key_management_service_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './key_management_service_client_config.json'; @@ -198,9 +199,8 @@ export class KeyManagementServiceClient { // and create an API call method for each. const keyManagementServiceStubMethods = ['listKeyRings', 'listCryptoKeys', 'listCryptoKeyVersions', 'listImportJobs', 'getKeyRing', 'getCryptoKey', 'getCryptoKeyVersion', 'getPublicKey', 'getImportJob', 'createKeyRing', 'createCryptoKey', 'createCryptoKeyVersion', 'importCryptoKeyVersion', 'createImportJob', 'updateCryptoKey', 'updateCryptoKeyVersion', 'encrypt', 'decrypt', 'asymmetricSign', 'asymmetricDecrypt', 'updateCryptoKeyPrimaryVersion', 'destroyCryptoKeyVersion', 'restoreCryptoKeyVersion']; - for (const methodName of keyManagementServiceStubMethods) { - const innerCallPromise = this.keyManagementServiceStub.then( + const callPromise = this.keyManagementServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -213,20 +213,14 @@ export class KeyManagementServiceClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.keyManagementServiceStub; @@ -296,14 +290,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IGetKeyRingRequest|null|undefined, + {}|null|undefined>): void; getKeyRing( request: protos.google.cloud.kms.v1.IGetKeyRingRequest, callback: Callback< protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IGetKeyRingRequest|null|undefined, + {}|null|undefined>): void; /** * Returns metadata for a given {@link google.cloud.kms.v1.KeyRing|KeyRing}. * @@ -321,11 +315,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IGetKeyRingRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IGetKeyRingRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.IGetKeyRingRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IGetKeyRingRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.IKeyRing, protos.google.cloud.kms.v1.IGetKeyRingRequest|undefined, {}|undefined @@ -362,14 +357,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IGetCryptoKeyRequest|null|undefined, + {}|null|undefined>): void; getCryptoKey( request: protos.google.cloud.kms.v1.IGetCryptoKeyRequest, callback: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IGetCryptoKeyRequest|null|undefined, + {}|null|undefined>): void; /** * Returns metadata for a given {@link google.cloud.kms.v1.CryptoKey|CryptoKey}, as well as its * {@link google.cloud.kms.v1.CryptoKey.primary|primary} {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. @@ -388,11 +383,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IGetCryptoKeyRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IGetCryptoKeyRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IGetCryptoKeyRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IGetCryptoKeyRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.ICryptoKey, protos.google.cloud.kms.v1.IGetCryptoKeyRequest|undefined, {}|undefined @@ -429,14 +425,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; getCryptoKeyVersion( request: protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; /** * Returns metadata for a given {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. * @@ -454,11 +450,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.ICryptoKeyVersion, protos.google.cloud.kms.v1.IGetCryptoKeyVersionRequest|undefined, {}|undefined @@ -495,14 +492,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IGetPublicKeyRequest|null|undefined, + {}|null|undefined>): void; getPublicKey( request: protos.google.cloud.kms.v1.IGetPublicKeyRequest, callback: Callback< protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IGetPublicKeyRequest|null|undefined, + {}|null|undefined>): void; /** * Returns the public key for the given {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}. The * {@link google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} must be @@ -524,11 +521,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IGetPublicKeyRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IGetPublicKeyRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.IPublicKey, - protos.google.cloud.kms.v1.IGetPublicKeyRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IGetPublicKeyRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.IPublicKey, protos.google.cloud.kms.v1.IGetPublicKeyRequest|undefined, {}|undefined @@ -565,14 +563,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IGetImportJobRequest|null|undefined, + {}|null|undefined>): void; getImportJob( request: protos.google.cloud.kms.v1.IGetImportJobRequest, callback: Callback< protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IGetImportJobRequest|null|undefined, + {}|null|undefined>): void; /** * Returns metadata for a given {@link google.cloud.kms.v1.ImportJob|ImportJob}. * @@ -590,11 +588,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IGetImportJobRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IGetImportJobRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.IGetImportJobRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IGetImportJobRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.IImportJob, protos.google.cloud.kms.v1.IGetImportJobRequest|undefined, {}|undefined @@ -631,14 +630,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.ICreateKeyRingRequest|null|undefined, + {}|null|undefined>): void; createKeyRing( request: protos.google.cloud.kms.v1.ICreateKeyRingRequest, callback: Callback< protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.ICreateKeyRingRequest|null|undefined, + {}|null|undefined>): void; /** * Create a new {@link google.cloud.kms.v1.KeyRing|KeyRing} in a given Project and Location. * @@ -662,11 +661,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.ICreateKeyRingRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.ICreateKeyRingRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.IKeyRing, - protos.google.cloud.kms.v1.ICreateKeyRingRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.ICreateKeyRingRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.IKeyRing, protos.google.cloud.kms.v1.ICreateKeyRingRequest|undefined, {}|undefined @@ -703,14 +703,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|null|undefined, + {}|null|undefined>): void; createCryptoKey( request: protos.google.cloud.kms.v1.ICreateCryptoKeyRequest, callback: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|null|undefined, + {}|null|undefined>): void; /** * Create a new {@link google.cloud.kms.v1.CryptoKey|CryptoKey} within a {@link google.cloud.kms.v1.KeyRing|KeyRing}. * @@ -744,11 +744,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.ICreateCryptoKeyRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.ICryptoKey, protos.google.cloud.kms.v1.ICreateCryptoKeyRequest|undefined, {}|undefined @@ -785,14 +786,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; createCryptoKeyVersion( request: protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; /** * Create a new {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} in a {@link google.cloud.kms.v1.CryptoKey|CryptoKey}. * @@ -817,11 +818,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.ICryptoKeyVersion, protos.google.cloud.kms.v1.ICreateCryptoKeyVersionRequest|undefined, {}|undefined @@ -858,14 +860,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; importCryptoKeyVersion( request: protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; /** * Imports a new {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} into an existing {@link google.cloud.kms.v1.CryptoKey|CryptoKey} using the * wrapped key material provided in the request. @@ -915,11 +917,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.ICryptoKeyVersion, protos.google.cloud.kms.v1.IImportCryptoKeyVersionRequest|undefined, {}|undefined @@ -956,14 +959,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.ICreateImportJobRequest|null|undefined, + {}|null|undefined>): void; createImportJob( request: protos.google.cloud.kms.v1.ICreateImportJobRequest, callback: Callback< protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.ICreateImportJobRequest|null|undefined, + {}|null|undefined>): void; /** * Create a new {@link google.cloud.kms.v1.ImportJob|ImportJob} within a {@link google.cloud.kms.v1.KeyRing|KeyRing}. * @@ -989,11 +992,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.ICreateImportJobRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.ICreateImportJobRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.IImportJob, - protos.google.cloud.kms.v1.ICreateImportJobRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.ICreateImportJobRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.IImportJob, protos.google.cloud.kms.v1.ICreateImportJobRequest|undefined, {}|undefined @@ -1030,14 +1034,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|null|undefined, + {}|null|undefined>): void; updateCryptoKey( request: protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest, callback: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|null|undefined, + {}|null|undefined>): void; /** * Update a {@link google.cloud.kms.v1.CryptoKey|CryptoKey}. * @@ -1057,11 +1061,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.ICryptoKey, protos.google.cloud.kms.v1.IUpdateCryptoKeyRequest|undefined, {}|undefined @@ -1098,14 +1103,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; updateCryptoKeyVersion( request: protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; /** * Update a {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion}'s metadata. * @@ -1131,11 +1136,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.ICryptoKeyVersion, protos.google.cloud.kms.v1.IUpdateCryptoKeyVersionRequest|undefined, {}|undefined @@ -1172,14 +1178,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IEncryptRequest|null|undefined, + {}|null|undefined>): void; encrypt( request: protos.google.cloud.kms.v1.IEncryptRequest, callback: Callback< protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IEncryptRequest|null|undefined, + {}|null|undefined>): void; /** * Encrypts data, so that it can only be recovered by a call to {@link google.cloud.kms.v1.KeyManagementService.Decrypt|Decrypt}. * The {@link google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} must be @@ -1222,11 +1228,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IEncryptRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IEncryptRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.IEncryptResponse, - protos.google.cloud.kms.v1.IEncryptRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IEncryptRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.IEncryptResponse, protos.google.cloud.kms.v1.IEncryptRequest|undefined, {}|undefined @@ -1263,14 +1270,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IDecryptRequest|null|undefined, + {}|null|undefined>): void; decrypt( request: protos.google.cloud.kms.v1.IDecryptRequest, callback: Callback< protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IDecryptRequest|null|undefined, + {}|null|undefined>): void; /** * Decrypts data that was protected by {@link google.cloud.kms.v1.KeyManagementService.Encrypt|Encrypt}. The {@link google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} * must be {@link google.cloud.kms.v1.CryptoKey.CryptoKeyPurpose.ENCRYPT_DECRYPT|ENCRYPT_DECRYPT}. @@ -1296,11 +1303,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IDecryptRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IDecryptRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.IDecryptResponse, - protos.google.cloud.kms.v1.IDecryptRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IDecryptRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.IDecryptResponse, protos.google.cloud.kms.v1.IDecryptRequest|undefined, {}|undefined @@ -1337,14 +1345,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IAsymmetricSignRequest|null|undefined, + {}|null|undefined>): void; asymmetricSign( request: protos.google.cloud.kms.v1.IAsymmetricSignRequest, callback: Callback< protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IAsymmetricSignRequest|null|undefined, + {}|null|undefined>): void; /** * Signs data using a {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} with {@link google.cloud.kms.v1.CryptoKey.purpose|CryptoKey.purpose} * ASYMMETRIC_SIGN, producing a signature that can be verified with the public @@ -1368,11 +1376,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IAsymmetricSignRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IAsymmetricSignRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.IAsymmetricSignResponse, - protos.google.cloud.kms.v1.IAsymmetricSignRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IAsymmetricSignRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.IAsymmetricSignResponse, protos.google.cloud.kms.v1.IAsymmetricSignRequest|undefined, {}|undefined @@ -1409,14 +1418,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|null|undefined, + {}|null|undefined>): void; asymmetricDecrypt( request: protos.google.cloud.kms.v1.IAsymmetricDecryptRequest, callback: Callback< protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|null|undefined, + {}|null|undefined>): void; /** * Decrypts data that was encrypted with a public key retrieved from * {@link google.cloud.kms.v1.KeyManagementService.GetPublicKey|GetPublicKey} corresponding to a {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} with @@ -1440,11 +1449,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IAsymmetricDecryptRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, - protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.IAsymmetricDecryptResponse, protos.google.cloud.kms.v1.IAsymmetricDecryptRequest|undefined, {}|undefined @@ -1481,14 +1491,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|null|undefined, + {}|null|undefined>): void; updateCryptoKeyPrimaryVersion( request: protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest, callback: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|null|undefined, + {}|null|undefined>): void; /** * Update the version of a {@link google.cloud.kms.v1.CryptoKey|CryptoKey} that will be used in {@link google.cloud.kms.v1.KeyManagementService.Encrypt|Encrypt}. * @@ -1510,11 +1520,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.ICryptoKey, - protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.ICryptoKey, protos.google.cloud.kms.v1.IUpdateCryptoKeyPrimaryVersionRequest|undefined, {}|undefined @@ -1551,14 +1562,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; destroyCryptoKeyVersion( request: protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; /** * Schedule a {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} for destruction. * @@ -1587,11 +1598,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.ICryptoKeyVersion, protos.google.cloud.kms.v1.IDestroyCryptoKeyVersionRequest|undefined, {}|undefined @@ -1628,14 +1640,14 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; restoreCryptoKeyVersion( request: protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest, callback: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|undefined, - {}|undefined>): void; + protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): void; /** * Restore a {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersion} in the * {@link google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionState.DESTROY_SCHEDULED|DESTROY_SCHEDULED} @@ -1659,11 +1671,12 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|undefined, {}|undefined>, + protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.kms.v1.ICryptoKeyVersion, - protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|undefined, - {}|undefined>): + protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.kms.v1.ICryptoKeyVersion, protos.google.cloud.kms.v1.IRestoreCryptoKeyVersionRequest|undefined, {}|undefined @@ -1702,13 +1715,13 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.cloud.kms.v1.IListKeyRingsRequest, - protos.google.cloud.kms.v1.IListKeyRingsResponse|null, + protos.google.cloud.kms.v1.IListKeyRingsResponse|null|undefined, protos.google.cloud.kms.v1.IKeyRing>): void; listKeyRings( request: protos.google.cloud.kms.v1.IListKeyRingsRequest, callback: PaginationCallback< protos.google.cloud.kms.v1.IListKeyRingsRequest, - protos.google.cloud.kms.v1.IListKeyRingsResponse|null, + protos.google.cloud.kms.v1.IListKeyRingsResponse|null|undefined, protos.google.cloud.kms.v1.IKeyRing>): void; /** * Lists {@link google.cloud.kms.v1.KeyRing|KeyRings}. @@ -1753,11 +1766,11 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IListKeyRingsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.cloud.kms.v1.IListKeyRingsRequest, - protos.google.cloud.kms.v1.IListKeyRingsResponse|null, + protos.google.cloud.kms.v1.IListKeyRingsResponse|null|undefined, protos.google.cloud.kms.v1.IKeyRing>, callback?: PaginationCallback< protos.google.cloud.kms.v1.IListKeyRingsRequest, - protos.google.cloud.kms.v1.IListKeyRingsResponse|null, + protos.google.cloud.kms.v1.IListKeyRingsResponse|null|undefined, protos.google.cloud.kms.v1.IKeyRing>): Promise<[ protos.google.cloud.kms.v1.IKeyRing[], @@ -1842,6 +1855,57 @@ export class KeyManagementServiceClient { callSettings ); } + +/** + * Equivalent to {@link listKeyRings}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the location associated with the + * {@link google.cloud.kms.v1.KeyRing|KeyRings}, in the format `projects/* /locations/*`. + * @param {number} request.pageSize + * Optional limit on the number of {@link google.cloud.kms.v1.KeyRing|KeyRings} to include in the + * response. Further {@link google.cloud.kms.v1.KeyRing|KeyRings} can subsequently be obtained by + * including the {@link google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token} in a subsequent + * request. If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * Optional pagination token, returned earlier via + * {@link google.cloud.kms.v1.ListKeyRingsResponse.next_page_token|ListKeyRingsResponse.next_page_token}. + * @param {string} request.filter + * Optional. Only include resources that match the filter in the response. + * @param {string} request.orderBy + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listKeyRingsAsync( + request?: protos.google.cloud.kms.v1.IListKeyRingsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listKeyRings.asyncIterate( + this.innerApiCalls['listKeyRings'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listCryptoKeys( request: protos.google.cloud.kms.v1.IListCryptoKeysRequest, options?: gax.CallOptions): @@ -1855,13 +1919,13 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.cloud.kms.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.v1.IListCryptoKeysResponse|null, + protos.google.cloud.kms.v1.IListCryptoKeysResponse|null|undefined, protos.google.cloud.kms.v1.ICryptoKey>): void; listCryptoKeys( request: protos.google.cloud.kms.v1.IListCryptoKeysRequest, callback: PaginationCallback< protos.google.cloud.kms.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.v1.IListCryptoKeysResponse|null, + protos.google.cloud.kms.v1.IListCryptoKeysResponse|null|undefined, protos.google.cloud.kms.v1.ICryptoKey>): void; /** * Lists {@link google.cloud.kms.v1.CryptoKey|CryptoKeys}. @@ -1908,11 +1972,11 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IListCryptoKeysRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.cloud.kms.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.v1.IListCryptoKeysResponse|null, + protos.google.cloud.kms.v1.IListCryptoKeysResponse|null|undefined, protos.google.cloud.kms.v1.ICryptoKey>, callback?: PaginationCallback< protos.google.cloud.kms.v1.IListCryptoKeysRequest, - protos.google.cloud.kms.v1.IListCryptoKeysResponse|null, + protos.google.cloud.kms.v1.IListCryptoKeysResponse|null|undefined, protos.google.cloud.kms.v1.ICryptoKey>): Promise<[ protos.google.cloud.kms.v1.ICryptoKey[], @@ -1999,6 +2063,59 @@ export class KeyManagementServiceClient { callSettings ); } + +/** + * Equivalent to {@link listCryptoKeys}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the {@link google.cloud.kms.v1.KeyRing|KeyRing} to list, in the format + * `projects/* /locations/* /keyRings/*`. + * @param {number} request.pageSize + * Optional limit on the number of {@link google.cloud.kms.v1.CryptoKey|CryptoKeys} to include in the + * response. Further {@link google.cloud.kms.v1.CryptoKey|CryptoKeys} can subsequently be obtained by + * including the {@link google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token} in a subsequent + * request. If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * Optional pagination token, returned earlier via + * {@link google.cloud.kms.v1.ListCryptoKeysResponse.next_page_token|ListCryptoKeysResponse.next_page_token}. + * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.versionView + * The fields of the primary version to include in the response. + * @param {string} request.filter + * Optional. Only include resources that match the filter in the response. + * @param {string} request.orderBy + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listCryptoKeysAsync( + request?: protos.google.cloud.kms.v1.IListCryptoKeysRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listCryptoKeys.asyncIterate( + this.innerApiCalls['listCryptoKeys'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listCryptoKeyVersions( request: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, options?: gax.CallOptions): @@ -2012,13 +2129,13 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null, + protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null|undefined, protos.google.cloud.kms.v1.ICryptoKeyVersion>): void; listCryptoKeyVersions( request: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, callback: PaginationCallback< protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null, + protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null|undefined, protos.google.cloud.kms.v1.ICryptoKeyVersion>): void; /** * Lists {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions}. @@ -2066,11 +2183,11 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null, + protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null|undefined, protos.google.cloud.kms.v1.ICryptoKeyVersion>, callback?: PaginationCallback< protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, - protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null, + protos.google.cloud.kms.v1.IListCryptoKeyVersionsResponse|null|undefined, protos.google.cloud.kms.v1.ICryptoKeyVersion>): Promise<[ protos.google.cloud.kms.v1.ICryptoKeyVersion[], @@ -2158,6 +2275,60 @@ export class KeyManagementServiceClient { callSettings ); } + +/** + * Equivalent to {@link listCryptoKeyVersions}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the {@link google.cloud.kms.v1.CryptoKey|CryptoKey} to list, in the format + * `projects/* /locations/* /keyRings/* /cryptoKeys/*`. + * @param {number} request.pageSize + * Optional limit on the number of {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} to + * include in the response. Further {@link google.cloud.kms.v1.CryptoKeyVersion|CryptoKeyVersions} can + * subsequently be obtained by including the + * {@link google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token} in a subsequent request. + * If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * Optional pagination token, returned earlier via + * {@link google.cloud.kms.v1.ListCryptoKeyVersionsResponse.next_page_token|ListCryptoKeyVersionsResponse.next_page_token}. + * @param {google.cloud.kms.v1.CryptoKeyVersion.CryptoKeyVersionView} request.view + * The fields to include in the response. + * @param {string} request.filter + * Optional. Only include resources that match the filter in the response. + * @param {string} request.orderBy + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listCryptoKeyVersionsAsync( + request?: protos.google.cloud.kms.v1.IListCryptoKeyVersionsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listCryptoKeyVersions.asyncIterate( + this.innerApiCalls['listCryptoKeyVersions'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listImportJobs( request: protos.google.cloud.kms.v1.IListImportJobsRequest, options?: gax.CallOptions): @@ -2171,13 +2342,13 @@ export class KeyManagementServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.cloud.kms.v1.IListImportJobsRequest, - protos.google.cloud.kms.v1.IListImportJobsResponse|null, + protos.google.cloud.kms.v1.IListImportJobsResponse|null|undefined, protos.google.cloud.kms.v1.IImportJob>): void; listImportJobs( request: protos.google.cloud.kms.v1.IListImportJobsRequest, callback: PaginationCallback< protos.google.cloud.kms.v1.IListImportJobsRequest, - protos.google.cloud.kms.v1.IListImportJobsResponse|null, + protos.google.cloud.kms.v1.IListImportJobsResponse|null|undefined, protos.google.cloud.kms.v1.IImportJob>): void; /** * Lists {@link google.cloud.kms.v1.ImportJob|ImportJobs}. @@ -2222,11 +2393,11 @@ export class KeyManagementServiceClient { request: protos.google.cloud.kms.v1.IListImportJobsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.cloud.kms.v1.IListImportJobsRequest, - protos.google.cloud.kms.v1.IListImportJobsResponse|null, + protos.google.cloud.kms.v1.IListImportJobsResponse|null|undefined, protos.google.cloud.kms.v1.IImportJob>, callback?: PaginationCallback< protos.google.cloud.kms.v1.IListImportJobsRequest, - protos.google.cloud.kms.v1.IListImportJobsResponse|null, + protos.google.cloud.kms.v1.IListImportJobsResponse|null|undefined, protos.google.cloud.kms.v1.IImportJob>): Promise<[ protos.google.cloud.kms.v1.IImportJob[], @@ -2312,6 +2483,57 @@ export class KeyManagementServiceClient { ); } +/** + * Equivalent to {@link listImportJobs}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the {@link google.cloud.kms.v1.KeyRing|KeyRing} to list, in the format + * `projects/* /locations/* /keyRings/*`. + * @param {number} request.pageSize + * Optional limit on the number of {@link google.cloud.kms.v1.ImportJob|ImportJobs} to include in the + * response. Further {@link google.cloud.kms.v1.ImportJob|ImportJobs} can subsequently be obtained by + * including the {@link google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token} in a subsequent + * request. If unspecified, the server will pick an appropriate default. + * @param {string} request.pageToken + * Optional pagination token, returned earlier via + * {@link google.cloud.kms.v1.ListImportJobsResponse.next_page_token|ListImportJobsResponse.next_page_token}. + * @param {string} request.filter + * Optional. Only include resources that match the filter in the response. + * @param {string} request.orderBy + * Optional. Specify how the results should be sorted. If not specified, the + * results will be sorted in the default order. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listImportJobsAsync( + request?: protos.google.cloud.kms.v1.IListImportJobsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listImportJobs.asyncIterate( + this.innerApiCalls['listImportJobs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } + /** * Terminate the GRPC channel and close the client. * diff --git a/baselines/kms/test/gapic_key_management_service_v1.ts.baseline b/baselines/kms/test/gapic_key_management_service_v1.ts.baseline index faeae60c2..a0fb18587 100644 --- a/baselines/kms/test/gapic_key_management_service_v1.ts.baseline +++ b/baselines/kms/test/gapic_key_management_service_v1.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v1.KeyManagementServiceClient', () => { it('has servicePath', () => { const servicePath = keymanagementserviceModule.v1.KeyManagementServiceClient.servicePath; @@ -1870,7 +1890,7 @@ describe('v1.KeyManagementServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listKeyRings.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listKeyRings, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listKeyRings.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -1904,12 +1924,69 @@ describe('v1.KeyManagementServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listKeyRings.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listKeyRings, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listKeyRings.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listKeyRings without error', async () => { + const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.kms.v1.ListKeyRingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + generateSampleMessage(new protos.google.cloud.kms.v1.KeyRing()), + ]; + client.descriptors.page.listKeyRings.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.IKeyRing[] = []; + const iterable = client.listKeyRingsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listKeyRings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listKeyRings.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listKeyRings with error', async () => { + const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.kms.v1.ListKeyRingsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listKeyRings.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listKeyRingsAsync(request); + assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.IKeyRing[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listKeyRings.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listKeyRings.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listCryptoKeys', () => { @@ -2035,7 +2112,7 @@ describe('v1.KeyManagementServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listCryptoKeys.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listCryptoKeys, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listCryptoKeys.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -2069,12 +2146,69 @@ describe('v1.KeyManagementServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listCryptoKeys.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listCryptoKeys, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listCryptoKeys.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listCryptoKeys without error', async () => { + const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.kms.v1.ListCryptoKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKey()), + ]; + client.descriptors.page.listCryptoKeys.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.ICryptoKey[] = []; + const iterable = client.listCryptoKeysAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCryptoKeys with error', async () => { + const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.kms.v1.ListCryptoKeysRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCryptoKeys.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCryptoKeysAsync(request); + assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.ICryptoKey[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCryptoKeys.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listCryptoKeyVersions', () => { @@ -2200,7 +2334,7 @@ describe('v1.KeyManagementServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listCryptoKeyVersions.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listCryptoKeyVersions, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listCryptoKeyVersions.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -2234,12 +2368,69 @@ describe('v1.KeyManagementServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listCryptoKeyVersions.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listCryptoKeyVersions, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listCryptoKeyVersions.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listCryptoKeyVersions without error', async () => { + const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), + generateSampleMessage(new protos.google.cloud.kms.v1.CryptoKeyVersion()), + ]; + client.descriptors.page.listCryptoKeyVersions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.ICryptoKeyVersion[] = []; + const iterable = client.listCryptoKeyVersionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listCryptoKeyVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCryptoKeyVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listCryptoKeyVersions with error', async () => { + const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.kms.v1.ListCryptoKeyVersionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listCryptoKeyVersions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listCryptoKeyVersionsAsync(request); + assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.ICryptoKeyVersion[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listCryptoKeyVersions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listCryptoKeyVersions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listImportJobs', () => { @@ -2365,7 +2556,7 @@ describe('v1.KeyManagementServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listImportJobs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listImportJobs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listImportJobs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -2399,11 +2590,68 @@ describe('v1.KeyManagementServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listImportJobs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listImportJobs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listImportJobs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listImportJobs without error', async () => { + const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.kms.v1.ListImportJobsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + generateSampleMessage(new protos.google.cloud.kms.v1.ImportJob()), + ]; + client.descriptors.page.listImportJobs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.kms.v1.IImportJob[] = []; + const iterable = client.listImportJobsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listImportJobs with error', async () => { + const client = new keymanagementserviceModule.v1.KeyManagementServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.kms.v1.ListImportJobsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listImportJobs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listImportJobsAsync(request); + assert.rejects(async () => { + const responses: protos.google.cloud.kms.v1.IImportJob[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listImportJobs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); }); diff --git a/baselines/logging/package.json b/baselines/logging/package.json index 8e85aa57f..8aa508f6c 100644 --- a/baselines/logging/package.json +++ b/baselines/logging/package.json @@ -24,7 +24,7 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^2.0.0" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/baselines/logging/src/v2/config_service_v2_client.ts.baseline b/baselines/logging/src/v2/config_service_v2_client.ts.baseline index 405c4307e..6674b25d0 100644 --- a/baselines/logging/src/v2/config_service_v2_client.ts.baseline +++ b/baselines/logging/src/v2/config_service_v2_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './config_service_v2_client_config.json'; @@ -262,9 +263,8 @@ export class ConfigServiceV2Client { // and create an API call method for each. const configServiceV2StubMethods = ['listBuckets', 'getBucket', 'updateBucket', 'listSinks', 'getSink', 'createSink', 'updateSink', 'deleteSink', 'listExclusions', 'getExclusion', 'createExclusion', 'updateExclusion', 'deleteExclusion', 'getCmekSettings', 'updateCmekSettings']; - for (const methodName of configServiceV2StubMethods) { - const innerCallPromise = this.configServiceV2Stub.then( + const callPromise = this.configServiceV2Stub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -277,20 +277,14 @@ export class ConfigServiceV2Client { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.configServiceV2Stub; @@ -362,14 +356,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ILogBucket, - protos.google.logging.v2.IGetBucketRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IGetBucketRequest|null|undefined, + {}|null|undefined>): void; getBucket( request: protos.google.logging.v2.IGetBucketRequest, callback: Callback< protos.google.logging.v2.ILogBucket, - protos.google.logging.v2.IGetBucketRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IGetBucketRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a bucket (Beta). * @@ -395,11 +389,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IGetBucketRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ILogBucket, - protos.google.logging.v2.IGetBucketRequest|undefined, {}|undefined>, + protos.google.logging.v2.IGetBucketRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ILogBucket, - protos.google.logging.v2.IGetBucketRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IGetBucketRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ILogBucket, protos.google.logging.v2.IGetBucketRequest|undefined, {}|undefined @@ -436,14 +431,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ILogBucket, - protos.google.logging.v2.IUpdateBucketRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IUpdateBucketRequest|null|undefined, + {}|null|undefined>): void; updateBucket( request: protos.google.logging.v2.IUpdateBucketRequest, callback: Callback< protos.google.logging.v2.ILogBucket, - protos.google.logging.v2.IUpdateBucketRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IUpdateBucketRequest|null|undefined, + {}|null|undefined>): void; /** * Updates a bucket. This method replaces the following fields in the * existing bucket with values from the new bucket: `retention_period` @@ -492,11 +487,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IUpdateBucketRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ILogBucket, - protos.google.logging.v2.IUpdateBucketRequest|undefined, {}|undefined>, + protos.google.logging.v2.IUpdateBucketRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ILogBucket, - protos.google.logging.v2.IUpdateBucketRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IUpdateBucketRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ILogBucket, protos.google.logging.v2.IUpdateBucketRequest|undefined, {}|undefined @@ -533,14 +529,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.IGetSinkRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IGetSinkRequest|null|undefined, + {}|null|undefined>): void; getSink( request: protos.google.logging.v2.IGetSinkRequest, callback: Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.IGetSinkRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IGetSinkRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a sink. * @@ -565,11 +561,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IGetSinkRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.IGetSinkRequest|undefined, {}|undefined>, + protos.google.logging.v2.IGetSinkRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.IGetSinkRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IGetSinkRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ILogSink, protos.google.logging.v2.IGetSinkRequest|undefined, {}|undefined @@ -606,14 +603,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.ICreateSinkRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.ICreateSinkRequest|null|undefined, + {}|null|undefined>): void; createSink( request: protos.google.logging.v2.ICreateSinkRequest, callback: Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.ICreateSinkRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.ICreateSinkRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a sink that exports specified log entries to a destination. The * export of newly-ingested log entries begins immediately, unless the sink's @@ -656,11 +653,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.ICreateSinkRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.ICreateSinkRequest|undefined, {}|undefined>, + protos.google.logging.v2.ICreateSinkRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.ICreateSinkRequest|undefined, - {}|undefined>): + protos.google.logging.v2.ICreateSinkRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ILogSink, protos.google.logging.v2.ICreateSinkRequest|undefined, {}|undefined @@ -697,14 +695,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.IUpdateSinkRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IUpdateSinkRequest|null|undefined, + {}|null|undefined>): void; updateSink( request: protos.google.logging.v2.IUpdateSinkRequest, callback: Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.IUpdateSinkRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IUpdateSinkRequest|null|undefined, + {}|null|undefined>): void; /** * Updates a sink. This method replaces the following fields in the existing * sink with values from the new sink: `destination`, and `filter`. @@ -764,11 +762,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IUpdateSinkRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.IUpdateSinkRequest|undefined, {}|undefined>, + protos.google.logging.v2.IUpdateSinkRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ILogSink, - protos.google.logging.v2.IUpdateSinkRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IUpdateSinkRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ILogSink, protos.google.logging.v2.IUpdateSinkRequest|undefined, {}|undefined @@ -805,14 +804,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteSinkRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IDeleteSinkRequest|null|undefined, + {}|null|undefined>): void; deleteSink( request: protos.google.logging.v2.IDeleteSinkRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteSinkRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IDeleteSinkRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a sink. If the sink has a unique `writer_identity`, then that * service account is also deleted. @@ -839,11 +838,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IDeleteSinkRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteSinkRequest|undefined, {}|undefined>, + protos.google.logging.v2.IDeleteSinkRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteSinkRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IDeleteSinkRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.logging.v2.IDeleteSinkRequest|undefined, {}|undefined @@ -880,14 +880,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.IGetExclusionRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IGetExclusionRequest|null|undefined, + {}|null|undefined>): void; getExclusion( request: protos.google.logging.v2.IGetExclusionRequest, callback: Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.IGetExclusionRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IGetExclusionRequest|null|undefined, + {}|null|undefined>): void; /** * Gets the description of an exclusion. * @@ -912,11 +912,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IGetExclusionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.IGetExclusionRequest|undefined, {}|undefined>, + protos.google.logging.v2.IGetExclusionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.IGetExclusionRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IGetExclusionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ILogExclusion, protos.google.logging.v2.IGetExclusionRequest|undefined, {}|undefined @@ -953,14 +954,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.ICreateExclusionRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.ICreateExclusionRequest|null|undefined, + {}|null|undefined>): void; createExclusion( request: protos.google.logging.v2.ICreateExclusionRequest, callback: Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.ICreateExclusionRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.ICreateExclusionRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a new exclusion in a specified parent resource. * Only log entries belonging to that resource can be excluded. @@ -990,11 +991,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.ICreateExclusionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.ICreateExclusionRequest|undefined, {}|undefined>, + protos.google.logging.v2.ICreateExclusionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.ICreateExclusionRequest|undefined, - {}|undefined>): + protos.google.logging.v2.ICreateExclusionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ILogExclusion, protos.google.logging.v2.ICreateExclusionRequest|undefined, {}|undefined @@ -1031,14 +1033,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.IUpdateExclusionRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IUpdateExclusionRequest|null|undefined, + {}|null|undefined>): void; updateExclusion( request: protos.google.logging.v2.IUpdateExclusionRequest, callback: Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.IUpdateExclusionRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IUpdateExclusionRequest|null|undefined, + {}|null|undefined>): void; /** * Changes one or more properties of an existing exclusion. * @@ -1074,11 +1076,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IUpdateExclusionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.IUpdateExclusionRequest|undefined, {}|undefined>, + protos.google.logging.v2.IUpdateExclusionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ILogExclusion, - protos.google.logging.v2.IUpdateExclusionRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IUpdateExclusionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ILogExclusion, protos.google.logging.v2.IUpdateExclusionRequest|undefined, {}|undefined @@ -1115,14 +1118,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteExclusionRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IDeleteExclusionRequest|null|undefined, + {}|null|undefined>): void; deleteExclusion( request: protos.google.logging.v2.IDeleteExclusionRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteExclusionRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IDeleteExclusionRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes an exclusion. * @@ -1147,11 +1150,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IDeleteExclusionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteExclusionRequest|undefined, {}|undefined>, + protos.google.logging.v2.IDeleteExclusionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteExclusionRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IDeleteExclusionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.logging.v2.IDeleteExclusionRequest|undefined, {}|undefined @@ -1188,14 +1192,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ICmekSettings, - protos.google.logging.v2.IGetCmekSettingsRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IGetCmekSettingsRequest|null|undefined, + {}|null|undefined>): void; getCmekSettings( request: protos.google.logging.v2.IGetCmekSettingsRequest, callback: Callback< protos.google.logging.v2.ICmekSettings, - protos.google.logging.v2.IGetCmekSettingsRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IGetCmekSettingsRequest|null|undefined, + {}|null|undefined>): void; /** * Gets the Logs Router CMEK settings for the given resource. * @@ -1231,11 +1235,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IGetCmekSettingsRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ICmekSettings, - protos.google.logging.v2.IGetCmekSettingsRequest|undefined, {}|undefined>, + protos.google.logging.v2.IGetCmekSettingsRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ICmekSettings, - protos.google.logging.v2.IGetCmekSettingsRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IGetCmekSettingsRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ICmekSettings, protos.google.logging.v2.IGetCmekSettingsRequest|undefined, {}|undefined @@ -1272,14 +1277,14 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ICmekSettings, - protos.google.logging.v2.IUpdateCmekSettingsRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IUpdateCmekSettingsRequest|null|undefined, + {}|null|undefined>): void; updateCmekSettings( request: protos.google.logging.v2.IUpdateCmekSettingsRequest, callback: Callback< protos.google.logging.v2.ICmekSettings, - protos.google.logging.v2.IUpdateCmekSettingsRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IUpdateCmekSettingsRequest|null|undefined, + {}|null|undefined>): void; /** * Updates the Logs Router CMEK settings for the given resource. * @@ -1334,11 +1339,12 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IUpdateCmekSettingsRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ICmekSettings, - protos.google.logging.v2.IUpdateCmekSettingsRequest|undefined, {}|undefined>, + protos.google.logging.v2.IUpdateCmekSettingsRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ICmekSettings, - protos.google.logging.v2.IUpdateCmekSettingsRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IUpdateCmekSettingsRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ICmekSettings, protos.google.logging.v2.IUpdateCmekSettingsRequest|undefined, {}|undefined @@ -1377,13 +1383,13 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: PaginationCallback< protos.google.logging.v2.IListBucketsRequest, - protos.google.logging.v2.IListBucketsResponse|null, + protos.google.logging.v2.IListBucketsResponse|null|undefined, protos.google.logging.v2.ILogBucket>): void; listBuckets( request: protos.google.logging.v2.IListBucketsRequest, callback: PaginationCallback< protos.google.logging.v2.IListBucketsRequest, - protos.google.logging.v2.IListBucketsResponse|null, + protos.google.logging.v2.IListBucketsResponse|null|undefined, protos.google.logging.v2.ILogBucket>): void; /** * Lists buckets (Beta). @@ -1432,11 +1438,11 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IListBucketsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.logging.v2.IListBucketsRequest, - protos.google.logging.v2.IListBucketsResponse|null, + protos.google.logging.v2.IListBucketsResponse|null|undefined, protos.google.logging.v2.ILogBucket>, callback?: PaginationCallback< protos.google.logging.v2.IListBucketsRequest, - protos.google.logging.v2.IListBucketsResponse|null, + protos.google.logging.v2.IListBucketsResponse|null|undefined, protos.google.logging.v2.ILogBucket>): Promise<[ protos.google.logging.v2.ILogBucket[], @@ -1525,6 +1531,61 @@ export class ConfigServiceV2Client { callSettings ); } + +/** + * Equivalent to {@link listBuckets}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose buckets are to be listed: + * + * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" + * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" + * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" + * + * Note: The locations portion of the resource must be specified, but + * supplying the character `-` in place of [LOCATION_ID] will return all + * buckets. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listBucketsAsync( + request?: protos.google.logging.v2.IListBucketsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listBuckets.asyncIterate( + this.innerApiCalls['listBuckets'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listSinks( request: protos.google.logging.v2.IListSinksRequest, options?: gax.CallOptions): @@ -1538,13 +1599,13 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: PaginationCallback< protos.google.logging.v2.IListSinksRequest, - protos.google.logging.v2.IListSinksResponse|null, + protos.google.logging.v2.IListSinksResponse|null|undefined, protos.google.logging.v2.ILogSink>): void; listSinks( request: protos.google.logging.v2.IListSinksRequest, callback: PaginationCallback< protos.google.logging.v2.IListSinksRequest, - protos.google.logging.v2.IListSinksResponse|null, + protos.google.logging.v2.IListSinksResponse|null|undefined, protos.google.logging.v2.ILogSink>): void; /** * Lists sinks. @@ -1589,11 +1650,11 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IListSinksRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.logging.v2.IListSinksRequest, - protos.google.logging.v2.IListSinksResponse|null, + protos.google.logging.v2.IListSinksResponse|null|undefined, protos.google.logging.v2.ILogSink>, callback?: PaginationCallback< protos.google.logging.v2.IListSinksRequest, - protos.google.logging.v2.IListSinksResponse|null, + protos.google.logging.v2.IListSinksResponse|null|undefined, protos.google.logging.v2.ILogSink>): Promise<[ protos.google.logging.v2.ILogSink[], @@ -1678,6 +1739,57 @@ export class ConfigServiceV2Client { callSettings ); } + +/** + * Equivalent to {@link listSinks}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose sinks are to be listed: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listSinksAsync( + request?: protos.google.logging.v2.IListSinksRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listSinks.asyncIterate( + this.innerApiCalls['listSinks'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listExclusions( request: protos.google.logging.v2.IListExclusionsRequest, options?: gax.CallOptions): @@ -1691,13 +1803,13 @@ export class ConfigServiceV2Client { options: gax.CallOptions, callback: PaginationCallback< protos.google.logging.v2.IListExclusionsRequest, - protos.google.logging.v2.IListExclusionsResponse|null, + protos.google.logging.v2.IListExclusionsResponse|null|undefined, protos.google.logging.v2.ILogExclusion>): void; listExclusions( request: protos.google.logging.v2.IListExclusionsRequest, callback: PaginationCallback< protos.google.logging.v2.IListExclusionsRequest, - protos.google.logging.v2.IListExclusionsResponse|null, + protos.google.logging.v2.IListExclusionsResponse|null|undefined, protos.google.logging.v2.ILogExclusion>): void; /** * Lists all the exclusions in a parent resource. @@ -1742,11 +1854,11 @@ export class ConfigServiceV2Client { request: protos.google.logging.v2.IListExclusionsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.logging.v2.IListExclusionsRequest, - protos.google.logging.v2.IListExclusionsResponse|null, + protos.google.logging.v2.IListExclusionsResponse|null|undefined, protos.google.logging.v2.ILogExclusion>, callback?: PaginationCallback< protos.google.logging.v2.IListExclusionsRequest, - protos.google.logging.v2.IListExclusionsResponse|null, + protos.google.logging.v2.IListExclusionsResponse|null|undefined, protos.google.logging.v2.ILogExclusion>): Promise<[ protos.google.logging.v2.ILogExclusion[], @@ -1831,6 +1943,57 @@ export class ConfigServiceV2Client { callSettings ); } + +/** + * Equivalent to {@link listExclusions}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The parent resource whose exclusions are to be listed. + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listExclusionsAsync( + request?: protos.google.logging.v2.IListExclusionsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listExclusions.asyncIterate( + this.innerApiCalls['listExclusions'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/logging/src/v2/logging_service_v2_client.ts.baseline b/baselines/logging/src/v2/logging_service_v2_client.ts.baseline index 2ea21ffe7..67f3bc126 100644 --- a/baselines/logging/src/v2/logging_service_v2_client.ts.baseline +++ b/baselines/logging/src/v2/logging_service_v2_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './logging_service_v2_client_config.json'; @@ -283,9 +284,8 @@ export class LoggingServiceV2Client { // and create an API call method for each. const loggingServiceV2StubMethods = ['deleteLog', 'writeLogEntries', 'listLogEntries', 'listMonitoredResourceDescriptors', 'listLogs']; - for (const methodName of loggingServiceV2StubMethods) { - const innerCallPromise = this.loggingServiceV2Stub.then( + const callPromise = this.loggingServiceV2Stub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -298,20 +298,14 @@ export class LoggingServiceV2Client { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.loggingServiceV2Stub; @@ -384,14 +378,14 @@ export class LoggingServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteLogRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IDeleteLogRequest|null|undefined, + {}|null|undefined>): void; deleteLog( request: protos.google.logging.v2.IDeleteLogRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteLogRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IDeleteLogRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes all the log entries in a log. The log reappears if it receives new * entries. Log entries written shortly before the delete operation might not @@ -423,11 +417,12 @@ export class LoggingServiceV2Client { request: protos.google.logging.v2.IDeleteLogRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteLogRequest|undefined, {}|undefined>, + protos.google.logging.v2.IDeleteLogRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteLogRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IDeleteLogRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.logging.v2.IDeleteLogRequest|undefined, {}|undefined @@ -464,14 +459,14 @@ export class LoggingServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.IWriteLogEntriesResponse, - protos.google.logging.v2.IWriteLogEntriesRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IWriteLogEntriesRequest|null|undefined, + {}|null|undefined>): void; writeLogEntries( request: protos.google.logging.v2.IWriteLogEntriesRequest, callback: Callback< protos.google.logging.v2.IWriteLogEntriesResponse, - protos.google.logging.v2.IWriteLogEntriesRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IWriteLogEntriesRequest|null|undefined, + {}|null|undefined>): void; /** * Writes log entries to Logging. This API method is the * only way to send log entries to Logging. This method @@ -559,11 +554,12 @@ export class LoggingServiceV2Client { request: protos.google.logging.v2.IWriteLogEntriesRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.IWriteLogEntriesResponse, - protos.google.logging.v2.IWriteLogEntriesRequest|undefined, {}|undefined>, + protos.google.logging.v2.IWriteLogEntriesRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.IWriteLogEntriesResponse, - protos.google.logging.v2.IWriteLogEntriesRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IWriteLogEntriesRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.IWriteLogEntriesResponse, protos.google.logging.v2.IWriteLogEntriesRequest|undefined, {}|undefined @@ -595,13 +591,13 @@ export class LoggingServiceV2Client { options: gax.CallOptions, callback: PaginationCallback< protos.google.logging.v2.IListLogEntriesRequest, - protos.google.logging.v2.IListLogEntriesResponse|null, + protos.google.logging.v2.IListLogEntriesResponse|null|undefined, protos.google.logging.v2.ILogEntry>): void; listLogEntries( request: protos.google.logging.v2.IListLogEntriesRequest, callback: PaginationCallback< protos.google.logging.v2.IListLogEntriesRequest, - protos.google.logging.v2.IListLogEntriesResponse|null, + protos.google.logging.v2.IListLogEntriesResponse|null|undefined, protos.google.logging.v2.ILogEntry>): void; /** * Lists log entries. Use this method to retrieve log entries that originated @@ -667,11 +663,11 @@ export class LoggingServiceV2Client { request: protos.google.logging.v2.IListLogEntriesRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.logging.v2.IListLogEntriesRequest, - protos.google.logging.v2.IListLogEntriesResponse|null, + protos.google.logging.v2.IListLogEntriesResponse|null|undefined, protos.google.logging.v2.ILogEntry>, callback?: PaginationCallback< protos.google.logging.v2.IListLogEntriesRequest, - protos.google.logging.v2.IListLogEntriesResponse|null, + protos.google.logging.v2.IListLogEntriesResponse|null|undefined, protos.google.logging.v2.ILogEntry>): Promise<[ protos.google.logging.v2.ILogEntry[], @@ -761,6 +757,69 @@ export class LoggingServiceV2Client { callSettings ); } + +/** + * Equivalent to {@link listLogEntries}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string[]} request.resourceNames + * Required. Names of one or more parent resources from which to + * retrieve log entries: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * + * + * Projects listed in the `project_ids` field are added to this list. + * @param {string} [request.filter] + * Optional. A filter that chooses which log entries to return. See [Advanced + * Logs Queries](/logging/docs/view/advanced-queries). Only log entries that + * match the filter are returned. An empty filter matches all log entries in + * the resources listed in `resource_names`. Referencing a parent resource + * that is not listed in `resource_names` will cause the filter to return no + * results. + * The maximum length of the filter is 20000 characters. + * @param {string} [request.orderBy] + * Optional. How the results should be sorted. Presently, the only permitted + * values are `"timestamp asc"` (default) and `"timestamp desc"`. The first + * option returns entries in order of increasing values of + * `LogEntry.timestamp` (oldest first), and the second option returns entries + * in order of decreasing timestamps (newest first). Entries with equal + * timestamps are returned in order of their `insert_id` values. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `next_page_token` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `page_token` must be the value of + * `next_page_token` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listLogEntriesAsync( + request?: protos.google.logging.v2.IListLogEntriesRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listLogEntries.asyncIterate( + this.innerApiCalls['listLogEntries'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listMonitoredResourceDescriptors( request: protos.google.logging.v2.IListMonitoredResourceDescriptorsRequest, options?: gax.CallOptions): @@ -774,13 +833,13 @@ export class LoggingServiceV2Client { options: gax.CallOptions, callback: PaginationCallback< protos.google.logging.v2.IListMonitoredResourceDescriptorsRequest, - protos.google.logging.v2.IListMonitoredResourceDescriptorsResponse|null, + protos.google.logging.v2.IListMonitoredResourceDescriptorsResponse|null|undefined, protos.google.api.IMonitoredResourceDescriptor>): void; listMonitoredResourceDescriptors( request: protos.google.logging.v2.IListMonitoredResourceDescriptorsRequest, callback: PaginationCallback< protos.google.logging.v2.IListMonitoredResourceDescriptorsRequest, - protos.google.logging.v2.IListMonitoredResourceDescriptorsResponse|null, + protos.google.logging.v2.IListMonitoredResourceDescriptorsResponse|null|undefined, protos.google.api.IMonitoredResourceDescriptor>): void; /** * Lists the descriptors for monitored resource types used by Logging. @@ -818,11 +877,11 @@ export class LoggingServiceV2Client { request: protos.google.logging.v2.IListMonitoredResourceDescriptorsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.logging.v2.IListMonitoredResourceDescriptorsRequest, - protos.google.logging.v2.IListMonitoredResourceDescriptorsResponse|null, + protos.google.logging.v2.IListMonitoredResourceDescriptorsResponse|null|undefined, protos.google.api.IMonitoredResourceDescriptor>, callback?: PaginationCallback< protos.google.logging.v2.IListMonitoredResourceDescriptorsRequest, - protos.google.logging.v2.IListMonitoredResourceDescriptorsResponse|null, + protos.google.logging.v2.IListMonitoredResourceDescriptorsResponse|null|undefined, protos.google.api.IMonitoredResourceDescriptor>): Promise<[ protos.google.api.IMonitoredResourceDescriptor[], @@ -886,6 +945,43 @@ export class LoggingServiceV2Client { callSettings ); } + +/** + * Equivalent to {@link listMonitoredResourceDescriptors}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listMonitoredResourceDescriptorsAsync( + request?: protos.google.logging.v2.IListMonitoredResourceDescriptorsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listMonitoredResourceDescriptors.asyncIterate( + this.innerApiCalls['listMonitoredResourceDescriptors'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listLogs( request: protos.google.logging.v2.IListLogsRequest, options?: gax.CallOptions): @@ -899,13 +995,13 @@ export class LoggingServiceV2Client { options: gax.CallOptions, callback: PaginationCallback< protos.google.logging.v2.IListLogsRequest, - protos.google.logging.v2.IListLogsResponse|null, + protos.google.logging.v2.IListLogsResponse|null|undefined, string>): void; listLogs( request: protos.google.logging.v2.IListLogsRequest, callback: PaginationCallback< protos.google.logging.v2.IListLogsRequest, - protos.google.logging.v2.IListLogsResponse|null, + protos.google.logging.v2.IListLogsResponse|null|undefined, string>): void; /** * Lists the logs in projects, organizations, folders, or billing accounts. @@ -951,11 +1047,11 @@ export class LoggingServiceV2Client { request: protos.google.logging.v2.IListLogsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.logging.v2.IListLogsRequest, - protos.google.logging.v2.IListLogsResponse|null, + protos.google.logging.v2.IListLogsResponse|null|undefined, string>, callback?: PaginationCallback< protos.google.logging.v2.IListLogsRequest, - protos.google.logging.v2.IListLogsResponse|null, + protos.google.logging.v2.IListLogsResponse|null|undefined, string>): Promise<[ string[], @@ -1040,6 +1136,57 @@ export class LoggingServiceV2Client { callSettings ); } + +/** + * Equivalent to {@link listLogs}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name that owns the logs: + * + * "projects/[PROJECT_ID]" + * "organizations/[ORGANIZATION_ID]" + * "billingAccounts/[BILLING_ACCOUNT_ID]" + * "folders/[FOLDER_ID]" + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listLogsAsync( + request?: protos.google.logging.v2.IListLogsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listLogs.asyncIterate( + this.innerApiCalls['listLogs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/logging/src/v2/metrics_service_v2_client.ts.baseline b/baselines/logging/src/v2/metrics_service_v2_client.ts.baseline index 0e2ba7c35..8438925f8 100644 --- a/baselines/logging/src/v2/metrics_service_v2_client.ts.baseline +++ b/baselines/logging/src/v2/metrics_service_v2_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './metrics_service_v2_client_config.json'; @@ -255,9 +256,8 @@ export class MetricsServiceV2Client { // and create an API call method for each. const metricsServiceV2StubMethods = ['listLogMetrics', 'getLogMetric', 'createLogMetric', 'updateLogMetric', 'deleteLogMetric']; - for (const methodName of metricsServiceV2StubMethods) { - const innerCallPromise = this.metricsServiceV2Stub.then( + const callPromise = this.metricsServiceV2Stub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -270,20 +270,14 @@ export class MetricsServiceV2Client { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.metricsServiceV2Stub; @@ -356,14 +350,14 @@ export class MetricsServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.IGetLogMetricRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IGetLogMetricRequest|null|undefined, + {}|null|undefined>): void; getLogMetric( request: protos.google.logging.v2.IGetLogMetricRequest, callback: Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.IGetLogMetricRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IGetLogMetricRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a logs-based metric. * @@ -383,11 +377,12 @@ export class MetricsServiceV2Client { request: protos.google.logging.v2.IGetLogMetricRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.IGetLogMetricRequest|undefined, {}|undefined>, + protos.google.logging.v2.IGetLogMetricRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.IGetLogMetricRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IGetLogMetricRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ILogMetric, protos.google.logging.v2.IGetLogMetricRequest|undefined, {}|undefined @@ -424,14 +419,14 @@ export class MetricsServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.ICreateLogMetricRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.ICreateLogMetricRequest|null|undefined, + {}|null|undefined>): void; createLogMetric( request: protos.google.logging.v2.ICreateLogMetricRequest, callback: Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.ICreateLogMetricRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.ICreateLogMetricRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a logs-based metric. * @@ -456,11 +451,12 @@ export class MetricsServiceV2Client { request: protos.google.logging.v2.ICreateLogMetricRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.ICreateLogMetricRequest|undefined, {}|undefined>, + protos.google.logging.v2.ICreateLogMetricRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.ICreateLogMetricRequest|undefined, - {}|undefined>): + protos.google.logging.v2.ICreateLogMetricRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ILogMetric, protos.google.logging.v2.ICreateLogMetricRequest|undefined, {}|undefined @@ -497,14 +493,14 @@ export class MetricsServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.IUpdateLogMetricRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IUpdateLogMetricRequest|null|undefined, + {}|null|undefined>): void; updateLogMetric( request: protos.google.logging.v2.IUpdateLogMetricRequest, callback: Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.IUpdateLogMetricRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IUpdateLogMetricRequest|null|undefined, + {}|null|undefined>): void; /** * Creates or updates a logs-based metric. * @@ -530,11 +526,12 @@ export class MetricsServiceV2Client { request: protos.google.logging.v2.IUpdateLogMetricRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.IUpdateLogMetricRequest|undefined, {}|undefined>, + protos.google.logging.v2.IUpdateLogMetricRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.logging.v2.ILogMetric, - protos.google.logging.v2.IUpdateLogMetricRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IUpdateLogMetricRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.logging.v2.ILogMetric, protos.google.logging.v2.IUpdateLogMetricRequest|undefined, {}|undefined @@ -571,14 +568,14 @@ export class MetricsServiceV2Client { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteLogMetricRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IDeleteLogMetricRequest|null|undefined, + {}|null|undefined>): void; deleteLogMetric( request: protos.google.logging.v2.IDeleteLogMetricRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteLogMetricRequest|undefined, - {}|undefined>): void; + protos.google.logging.v2.IDeleteLogMetricRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a logs-based metric. * @@ -598,11 +595,12 @@ export class MetricsServiceV2Client { request: protos.google.logging.v2.IDeleteLogMetricRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteLogMetricRequest|undefined, {}|undefined>, + protos.google.logging.v2.IDeleteLogMetricRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.logging.v2.IDeleteLogMetricRequest|undefined, - {}|undefined>): + protos.google.logging.v2.IDeleteLogMetricRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.logging.v2.IDeleteLogMetricRequest|undefined, {}|undefined @@ -641,13 +639,13 @@ export class MetricsServiceV2Client { options: gax.CallOptions, callback: PaginationCallback< protos.google.logging.v2.IListLogMetricsRequest, - protos.google.logging.v2.IListLogMetricsResponse|null, + protos.google.logging.v2.IListLogMetricsResponse|null|undefined, protos.google.logging.v2.ILogMetric>): void; listLogMetrics( request: protos.google.logging.v2.IListLogMetricsRequest, callback: PaginationCallback< protos.google.logging.v2.IListLogMetricsRequest, - protos.google.logging.v2.IListLogMetricsResponse|null, + protos.google.logging.v2.IListLogMetricsResponse|null|undefined, protos.google.logging.v2.ILogMetric>): void; /** * Lists logs-based metrics. @@ -689,11 +687,11 @@ export class MetricsServiceV2Client { request: protos.google.logging.v2.IListLogMetricsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.logging.v2.IListLogMetricsRequest, - protos.google.logging.v2.IListLogMetricsResponse|null, + protos.google.logging.v2.IListLogMetricsResponse|null|undefined, protos.google.logging.v2.ILogMetric>, callback?: PaginationCallback< protos.google.logging.v2.IListLogMetricsRequest, - protos.google.logging.v2.IListLogMetricsResponse|null, + protos.google.logging.v2.IListLogMetricsResponse|null|undefined, protos.google.logging.v2.ILogMetric>): Promise<[ protos.google.logging.v2.ILogMetric[], @@ -775,6 +773,54 @@ export class MetricsServiceV2Client { callSettings ); } + +/** + * Equivalent to {@link listLogMetrics}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project containing the metrics: + * + * "projects/[PROJECT_ID]" + * @param {string} [request.pageToken] + * Optional. If present, then retrieve the next batch of results from the + * preceding call to this method. `pageToken` must be the value of + * `nextPageToken` from the previous response. The values of other method + * parameters should be identical to those in the previous call. + * @param {number} [request.pageSize] + * Optional. The maximum number of results to return from this request. + * Non-positive values are ignored. The presence of `nextPageToken` in the + * response indicates that more results might be available. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listLogMetricsAsync( + request?: protos.google.logging.v2.IListLogMetricsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listLogMetrics.asyncIterate( + this.innerApiCalls['listLogMetrics'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/logging/test/gapic_config_service_v2_v2.ts.baseline b/baselines/logging/test/gapic_config_service_v2_v2.ts.baseline index d12c9acfe..cbee78efb 100644 --- a/baselines/logging/test/gapic_config_service_v2_v2.ts.baseline +++ b/baselines/logging/test/gapic_config_service_v2_v2.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v2.ConfigServiceV2Client', () => { it('has servicePath', () => { const servicePath = configservicev2Module.v2.ConfigServiceV2Client.servicePath; @@ -1276,7 +1296,7 @@ describe('v2.ConfigServiceV2Client', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listBuckets.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listBuckets, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listBuckets.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -1310,12 +1330,69 @@ describe('v2.ConfigServiceV2Client', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listBuckets.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listBuckets, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listBuckets.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listBuckets without error', async () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListBucketsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.logging.v2.LogBucket()), + generateSampleMessage(new protos.google.logging.v2.LogBucket()), + generateSampleMessage(new protos.google.logging.v2.LogBucket()), + ]; + client.descriptors.page.listBuckets.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.logging.v2.ILogBucket[] = []; + const iterable = client.listBucketsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBuckets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listBuckets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listBuckets with error', async () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListBucketsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listBuckets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBucketsAsync(request); + assert.rejects(async () => { + const responses: protos.google.logging.v2.ILogBucket[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBuckets.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listBuckets.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listSinks', () => { @@ -1441,7 +1518,7 @@ describe('v2.ConfigServiceV2Client', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listSinks.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listSinks, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listSinks.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -1475,12 +1552,69 @@ describe('v2.ConfigServiceV2Client', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listSinks.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listSinks, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listSinks.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listSinks without error', async () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListSinksRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.logging.v2.LogSink()), + generateSampleMessage(new protos.google.logging.v2.LogSink()), + generateSampleMessage(new protos.google.logging.v2.LogSink()), + ]; + client.descriptors.page.listSinks.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.logging.v2.ILogSink[] = []; + const iterable = client.listSinksAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSinks.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listSinks.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listSinks with error', async () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListSinksRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listSinks.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSinksAsync(request); + assert.rejects(async () => { + const responses: protos.google.logging.v2.ILogSink[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSinks.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listSinks.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listExclusions', () => { @@ -1606,7 +1740,7 @@ describe('v2.ConfigServiceV2Client', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listExclusions.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listExclusions, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listExclusions.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -1640,12 +1774,69 @@ describe('v2.ConfigServiceV2Client', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listExclusions.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listExclusions, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listExclusions.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listExclusions without error', async () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListExclusionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.logging.v2.LogExclusion()), + generateSampleMessage(new protos.google.logging.v2.LogExclusion()), + generateSampleMessage(new protos.google.logging.v2.LogExclusion()), + ]; + client.descriptors.page.listExclusions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.logging.v2.ILogExclusion[] = []; + const iterable = client.listExclusionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listExclusions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listExclusions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listExclusions with error', async () => { + const client = new configservicev2Module.v2.ConfigServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListExclusionsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listExclusions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listExclusionsAsync(request); + assert.rejects(async () => { + const responses: protos.google.logging.v2.ILogExclusion[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listExclusions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listExclusions.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/logging/test/gapic_logging_service_v2_v2.ts.baseline b/baselines/logging/test/gapic_logging_service_v2_v2.ts.baseline index 1ce878a99..9b6fda190 100644 --- a/baselines/logging/test/gapic_logging_service_v2_v2.ts.baseline +++ b/baselines/logging/test/gapic_logging_service_v2_v2.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v2.LoggingServiceV2Client', () => { it('has servicePath', () => { const servicePath = loggingservicev2Module.v2.LoggingServiceV2Client.servicePath; @@ -414,6 +434,49 @@ describe('v2.LoggingServiceV2Client', () => { assert((client.descriptors.page.listLogEntries.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listLogEntries, request)); }); + + it('uses async iteration with listLogEntries without error', async () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListLogEntriesRequest());const expectedResponse = [ + generateSampleMessage(new protos.google.logging.v2.LogEntry()), + generateSampleMessage(new protos.google.logging.v2.LogEntry()), + generateSampleMessage(new protos.google.logging.v2.LogEntry()), + ]; + client.descriptors.page.listLogEntries.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.logging.v2.ILogEntry[] = []; + const iterable = client.listLogEntriesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listLogEntries.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listLogEntries with error', async () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListLogEntriesRequest());const expectedError = new Error('expected'); + client.descriptors.page.listLogEntries.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLogEntriesAsync(request); + assert.rejects(async () => { + const responses: protos.google.logging.v2.ILogEntry[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listLogEntries.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); }); describe('listMonitoredResourceDescriptors', () => { @@ -541,6 +604,49 @@ describe('v2.LoggingServiceV2Client', () => { assert((client.descriptors.page.listMonitoredResourceDescriptors.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listMonitoredResourceDescriptors, request)); }); + + it('uses async iteration with listMonitoredResourceDescriptors without error', async () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListMonitoredResourceDescriptorsRequest());const expectedResponse = [ + generateSampleMessage(new protos.google.api.MonitoredResourceDescriptor()), + generateSampleMessage(new protos.google.api.MonitoredResourceDescriptor()), + generateSampleMessage(new protos.google.api.MonitoredResourceDescriptor()), + ]; + client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.api.IMonitoredResourceDescriptor[] = []; + const iterable = client.listMonitoredResourceDescriptorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listMonitoredResourceDescriptors with error', async () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListMonitoredResourceDescriptorsRequest());const expectedError = new Error('expected'); + client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMonitoredResourceDescriptorsAsync(request); + assert.rejects(async () => { + const responses: protos.google.api.IMonitoredResourceDescriptor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); }); describe('listLogs', () => { @@ -666,7 +772,7 @@ describe('v2.LoggingServiceV2Client', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listLogs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listLogs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listLogs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -700,12 +806,69 @@ describe('v2.LoggingServiceV2Client', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listLogs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listLogs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listLogs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listLogs without error', async () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListLogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protosTYPE_STRING()), + generateSampleMessage(new protosTYPE_STRING()), + generateSampleMessage(new protosTYPE_STRING()), + ]; + client.descriptors.page.listLogs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: string[] = []; + const iterable = client.listLogsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listLogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listLogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listLogs with error', async () => { + const client = new loggingservicev2Module.v2.LoggingServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListLogsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listLogs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLogsAsync(request); + assert.rejects(async () => { + const responses: string[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listLogs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listLogs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/logging/test/gapic_metrics_service_v2_v2.ts.baseline b/baselines/logging/test/gapic_metrics_service_v2_v2.ts.baseline index 9bac47681..7a2bb9091 100644 --- a/baselines/logging/test/gapic_metrics_service_v2_v2.ts.baseline +++ b/baselines/logging/test/gapic_metrics_service_v2_v2.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v2.MetricsServiceV2Client', () => { it('has servicePath', () => { const servicePath = metricsservicev2Module.v2.MetricsServiceV2Client.servicePath; @@ -604,7 +624,7 @@ describe('v2.MetricsServiceV2Client', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listLogMetrics.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listLogMetrics, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listLogMetrics.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -638,12 +658,69 @@ describe('v2.MetricsServiceV2Client', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listLogMetrics.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listLogMetrics, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listLogMetrics.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listLogMetrics without error', async () => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListLogMetricsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.logging.v2.LogMetric()), + generateSampleMessage(new protos.google.logging.v2.LogMetric()), + generateSampleMessage(new protos.google.logging.v2.LogMetric()), + ]; + client.descriptors.page.listLogMetrics.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.logging.v2.ILogMetric[] = []; + const iterable = client.listLogMetricsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listLogMetrics.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listLogMetrics.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listLogMetrics with error', async () => { + const client = new metricsservicev2Module.v2.MetricsServiceV2Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.logging.v2.ListLogMetricsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listLogMetrics.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLogMetricsAsync(request); + assert.rejects(async () => { + const responses: protos.google.logging.v2.ILogMetric[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listLogMetrics.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listLogMetrics.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/monitoring/package.json b/baselines/monitoring/package.json index dbc6bc859..8760eea28 100644 --- a/baselines/monitoring/package.json +++ b/baselines/monitoring/package.json @@ -24,7 +24,7 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^2.0.0" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/baselines/monitoring/src/v3/alert_policy_service_client.ts.baseline b/baselines/monitoring/src/v3/alert_policy_service_client.ts.baseline index 9dc175145..31b736e12 100644 --- a/baselines/monitoring/src/v3/alert_policy_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/alert_policy_service_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './alert_policy_service_client_config.json'; @@ -269,9 +270,8 @@ export class AlertPolicyServiceClient { // and create an API call method for each. const alertPolicyServiceStubMethods = ['listAlertPolicies', 'getAlertPolicy', 'createAlertPolicy', 'deleteAlertPolicy', 'updateAlertPolicy']; - for (const methodName of alertPolicyServiceStubMethods) { - const innerCallPromise = this.alertPolicyServiceStub.then( + const callPromise = this.alertPolicyServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -284,20 +284,14 @@ export class AlertPolicyServiceClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.alertPolicyServiceStub; @@ -368,14 +362,14 @@ export class AlertPolicyServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.IGetAlertPolicyRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetAlertPolicyRequest|null|undefined, + {}|null|undefined>): void; getAlertPolicy( request: protos.google.monitoring.v3.IGetAlertPolicyRequest, callback: Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.IGetAlertPolicyRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetAlertPolicyRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a single alerting policy. * @@ -395,11 +389,12 @@ export class AlertPolicyServiceClient { request: protos.google.monitoring.v3.IGetAlertPolicyRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.IGetAlertPolicyRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IGetAlertPolicyRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.IGetAlertPolicyRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IGetAlertPolicyRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IAlertPolicy, protos.google.monitoring.v3.IGetAlertPolicyRequest|undefined, {}|undefined @@ -436,14 +431,14 @@ export class AlertPolicyServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateAlertPolicyRequest|null|undefined, + {}|null|undefined>): void; createAlertPolicy( request: protos.google.monitoring.v3.ICreateAlertPolicyRequest, callback: Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateAlertPolicyRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a new alerting policy. * @@ -472,11 +467,12 @@ export class AlertPolicyServiceClient { request: protos.google.monitoring.v3.ICreateAlertPolicyRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.ICreateAlertPolicyRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.ICreateAlertPolicyRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IAlertPolicy, protos.google.monitoring.v3.ICreateAlertPolicyRequest|undefined, {}|undefined @@ -513,14 +509,14 @@ export class AlertPolicyServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteAlertPolicyRequest|null|undefined, + {}|null|undefined>): void; deleteAlertPolicy( request: protos.google.monitoring.v3.IDeleteAlertPolicyRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteAlertPolicyRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes an alerting policy. * @@ -542,11 +538,12 @@ export class AlertPolicyServiceClient { request: protos.google.monitoring.v3.IDeleteAlertPolicyRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IDeleteAlertPolicyRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IDeleteAlertPolicyRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.monitoring.v3.IDeleteAlertPolicyRequest|undefined, {}|undefined @@ -583,14 +580,14 @@ export class AlertPolicyServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateAlertPolicyRequest|null|undefined, + {}|null|undefined>): void; updateAlertPolicy( request: protos.google.monitoring.v3.IUpdateAlertPolicyRequest, callback: Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateAlertPolicyRequest|null|undefined, + {}|null|undefined>): void; /** * Updates an alerting policy. You can either replace the entire policy with * a new one or replace only certain fields in the current alerting policy by @@ -636,11 +633,12 @@ export class AlertPolicyServiceClient { request: protos.google.monitoring.v3.IUpdateAlertPolicyRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IUpdateAlertPolicyRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IAlertPolicy, - protos.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IUpdateAlertPolicyRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IAlertPolicy, protos.google.monitoring.v3.IUpdateAlertPolicyRequest|undefined, {}|undefined @@ -679,13 +677,13 @@ export class AlertPolicyServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListAlertPoliciesRequest, - protos.google.monitoring.v3.IListAlertPoliciesResponse|null, + protos.google.monitoring.v3.IListAlertPoliciesResponse|null|undefined, protos.google.monitoring.v3.IAlertPolicy>): void; listAlertPolicies( request: protos.google.monitoring.v3.IListAlertPoliciesRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListAlertPoliciesRequest, - protos.google.monitoring.v3.IListAlertPoliciesResponse|null, + protos.google.monitoring.v3.IListAlertPoliciesResponse|null|undefined, protos.google.monitoring.v3.IAlertPolicy>): void; /** * Lists the existing alerting policies for the project. @@ -743,11 +741,11 @@ export class AlertPolicyServiceClient { request: protos.google.monitoring.v3.IListAlertPoliciesRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListAlertPoliciesRequest, - protos.google.monitoring.v3.IListAlertPoliciesResponse|null, + protos.google.monitoring.v3.IListAlertPoliciesResponse|null|undefined, protos.google.monitoring.v3.IAlertPolicy>, callback?: PaginationCallback< protos.google.monitoring.v3.IListAlertPoliciesRequest, - protos.google.monitoring.v3.IListAlertPoliciesResponse|null, + protos.google.monitoring.v3.IListAlertPoliciesResponse|null|undefined, protos.google.monitoring.v3.IAlertPolicy>): Promise<[ protos.google.monitoring.v3.IAlertPolicy[], @@ -845,6 +843,70 @@ export class AlertPolicyServiceClient { callSettings ); } + +/** + * Equivalent to {@link listAlertPolicies}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project whose alert policies are to be listed. The format is + * + * projects/[PROJECT_ID] + * + * Note that this field names the parent container in which the alerting + * policies to be listed are stored. To retrieve a single alerting policy + * by name, use the + * {@link google.monitoring.v3.AlertPolicyService.GetAlertPolicy|GetAlertPolicy} + * operation, instead. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by + * alert policies to be included in the response. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {string} request.orderBy + * A comma-separated list of fields by which to sort the result. Supports + * the same set of field references as the `filter` field. Entries can be + * prefixed with a minus sign to sort by the field in descending order. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {number} request.pageSize + * The maximum number of results to return in a single response. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return more results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listAlertPoliciesAsync( + request?: protos.google.monitoring.v3.IListAlertPoliciesRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listAlertPolicies.asyncIterate( + this.innerApiCalls['listAlertPolicies'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/monitoring/src/v3/group_service_client.ts.baseline b/baselines/monitoring/src/v3/group_service_client.ts.baseline index 744748dba..1b3c008dd 100644 --- a/baselines/monitoring/src/v3/group_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/group_service_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './group_service_client_config.json'; @@ -274,9 +275,8 @@ export class GroupServiceClient { // and create an API call method for each. const groupServiceStubMethods = ['listGroups', 'getGroup', 'createGroup', 'updateGroup', 'deleteGroup', 'listGroupMembers']; - for (const methodName of groupServiceStubMethods) { - const innerCallPromise = this.groupServiceStub.then( + const callPromise = this.groupServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -289,20 +289,14 @@ export class GroupServiceClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.groupServiceStub; @@ -373,14 +367,14 @@ export class GroupServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.IGetGroupRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetGroupRequest|null|undefined, + {}|null|undefined>): void; getGroup( request: protos.google.monitoring.v3.IGetGroupRequest, callback: Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.IGetGroupRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetGroupRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a single group. * @@ -399,11 +393,12 @@ export class GroupServiceClient { request: protos.google.monitoring.v3.IGetGroupRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.IGetGroupRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IGetGroupRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.IGetGroupRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IGetGroupRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IGroup, protos.google.monitoring.v3.IGetGroupRequest|undefined, {}|undefined @@ -440,14 +435,14 @@ export class GroupServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.ICreateGroupRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateGroupRequest|null|undefined, + {}|null|undefined>): void; createGroup( request: protos.google.monitoring.v3.ICreateGroupRequest, callback: Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.ICreateGroupRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateGroupRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a new group. * @@ -471,11 +466,12 @@ export class GroupServiceClient { request: protos.google.monitoring.v3.ICreateGroupRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.ICreateGroupRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.ICreateGroupRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.ICreateGroupRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.ICreateGroupRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IGroup, protos.google.monitoring.v3.ICreateGroupRequest|undefined, {}|undefined @@ -512,14 +508,14 @@ export class GroupServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.IUpdateGroupRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateGroupRequest|null|undefined, + {}|null|undefined>): void; updateGroup( request: protos.google.monitoring.v3.IUpdateGroupRequest, callback: Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.IUpdateGroupRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateGroupRequest|null|undefined, + {}|null|undefined>): void; /** * Updates an existing group. * You can change any group attributes except `name`. @@ -541,11 +537,12 @@ export class GroupServiceClient { request: protos.google.monitoring.v3.IUpdateGroupRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.IUpdateGroupRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IUpdateGroupRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IGroup, - protos.google.monitoring.v3.IUpdateGroupRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IUpdateGroupRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IGroup, protos.google.monitoring.v3.IUpdateGroupRequest|undefined, {}|undefined @@ -582,14 +579,14 @@ export class GroupServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteGroupRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteGroupRequest|null|undefined, + {}|null|undefined>): void; deleteGroup( request: protos.google.monitoring.v3.IDeleteGroupRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteGroupRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteGroupRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes an existing group. * @@ -612,11 +609,12 @@ export class GroupServiceClient { request: protos.google.monitoring.v3.IDeleteGroupRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteGroupRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IDeleteGroupRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteGroupRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IDeleteGroupRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.monitoring.v3.IDeleteGroupRequest|undefined, {}|undefined @@ -655,13 +653,13 @@ export class GroupServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListGroupsRequest, - protos.google.monitoring.v3.IListGroupsResponse|null, + protos.google.monitoring.v3.IListGroupsResponse|null|undefined, protos.google.monitoring.v3.IGroup>): void; listGroups( request: protos.google.monitoring.v3.IListGroupsRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListGroupsRequest, - protos.google.monitoring.v3.IListGroupsResponse|null, + protos.google.monitoring.v3.IListGroupsResponse|null|undefined, protos.google.monitoring.v3.IGroup>): void; /** * Lists the existing groups. @@ -714,11 +712,11 @@ export class GroupServiceClient { request: protos.google.monitoring.v3.IListGroupsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListGroupsRequest, - protos.google.monitoring.v3.IListGroupsResponse|null, + protos.google.monitoring.v3.IListGroupsResponse|null|undefined, protos.google.monitoring.v3.IGroup>, callback?: PaginationCallback< protos.google.monitoring.v3.IListGroupsRequest, - protos.google.monitoring.v3.IListGroupsResponse|null, + protos.google.monitoring.v3.IListGroupsResponse|null|undefined, protos.google.monitoring.v3.IGroup>): Promise<[ protos.google.monitoring.v3.IGroup[], @@ -811,6 +809,65 @@ export class GroupServiceClient { callSettings ); } + +/** + * Equivalent to {@link listGroups}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project whose groups are to be listed. The format is + * `"projects/{project_id_or_number}"`. + * @param {string} request.childrenOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns groups whose `parentName` field contains the group + * name. If no groups have this parent, the results are empty. + * @param {string} request.ancestorsOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns groups that are ancestors of the specified group. + * The groups are returned in order, starting with the immediate parent and + * ending with the most distant ancestor. If the specified group has no + * immediate parent, the results are empty. + * @param {string} request.descendantsOfGroup + * A group name: `"projects/{project_id_or_number}/groups/{group_id}"`. + * Returns the descendants of the specified group. This is a superset of + * the results returned by the `childrenOfGroup` filter, and includes + * children-of-children, and so forth. + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listGroupsAsync( + request?: protos.google.monitoring.v3.IListGroupsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listGroups.asyncIterate( + this.innerApiCalls['listGroups'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listGroupMembers( request: protos.google.monitoring.v3.IListGroupMembersRequest, options?: gax.CallOptions): @@ -824,13 +881,13 @@ export class GroupServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListGroupMembersRequest, - protos.google.monitoring.v3.IListGroupMembersResponse|null, + protos.google.monitoring.v3.IListGroupMembersResponse|null|undefined, protos.google.api.IMonitoredResource>): void; listGroupMembers( request: protos.google.monitoring.v3.IListGroupMembersRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListGroupMembersRequest, - protos.google.monitoring.v3.IListGroupMembersResponse|null, + protos.google.monitoring.v3.IListGroupMembersResponse|null|undefined, protos.google.api.IMonitoredResource>): void; /** * Lists the monitored resources that are members of a group. @@ -881,11 +938,11 @@ export class GroupServiceClient { request: protos.google.monitoring.v3.IListGroupMembersRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListGroupMembersRequest, - protos.google.monitoring.v3.IListGroupMembersResponse|null, + protos.google.monitoring.v3.IListGroupMembersResponse|null|undefined, protos.google.api.IMonitoredResource>, callback?: PaginationCallback< protos.google.monitoring.v3.IListGroupMembersRequest, - protos.google.monitoring.v3.IListGroupMembersResponse|null, + protos.google.monitoring.v3.IListGroupMembersResponse|null|undefined, protos.google.api.IMonitoredResource>): Promise<[ protos.google.api.IMonitoredResource[], @@ -976,6 +1033,63 @@ export class GroupServiceClient { callSettings ); } + +/** + * Equivalent to {@link listGroupMembers}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The group whose members are listed. The format is + * `"projects/{project_id_or_number}/groups/{group_id}"`. + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {string} request.filter + * An optional [list filter](/monitoring/api/learn_more#filtering) describing + * the members to be returned. The filter may reference the type, labels, and + * metadata of monitored resources that comprise the group. + * For example, to return only resources representing Compute Engine VM + * instances, use this filter: + * + * resource.type = "gce_instance" + * @param {google.monitoring.v3.TimeInterval} request.interval + * An optional time interval for which results should be returned. Only + * members that were part of the group during the specified interval are + * included in the response. If no interval is provided then the group + * membership over the last minute is returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listGroupMembersAsync( + request?: protos.google.monitoring.v3.IListGroupMembersRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listGroupMembers.asyncIterate( + this.innerApiCalls['listGroupMembers'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/monitoring/src/v3/metric_service_client.ts.baseline b/baselines/monitoring/src/v3/metric_service_client.ts.baseline index 86d5f606d..6de244c45 100644 --- a/baselines/monitoring/src/v3/metric_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/metric_service_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './metric_service_client_config.json'; @@ -284,9 +285,8 @@ export class MetricServiceClient { // and create an API call method for each. const metricServiceStubMethods = ['listMonitoredResourceDescriptors', 'getMonitoredResourceDescriptor', 'listMetricDescriptors', 'getMetricDescriptor', 'createMetricDescriptor', 'deleteMetricDescriptor', 'listTimeSeries', 'createTimeSeries']; - for (const methodName of metricServiceStubMethods) { - const innerCallPromise = this.metricServiceStub.then( + const callPromise = this.metricServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -299,20 +299,14 @@ export class MetricServiceClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.metricServiceStub; @@ -384,14 +378,14 @@ export class MetricServiceClient { options: gax.CallOptions, callback: Callback< protos.google.api.IMonitoredResourceDescriptor, - protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|null|undefined, + {}|null|undefined>): void; getMonitoredResourceDescriptor( request: protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, callback: Callback< protos.google.api.IMonitoredResourceDescriptor, - protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a single monitored resource descriptor. This method does not require a Stackdriver account. * @@ -412,11 +406,12 @@ export class MetricServiceClient { request: protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.api.IMonitoredResourceDescriptor, - protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.api.IMonitoredResourceDescriptor, - protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.api.IMonitoredResourceDescriptor, protos.google.monitoring.v3.IGetMonitoredResourceDescriptorRequest|undefined, {}|undefined @@ -453,14 +448,14 @@ export class MetricServiceClient { options: gax.CallOptions, callback: Callback< protos.google.api.IMetricDescriptor, - protos.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetMetricDescriptorRequest|null|undefined, + {}|null|undefined>): void; getMetricDescriptor( request: protos.google.monitoring.v3.IGetMetricDescriptorRequest, callback: Callback< protos.google.api.IMetricDescriptor, - protos.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetMetricDescriptorRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a single metric descriptor. This method does not require a Stackdriver account. * @@ -481,11 +476,12 @@ export class MetricServiceClient { request: protos.google.monitoring.v3.IGetMetricDescriptorRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.api.IMetricDescriptor, - protos.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IGetMetricDescriptorRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.api.IMetricDescriptor, - protos.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IGetMetricDescriptorRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.api.IMetricDescriptor, protos.google.monitoring.v3.IGetMetricDescriptorRequest|undefined, {}|undefined @@ -522,14 +518,14 @@ export class MetricServiceClient { options: gax.CallOptions, callback: Callback< protos.google.api.IMetricDescriptor, - protos.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateMetricDescriptorRequest|null|undefined, + {}|null|undefined>): void; createMetricDescriptor( request: protos.google.monitoring.v3.ICreateMetricDescriptorRequest, callback: Callback< protos.google.api.IMetricDescriptor, - protos.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateMetricDescriptorRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a new metric descriptor. * User-created metric descriptors define @@ -553,11 +549,12 @@ export class MetricServiceClient { request: protos.google.monitoring.v3.ICreateMetricDescriptorRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.api.IMetricDescriptor, - protos.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.ICreateMetricDescriptorRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.api.IMetricDescriptor, - protos.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.ICreateMetricDescriptorRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.api.IMetricDescriptor, protos.google.monitoring.v3.ICreateMetricDescriptorRequest|undefined, {}|undefined @@ -594,14 +591,14 @@ export class MetricServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteMetricDescriptorRequest|null|undefined, + {}|null|undefined>): void; deleteMetricDescriptor( request: protos.google.monitoring.v3.IDeleteMetricDescriptorRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteMetricDescriptorRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a metric descriptor. Only user-created * [custom metrics](/monitoring/custom-metrics) can be deleted. @@ -623,11 +620,12 @@ export class MetricServiceClient { request: protos.google.monitoring.v3.IDeleteMetricDescriptorRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IDeleteMetricDescriptorRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IDeleteMetricDescriptorRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.monitoring.v3.IDeleteMetricDescriptorRequest|undefined, {}|undefined @@ -664,14 +662,14 @@ export class MetricServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateTimeSeriesRequest|null|undefined, + {}|null|undefined>): void; createTimeSeries( request: protos.google.monitoring.v3.ICreateTimeSeriesRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateTimeSeriesRequest|null|undefined, + {}|null|undefined>): void; /** * Creates or adds data to one or more time series. * The response is empty if all time series in the request were written. @@ -701,11 +699,12 @@ export class MetricServiceClient { request: protos.google.monitoring.v3.ICreateTimeSeriesRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.ICreateTimeSeriesRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.ICreateTimeSeriesRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.monitoring.v3.ICreateTimeSeriesRequest|undefined, {}|undefined @@ -744,13 +743,13 @@ export class MetricServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, - protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse|null, + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse|null|undefined, protos.google.api.IMonitoredResourceDescriptor>): void; listMonitoredResourceDescriptors( request: protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, - protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse|null, + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse|null|undefined, protos.google.api.IMonitoredResourceDescriptor>): void; /** * Lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account. @@ -796,11 +795,11 @@ export class MetricServiceClient { request: protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, - protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse|null, + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse|null|undefined, protos.google.api.IMonitoredResourceDescriptor>, callback?: PaginationCallback< protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, - protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse|null, + protos.google.monitoring.v3.IListMonitoredResourceDescriptorsResponse|null|undefined, protos.google.api.IMonitoredResourceDescriptor>): Promise<[ protos.google.api.IMonitoredResourceDescriptor[], @@ -886,6 +885,58 @@ export class MetricServiceClient { callSettings ); } + +/** + * Equivalent to {@link listMonitoredResourceDescriptors}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {string} request.filter + * An optional [filter](/monitoring/api/v3/filters) describing + * the descriptors to be returned. The filter can reference + * the descriptor's type and labels. For example, the + * following filter returns only Google Compute Engine descriptors + * that have an `id` label: + * + * resource.type = starts_with("gce_") AND resource.label:id + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listMonitoredResourceDescriptorsAsync( + request?: protos.google.monitoring.v3.IListMonitoredResourceDescriptorsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listMonitoredResourceDescriptors.asyncIterate( + this.innerApiCalls['listMonitoredResourceDescriptors'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listMetricDescriptors( request: protos.google.monitoring.v3.IListMetricDescriptorsRequest, options?: gax.CallOptions): @@ -899,13 +950,13 @@ export class MetricServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListMetricDescriptorsRequest, - protos.google.monitoring.v3.IListMetricDescriptorsResponse|null, + protos.google.monitoring.v3.IListMetricDescriptorsResponse|null|undefined, protos.google.api.IMetricDescriptor>): void; listMetricDescriptors( request: protos.google.monitoring.v3.IListMetricDescriptorsRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListMetricDescriptorsRequest, - protos.google.monitoring.v3.IListMetricDescriptorsResponse|null, + protos.google.monitoring.v3.IListMetricDescriptorsResponse|null|undefined, protos.google.api.IMetricDescriptor>): void; /** * Lists metric descriptors that match a filter. This method does not require a Stackdriver account. @@ -952,11 +1003,11 @@ export class MetricServiceClient { request: protos.google.monitoring.v3.IListMetricDescriptorsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListMetricDescriptorsRequest, - protos.google.monitoring.v3.IListMetricDescriptorsResponse|null, + protos.google.monitoring.v3.IListMetricDescriptorsResponse|null|undefined, protos.google.api.IMetricDescriptor>, callback?: PaginationCallback< protos.google.monitoring.v3.IListMetricDescriptorsRequest, - protos.google.monitoring.v3.IListMetricDescriptorsResponse|null, + protos.google.monitoring.v3.IListMetricDescriptorsResponse|null|undefined, protos.google.api.IMetricDescriptor>): Promise<[ protos.google.api.IMetricDescriptor[], @@ -1043,6 +1094,59 @@ export class MetricServiceClient { callSettings ); } + +/** + * Equivalent to {@link listMetricDescriptors}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `"projects/{project_id_or_number}"`. + * @param {string} request.filter + * If this field is empty, all custom and + * system-defined metric descriptors are returned. + * Otherwise, the [filter](/monitoring/api/v3/filters) + * specifies which metric descriptors are to be + * returned. For example, the following filter matches all + * [custom metrics](/monitoring/custom-metrics): + * + * metric.type = starts_with("custom.googleapis.com/") + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listMetricDescriptorsAsync( + request?: protos.google.monitoring.v3.IListMetricDescriptorsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listMetricDescriptors.asyncIterate( + this.innerApiCalls['listMetricDescriptors'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listTimeSeries( request: protos.google.monitoring.v3.IListTimeSeriesRequest, options?: gax.CallOptions): @@ -1056,13 +1160,13 @@ export class MetricServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListTimeSeriesRequest, - protos.google.monitoring.v3.IListTimeSeriesResponse|null, + protos.google.monitoring.v3.IListTimeSeriesResponse|null|undefined, protos.google.monitoring.v3.ITimeSeries>): void; listTimeSeries( request: protos.google.monitoring.v3.IListTimeSeriesRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListTimeSeriesRequest, - protos.google.monitoring.v3.IListTimeSeriesResponse|null, + protos.google.monitoring.v3.IListTimeSeriesResponse|null|undefined, protos.google.monitoring.v3.ITimeSeries>): void; /** * Lists time series that match a filter. This method does not require a Stackdriver account. @@ -1127,11 +1231,11 @@ export class MetricServiceClient { request: protos.google.monitoring.v3.IListTimeSeriesRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListTimeSeriesRequest, - protos.google.monitoring.v3.IListTimeSeriesResponse|null, + protos.google.monitoring.v3.IListTimeSeriesResponse|null|undefined, protos.google.monitoring.v3.ITimeSeries>, callback?: PaginationCallback< protos.google.monitoring.v3.IListTimeSeriesRequest, - protos.google.monitoring.v3.IListTimeSeriesResponse|null, + protos.google.monitoring.v3.IListTimeSeriesResponse|null|undefined, protos.google.monitoring.v3.ITimeSeries>): Promise<[ protos.google.monitoring.v3.ITimeSeries[], @@ -1236,6 +1340,77 @@ export class MetricServiceClient { callSettings ); } + +/** + * Equivalent to {@link listTimeSeries}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * "projects/{project_id_or_number}". + * @param {string} request.filter + * Required. A [monitoring filter](/monitoring/api/v3/filters) that specifies which time + * series should be returned. The filter must specify a single metric type, + * and can additionally specify metric labels and other information. For + * example: + * + * metric.type = "compute.googleapis.com/instance/cpu/usage_time" AND + * metric.labels.instance_name = "my-instance-name" + * @param {google.monitoring.v3.TimeInterval} request.interval + * Required. The time interval for which results should be returned. Only time series + * that contain data points in the specified interval are included + * in the response. + * @param {google.monitoring.v3.Aggregation} request.aggregation + * Specifies the alignment of data points in individual time series as + * well as how to combine the retrieved time series across specified labels. + * + * By default (if no `aggregation` is explicitly specified), the raw time + * series data is returned. + * @param {string} request.orderBy + * Unsupported: must be left blank. The points in each time series are + * currently returned in reverse time order (most recent to oldest). + * @param {google.monitoring.v3.ListTimeSeriesRequest.TimeSeriesView} request.view + * Required. Specifies which information is returned about the time series. + * @param {number} request.pageSize + * A positive number that is the maximum number of results to return. If + * `page_size` is empty or more than 100,000 results, the effective + * `page_size` is 100,000 results. If `view` is set to `FULL`, this is the + * maximum number of `Points` returned. If `view` is set to `HEADERS`, this is + * the maximum number of `TimeSeries` returned. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listTimeSeriesAsync( + request?: protos.google.monitoring.v3.IListTimeSeriesRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listTimeSeries.asyncIterate( + this.innerApiCalls['listTimeSeries'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/monitoring/src/v3/notification_channel_service_client.ts.baseline b/baselines/monitoring/src/v3/notification_channel_service_client.ts.baseline index bd48d0733..02a2fad3f 100644 --- a/baselines/monitoring/src/v3/notification_channel_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/notification_channel_service_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './notification_channel_service_client_config.json'; @@ -264,9 +265,8 @@ export class NotificationChannelServiceClient { // and create an API call method for each. const notificationChannelServiceStubMethods = ['listNotificationChannelDescriptors', 'getNotificationChannelDescriptor', 'listNotificationChannels', 'getNotificationChannel', 'createNotificationChannel', 'updateNotificationChannel', 'deleteNotificationChannel', 'sendNotificationChannelVerificationCode', 'getNotificationChannelVerificationCode', 'verifyNotificationChannel']; - for (const methodName of notificationChannelServiceStubMethods) { - const innerCallPromise = this.notificationChannelServiceStub.then( + const callPromise = this.notificationChannelServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -279,20 +279,14 @@ export class NotificationChannelServiceClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.notificationChannelServiceStub; @@ -363,14 +357,14 @@ export class NotificationChannelServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.INotificationChannelDescriptor, - protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|null|undefined, + {}|null|undefined>): void; getNotificationChannelDescriptor( request: protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, callback: Callback< protos.google.monitoring.v3.INotificationChannelDescriptor, - protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a single channel descriptor. The descriptor indicates which fields * are expected / permitted for a notification channel of the given type. @@ -390,11 +384,12 @@ export class NotificationChannelServiceClient { request: protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.INotificationChannelDescriptor, - protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.INotificationChannelDescriptor, - protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.INotificationChannelDescriptor, protos.google.monitoring.v3.IGetNotificationChannelDescriptorRequest|undefined, {}|undefined @@ -431,14 +426,14 @@ export class NotificationChannelServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IGetNotificationChannelRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetNotificationChannelRequest|null|undefined, + {}|null|undefined>): void; getNotificationChannel( request: protos.google.monitoring.v3.IGetNotificationChannelRequest, callback: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IGetNotificationChannelRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetNotificationChannelRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a single notification channel. The channel includes the relevant * configuration details with which the channel was created. However, the @@ -461,11 +456,12 @@ export class NotificationChannelServiceClient { request: protos.google.monitoring.v3.IGetNotificationChannelRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IGetNotificationChannelRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IGetNotificationChannelRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IGetNotificationChannelRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IGetNotificationChannelRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.INotificationChannel, protos.google.monitoring.v3.IGetNotificationChannelRequest|undefined, {}|undefined @@ -502,14 +498,14 @@ export class NotificationChannelServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateNotificationChannelRequest|null|undefined, + {}|null|undefined>): void; createNotificationChannel( request: protos.google.monitoring.v3.ICreateNotificationChannelRequest, callback: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateNotificationChannelRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a new notification channel, representing a single notification * endpoint such as an email address, SMS number, or PagerDuty service. @@ -537,11 +533,12 @@ export class NotificationChannelServiceClient { request: protos.google.monitoring.v3.ICreateNotificationChannelRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.ICreateNotificationChannelRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.ICreateNotificationChannelRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.INotificationChannel, protos.google.monitoring.v3.ICreateNotificationChannelRequest|undefined, {}|undefined @@ -578,14 +575,14 @@ export class NotificationChannelServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateNotificationChannelRequest|null|undefined, + {}|null|undefined>): void; updateNotificationChannel( request: protos.google.monitoring.v3.IUpdateNotificationChannelRequest, callback: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateNotificationChannelRequest|null|undefined, + {}|null|undefined>): void; /** * Updates a notification channel. Fields not specified in the field mask * remain unchanged. @@ -609,11 +606,12 @@ export class NotificationChannelServiceClient { request: protos.google.monitoring.v3.IUpdateNotificationChannelRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IUpdateNotificationChannelRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IUpdateNotificationChannelRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.INotificationChannel, protos.google.monitoring.v3.IUpdateNotificationChannelRequest|undefined, {}|undefined @@ -650,14 +648,14 @@ export class NotificationChannelServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteNotificationChannelRequest|null|undefined, + {}|null|undefined>): void; deleteNotificationChannel( request: protos.google.monitoring.v3.IDeleteNotificationChannelRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteNotificationChannelRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a notification channel. * @@ -681,11 +679,12 @@ export class NotificationChannelServiceClient { request: protos.google.monitoring.v3.IDeleteNotificationChannelRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IDeleteNotificationChannelRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IDeleteNotificationChannelRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.monitoring.v3.IDeleteNotificationChannelRequest|undefined, {}|undefined @@ -722,14 +721,14 @@ export class NotificationChannelServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|null|undefined, + {}|null|undefined>): void; sendNotificationChannelVerificationCode( request: protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|null|undefined, + {}|null|undefined>): void; /** * Causes a verification code to be delivered to the channel. The code * can then be supplied in `VerifyNotificationChannel` to verify the channel. @@ -748,11 +747,12 @@ export class NotificationChannelServiceClient { request: protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.monitoring.v3.ISendNotificationChannelVerificationCodeRequest|undefined, {}|undefined @@ -789,14 +789,14 @@ export class NotificationChannelServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|null|undefined, + {}|null|undefined>): void; getNotificationChannelVerificationCode( request: protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, callback: Callback< protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|null|undefined, + {}|null|undefined>): void; /** * Requests a verification code for an already verified channel that can then * be used in a call to VerifyNotificationChannel() on a different channel @@ -846,11 +846,12 @@ export class NotificationChannelServiceClient { request: protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, - protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeResponse, protos.google.monitoring.v3.IGetNotificationChannelVerificationCodeRequest|undefined, {}|undefined @@ -887,14 +888,14 @@ export class NotificationChannelServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IVerifyNotificationChannelRequest|null|undefined, + {}|null|undefined>): void; verifyNotificationChannel( request: protos.google.monitoring.v3.IVerifyNotificationChannelRequest, callback: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IVerifyNotificationChannelRequest|null|undefined, + {}|null|undefined>): void; /** * Verifies a `NotificationChannel` by proving receipt of the code * delivered to the channel as a result of calling @@ -922,11 +923,12 @@ export class NotificationChannelServiceClient { request: protos.google.monitoring.v3.IVerifyNotificationChannelRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IVerifyNotificationChannelRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.INotificationChannel, - protos.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IVerifyNotificationChannelRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.INotificationChannel, protos.google.monitoring.v3.IVerifyNotificationChannelRequest|undefined, {}|undefined @@ -965,13 +967,13 @@ export class NotificationChannelServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, - protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse|null, + protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse|null|undefined, protos.google.monitoring.v3.INotificationChannelDescriptor>): void; listNotificationChannelDescriptors( request: protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, - protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse|null, + protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse|null|undefined, protos.google.monitoring.v3.INotificationChannelDescriptor>): void; /** * Lists the descriptors for supported channel types. The use of descriptors @@ -1019,11 +1021,11 @@ export class NotificationChannelServiceClient { request: protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, - protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse|null, + protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse|null|undefined, protos.google.monitoring.v3.INotificationChannelDescriptor>, callback?: PaginationCallback< protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, - protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse|null, + protos.google.monitoring.v3.IListNotificationChannelDescriptorsResponse|null|undefined, protos.google.monitoring.v3.INotificationChannelDescriptor>): Promise<[ protos.google.monitoring.v3.INotificationChannelDescriptor[], @@ -1110,6 +1112,59 @@ export class NotificationChannelServiceClient { callSettings ); } + +/** + * Equivalent to {@link listNotificationChannelDescriptors}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The REST resource name of the parent from which to retrieve + * the notification channel descriptors. The expected syntax is: + * + * projects/[PROJECT_ID] + * + * Note that this names the parent container in which to look for the + * descriptors; to retrieve a single descriptor by name, use the + * {@link google.monitoring.v3.NotificationChannelService.GetNotificationChannelDescriptor|GetNotificationChannelDescriptor} + * operation, instead. + * @param {number} request.pageSize + * The maximum number of results to return in a single response. If + * not set to a positive number, a reasonable value will be chosen by the + * service. + * @param {string} request.pageToken + * If non-empty, `page_token` must contain a value returned as the + * `next_page_token` in a previous response to request the next set + * of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listNotificationChannelDescriptorsAsync( + request?: protos.google.monitoring.v3.IListNotificationChannelDescriptorsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listNotificationChannelDescriptors.asyncIterate( + this.innerApiCalls['listNotificationChannelDescriptors'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listNotificationChannels( request: protos.google.monitoring.v3.IListNotificationChannelsRequest, options?: gax.CallOptions): @@ -1123,13 +1178,13 @@ export class NotificationChannelServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListNotificationChannelsRequest, - protos.google.monitoring.v3.IListNotificationChannelsResponse|null, + protos.google.monitoring.v3.IListNotificationChannelsResponse|null|undefined, protos.google.monitoring.v3.INotificationChannel>): void; listNotificationChannels( request: protos.google.monitoring.v3.IListNotificationChannelsRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListNotificationChannelsRequest, - protos.google.monitoring.v3.IListNotificationChannelsResponse|null, + protos.google.monitoring.v3.IListNotificationChannelsResponse|null|undefined, protos.google.monitoring.v3.INotificationChannel>): void; /** * Lists the notification channels that have been created for the project. @@ -1187,11 +1242,11 @@ export class NotificationChannelServiceClient { request: protos.google.monitoring.v3.IListNotificationChannelsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListNotificationChannelsRequest, - protos.google.monitoring.v3.IListNotificationChannelsResponse|null, + protos.google.monitoring.v3.IListNotificationChannelsResponse|null|undefined, protos.google.monitoring.v3.INotificationChannel>, callback?: PaginationCallback< protos.google.monitoring.v3.IListNotificationChannelsRequest, - protos.google.monitoring.v3.IListNotificationChannelsResponse|null, + protos.google.monitoring.v3.IListNotificationChannelsResponse|null|undefined, protos.google.monitoring.v3.INotificationChannel>): Promise<[ protos.google.monitoring.v3.INotificationChannel[], @@ -1289,6 +1344,70 @@ export class NotificationChannelServiceClient { callSettings ); } + +/** + * Equivalent to {@link listNotificationChannels}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The project on which to execute the request. The format is + * `projects/[PROJECT_ID]`. That is, this names the container + * in which to look for the notification channels; it does not name a + * specific channel. To query a specific channel by REST resource name, use + * the + * {@link google.monitoring.v3.NotificationChannelService.GetNotificationChannel|`GetNotificationChannel`} + * operation. + * @param {string} request.filter + * If provided, this field specifies the criteria that must be met by + * notification channels to be included in the response. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {string} request.orderBy + * A comma-separated list of fields by which to sort the result. Supports + * the same set of fields as in `filter`. Entries can be prefixed with + * a minus sign to sort in descending rather than ascending order. + * + * For more details, see [sorting and + * filtering](/monitoring/api/v3/sorting-and-filtering). + * @param {number} request.pageSize + * The maximum number of results to return in a single response. If + * not set to a positive number, a reasonable value will be chosen by the + * service. + * @param {string} request.pageToken + * If non-empty, `page_token` must contain a value returned as the + * `next_page_token` in a previous response to request the next set + * of results. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listNotificationChannelsAsync( + request?: protos.google.monitoring.v3.IListNotificationChannelsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'name': request.name || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listNotificationChannels.asyncIterate( + this.innerApiCalls['listNotificationChannels'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/monitoring/src/v3/service_monitoring_service_client.ts.baseline b/baselines/monitoring/src/v3/service_monitoring_service_client.ts.baseline index d22792c7d..79dc65b98 100644 --- a/baselines/monitoring/src/v3/service_monitoring_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/service_monitoring_service_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './service_monitoring_service_client_config.json'; @@ -266,9 +267,8 @@ export class ServiceMonitoringServiceClient { // and create an API call method for each. const serviceMonitoringServiceStubMethods = ['createService', 'getService', 'listServices', 'updateService', 'deleteService', 'createServiceLevelObjective', 'getServiceLevelObjective', 'listServiceLevelObjectives', 'updateServiceLevelObjective', 'deleteServiceLevelObjective']; - for (const methodName of serviceMonitoringServiceStubMethods) { - const innerCallPromise = this.serviceMonitoringServiceStub.then( + const callPromise = this.serviceMonitoringServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -281,20 +281,14 @@ export class ServiceMonitoringServiceClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.serviceMonitoringServiceStub; @@ -365,14 +359,14 @@ export class ServiceMonitoringServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.ICreateServiceRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateServiceRequest|null|undefined, + {}|null|undefined>): void; createService( request: protos.google.monitoring.v3.ICreateServiceRequest, callback: Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.ICreateServiceRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateServiceRequest|null|undefined, + {}|null|undefined>): void; /** * Create a `Service`. * @@ -396,11 +390,12 @@ export class ServiceMonitoringServiceClient { request: protos.google.monitoring.v3.ICreateServiceRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.ICreateServiceRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.ICreateServiceRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.ICreateServiceRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.ICreateServiceRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IService, protos.google.monitoring.v3.ICreateServiceRequest|undefined, {}|undefined @@ -437,14 +432,14 @@ export class ServiceMonitoringServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.IGetServiceRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetServiceRequest|null|undefined, + {}|null|undefined>): void; getService( request: protos.google.monitoring.v3.IGetServiceRequest, callback: Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.IGetServiceRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetServiceRequest|null|undefined, + {}|null|undefined>): void; /** * Get the named `Service`. * @@ -463,11 +458,12 @@ export class ServiceMonitoringServiceClient { request: protos.google.monitoring.v3.IGetServiceRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.IGetServiceRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IGetServiceRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.IGetServiceRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IGetServiceRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IService, protos.google.monitoring.v3.IGetServiceRequest|undefined, {}|undefined @@ -504,14 +500,14 @@ export class ServiceMonitoringServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.IUpdateServiceRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateServiceRequest|null|undefined, + {}|null|undefined>): void; updateService( request: protos.google.monitoring.v3.IUpdateServiceRequest, callback: Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.IUpdateServiceRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateServiceRequest|null|undefined, + {}|null|undefined>): void; /** * Update this `Service`. * @@ -532,11 +528,12 @@ export class ServiceMonitoringServiceClient { request: protos.google.monitoring.v3.IUpdateServiceRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.IUpdateServiceRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IUpdateServiceRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IService, - protos.google.monitoring.v3.IUpdateServiceRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IUpdateServiceRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IService, protos.google.monitoring.v3.IUpdateServiceRequest|undefined, {}|undefined @@ -573,14 +570,14 @@ export class ServiceMonitoringServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteServiceRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteServiceRequest|null|undefined, + {}|null|undefined>): void; deleteService( request: protos.google.monitoring.v3.IDeleteServiceRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteServiceRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteServiceRequest|null|undefined, + {}|null|undefined>): void; /** * Soft delete this `Service`. * @@ -599,11 +596,12 @@ export class ServiceMonitoringServiceClient { request: protos.google.monitoring.v3.IDeleteServiceRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteServiceRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IDeleteServiceRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteServiceRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IDeleteServiceRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.monitoring.v3.IDeleteServiceRequest|undefined, {}|undefined @@ -640,14 +638,14 @@ export class ServiceMonitoringServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): void; createServiceLevelObjective( request: protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, callback: Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): void; /** * Create a `ServiceLevelObjective` for the given `Service`. * @@ -674,11 +672,12 @@ export class ServiceMonitoringServiceClient { request: protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IServiceLevelObjective, protos.google.monitoring.v3.ICreateServiceLevelObjectiveRequest|undefined, {}|undefined @@ -715,14 +714,14 @@ export class ServiceMonitoringServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): void; getServiceLevelObjective( request: protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest, callback: Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): void; /** * Get a `ServiceLevelObjective` by name. * @@ -747,11 +746,12 @@ export class ServiceMonitoringServiceClient { request: protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IServiceLevelObjective, protos.google.monitoring.v3.IGetServiceLevelObjectiveRequest|undefined, {}|undefined @@ -788,14 +788,14 @@ export class ServiceMonitoringServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): void; updateServiceLevelObjective( request: protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, callback: Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): void; /** * Update the given `ServiceLevelObjective`. * @@ -816,11 +816,12 @@ export class ServiceMonitoringServiceClient { request: protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IServiceLevelObjective, - protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IServiceLevelObjective, protos.google.monitoring.v3.IUpdateServiceLevelObjectiveRequest|undefined, {}|undefined @@ -857,14 +858,14 @@ export class ServiceMonitoringServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): void; deleteServiceLevelObjective( request: protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): void; /** * Delete the given `ServiceLevelObjective`. * @@ -884,11 +885,12 @@ export class ServiceMonitoringServiceClient { request: protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.monitoring.v3.IDeleteServiceLevelObjectiveRequest|undefined, {}|undefined @@ -927,13 +929,13 @@ export class ServiceMonitoringServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListServicesRequest, - protos.google.monitoring.v3.IListServicesResponse|null, + protos.google.monitoring.v3.IListServicesResponse|null|undefined, protos.google.monitoring.v3.IService>): void; listServices( request: protos.google.monitoring.v3.IListServicesRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListServicesRequest, - protos.google.monitoring.v3.IListServicesResponse|null, + protos.google.monitoring.v3.IListServicesResponse|null|undefined, protos.google.monitoring.v3.IService>): void; /** * List `Service`s for this workspace. @@ -988,11 +990,11 @@ export class ServiceMonitoringServiceClient { request: protos.google.monitoring.v3.IListServicesRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListServicesRequest, - protos.google.monitoring.v3.IListServicesResponse|null, + protos.google.monitoring.v3.IListServicesResponse|null|undefined, protos.google.monitoring.v3.IService>, callback?: PaginationCallback< protos.google.monitoring.v3.IListServicesRequest, - protos.google.monitoring.v3.IListServicesResponse|null, + protos.google.monitoring.v3.IListServicesResponse|null|undefined, protos.google.monitoring.v3.IService>): Promise<[ protos.google.monitoring.v3.IService[], @@ -1087,6 +1089,67 @@ export class ServiceMonitoringServiceClient { callSettings ); } + +/** + * Equivalent to {@link listServices}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the parent `Workspace`. + * Of the form `projects/{project_id}`. + * @param {string} request.filter + * A filter specifying what `Service`s to return. The filter currently + * supports the following fields: + * + * - `identifier_case` + * - `app_engine.module_id` + * - `cloud_endpoints.service` + * - `cluster_istio.location` + * - `cluster_istio.cluster_name` + * - `cluster_istio.service_namespace` + * - `cluster_istio.service_name` + * + * `identifier_case` refers to which option in the identifier oneof is + * populated. For example, the filter `identifier_case = "CUSTOM"` would match + * all services with a value for the `custom` field. Valid options are + * "CUSTOM", "APP_ENGINE", "CLOUD_ENDPOINTS", and "CLUSTER_ISTIO". + * @param {number} request.pageSize + * A non-negative number that is the maximum number of results to return. + * When 0, use default page size. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listServicesAsync( + request?: protos.google.monitoring.v3.IListServicesRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listServices.asyncIterate( + this.innerApiCalls['listServices'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listServiceLevelObjectives( request: protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, options?: gax.CallOptions): @@ -1100,13 +1163,13 @@ export class ServiceMonitoringServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, - protos.google.monitoring.v3.IListServiceLevelObjectivesResponse|null, + protos.google.monitoring.v3.IListServiceLevelObjectivesResponse|null|undefined, protos.google.monitoring.v3.IServiceLevelObjective>): void; listServiceLevelObjectives( request: protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, - protos.google.monitoring.v3.IListServiceLevelObjectivesResponse|null, + protos.google.monitoring.v3.IListServiceLevelObjectivesResponse|null|undefined, protos.google.monitoring.v3.IServiceLevelObjective>): void; /** * List the `ServiceLevelObjective`s for the given `Service`. @@ -1152,11 +1215,11 @@ export class ServiceMonitoringServiceClient { request: protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, - protos.google.monitoring.v3.IListServiceLevelObjectivesResponse|null, + protos.google.monitoring.v3.IListServiceLevelObjectivesResponse|null|undefined, protos.google.monitoring.v3.IServiceLevelObjective>, callback?: PaginationCallback< protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, - protos.google.monitoring.v3.IListServiceLevelObjectivesResponse|null, + protos.google.monitoring.v3.IListServiceLevelObjectivesResponse|null|undefined, protos.google.monitoring.v3.IServiceLevelObjective>): Promise<[ protos.google.monitoring.v3.IServiceLevelObjective[], @@ -1242,6 +1305,58 @@ export class ServiceMonitoringServiceClient { callSettings ); } + +/** + * Equivalent to {@link listServiceLevelObjectives}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. Resource name of the parent `Service`. + * Of the form `projects/{project_id}/services/{service_id}`. + * @param {string} request.filter + * A filter specifying what `ServiceLevelObjective`s to return. + * @param {number} request.pageSize + * A non-negative number that is the maximum number of results to return. + * When 0, use default page size. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return additional results from the previous method call. + * @param {google.monitoring.v3.ServiceLevelObjective.View} request.view + * View of the `ServiceLevelObjective`s to return. If `DEFAULT`, return each + * `ServiceLevelObjective` as originally defined. If `EXPLICIT` and the + * `ServiceLevelObjective` is defined in terms of a `BasicSli`, replace the + * `BasicSli` with a `RequestBasedSli` spelling out how the SLI is computed. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listServiceLevelObjectivesAsync( + request?: protos.google.monitoring.v3.IListServiceLevelObjectivesRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listServiceLevelObjectives.asyncIterate( + this.innerApiCalls['listServiceLevelObjectives'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/monitoring/src/v3/uptime_check_service_client.ts.baseline b/baselines/monitoring/src/v3/uptime_check_service_client.ts.baseline index fcd449e20..fe391f65e 100644 --- a/baselines/monitoring/src/v3/uptime_check_service_client.ts.baseline +++ b/baselines/monitoring/src/v3/uptime_check_service_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './uptime_check_service_client_config.json'; @@ -270,9 +271,8 @@ export class UptimeCheckServiceClient { // and create an API call method for each. const uptimeCheckServiceStubMethods = ['listUptimeCheckConfigs', 'getUptimeCheckConfig', 'createUptimeCheckConfig', 'updateUptimeCheckConfig', 'deleteUptimeCheckConfig', 'listUptimeCheckIps']; - for (const methodName of uptimeCheckServiceStubMethods) { - const innerCallPromise = this.uptimeCheckServiceStub.then( + const callPromise = this.uptimeCheckServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -285,20 +285,14 @@ export class UptimeCheckServiceClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.uptimeCheckServiceStub; @@ -369,14 +363,14 @@ export class UptimeCheckServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.IGetUptimeCheckConfigRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): void; getUptimeCheckConfig( request: protos.google.monitoring.v3.IGetUptimeCheckConfigRequest, callback: Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.IGetUptimeCheckConfigRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IGetUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a single Uptime check configuration. * @@ -395,11 +389,12 @@ export class UptimeCheckServiceClient { request: protos.google.monitoring.v3.IGetUptimeCheckConfigRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.IGetUptimeCheckConfigRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IGetUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.IGetUptimeCheckConfigRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IGetUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IUptimeCheckConfig, protos.google.monitoring.v3.IGetUptimeCheckConfigRequest|undefined, {}|undefined @@ -436,14 +431,14 @@ export class UptimeCheckServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): void; createUptimeCheckConfig( request: protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest, callback: Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a new Uptime check configuration. * @@ -464,11 +459,12 @@ export class UptimeCheckServiceClient { request: protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IUptimeCheckConfig, protos.google.monitoring.v3.ICreateUptimeCheckConfigRequest|undefined, {}|undefined @@ -505,14 +501,14 @@ export class UptimeCheckServiceClient { options: gax.CallOptions, callback: Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): void; updateUptimeCheckConfig( request: protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, callback: Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): void; /** * Updates an Uptime check configuration. You can either replace the entire * configuration with a new one or replace only certain fields in the current @@ -548,11 +544,12 @@ export class UptimeCheckServiceClient { request: protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.monitoring.v3.IUptimeCheckConfig, - protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.monitoring.v3.IUptimeCheckConfig, protos.google.monitoring.v3.IUpdateUptimeCheckConfigRequest|undefined, {}|undefined @@ -589,14 +586,14 @@ export class UptimeCheckServiceClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): void; deleteUptimeCheckConfig( request: protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|undefined, - {}|undefined>): void; + protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes an Uptime check configuration. Note that this method will fail * if the Uptime check configuration is referenced by an alert policy or @@ -617,11 +614,12 @@ export class UptimeCheckServiceClient { request: protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|undefined, {}|undefined>, + protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|undefined, - {}|undefined>): + protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.monitoring.v3.IDeleteUptimeCheckConfigRequest|undefined, {}|undefined @@ -660,13 +658,13 @@ export class UptimeCheckServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, - protos.google.monitoring.v3.IListUptimeCheckConfigsResponse|null, + protos.google.monitoring.v3.IListUptimeCheckConfigsResponse|null|undefined, protos.google.monitoring.v3.IUptimeCheckConfig>): void; listUptimeCheckConfigs( request: protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, - protos.google.monitoring.v3.IListUptimeCheckConfigsResponse|null, + protos.google.monitoring.v3.IListUptimeCheckConfigsResponse|null|undefined, protos.google.monitoring.v3.IUptimeCheckConfig>): void; /** * Lists the existing valid Uptime check configurations for the project @@ -708,11 +706,11 @@ export class UptimeCheckServiceClient { request: protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, - protos.google.monitoring.v3.IListUptimeCheckConfigsResponse|null, + protos.google.monitoring.v3.IListUptimeCheckConfigsResponse|null|undefined, protos.google.monitoring.v3.IUptimeCheckConfig>, callback?: PaginationCallback< protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, - protos.google.monitoring.v3.IListUptimeCheckConfigsResponse|null, + protos.google.monitoring.v3.IListUptimeCheckConfigsResponse|null|undefined, protos.google.monitoring.v3.IUptimeCheckConfig>): Promise<[ protos.google.monitoring.v3.IUptimeCheckConfig[], @@ -793,6 +791,53 @@ export class UptimeCheckServiceClient { callSettings ); } + +/** + * Equivalent to {@link listUptimeCheckConfigs}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The project whose Uptime check configurations are listed. The format + * is `projects/[PROJECT_ID]`. + * @param {number} request.pageSize + * The maximum number of results to return in a single response. The server + * may further constrain the maximum number of results returned in a single + * page. If the page_size is <=0, the server will decide the number of results + * to be returned. + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return more results from the previous method call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listUptimeCheckConfigsAsync( + request?: protos.google.monitoring.v3.IListUptimeCheckConfigsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listUptimeCheckConfigs.asyncIterate( + this.innerApiCalls['listUptimeCheckConfigs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listUptimeCheckIps( request: protos.google.monitoring.v3.IListUptimeCheckIpsRequest, options?: gax.CallOptions): @@ -806,13 +851,13 @@ export class UptimeCheckServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.monitoring.v3.IListUptimeCheckIpsRequest, - protos.google.monitoring.v3.IListUptimeCheckIpsResponse|null, + protos.google.monitoring.v3.IListUptimeCheckIpsResponse|null|undefined, protos.google.monitoring.v3.IUptimeCheckIp>): void; listUptimeCheckIps( request: protos.google.monitoring.v3.IListUptimeCheckIpsRequest, callback: PaginationCallback< protos.google.monitoring.v3.IListUptimeCheckIpsRequest, - protos.google.monitoring.v3.IListUptimeCheckIpsResponse|null, + protos.google.monitoring.v3.IListUptimeCheckIpsResponse|null|undefined, protos.google.monitoring.v3.IUptimeCheckIp>): void; /** * Returns the list of IP addresses that checkers run from @@ -852,11 +897,11 @@ export class UptimeCheckServiceClient { request: protos.google.monitoring.v3.IListUptimeCheckIpsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.monitoring.v3.IListUptimeCheckIpsRequest, - protos.google.monitoring.v3.IListUptimeCheckIpsResponse|null, + protos.google.monitoring.v3.IListUptimeCheckIpsResponse|null|undefined, protos.google.monitoring.v3.IUptimeCheckIp>, callback?: PaginationCallback< protos.google.monitoring.v3.IListUptimeCheckIpsRequest, - protos.google.monitoring.v3.IListUptimeCheckIpsResponse|null, + protos.google.monitoring.v3.IListUptimeCheckIpsResponse|null|undefined, protos.google.monitoring.v3.IUptimeCheckIp>): Promise<[ protos.google.monitoring.v3.IUptimeCheckIp[], @@ -922,6 +967,45 @@ export class UptimeCheckServiceClient { callSettings ); } + +/** + * Equivalent to {@link listUptimeCheckIps}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.pageSize + * The maximum number of results to return in a single response. The server + * may further constrain the maximum number of results returned in a single + * page. If the page_size is <=0, the server will decide the number of results + * to be returned. + * NOTE: this field is not yet implemented + * @param {string} request.pageToken + * If this field is not empty then it must contain the `nextPageToken` value + * returned by a previous call to this method. Using this field causes the + * method to return more results from the previous method call. + * NOTE: this field is not yet implemented + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listUptimeCheckIpsAsync( + request?: protos.google.monitoring.v3.IListUptimeCheckIpsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listUptimeCheckIps.asyncIterate( + this.innerApiCalls['listUptimeCheckIps'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/monitoring/test/gapic_alert_policy_service_v3.ts.baseline b/baselines/monitoring/test/gapic_alert_policy_service_v3.ts.baseline index 0770344bf..3efdf1820 100644 --- a/baselines/monitoring/test/gapic_alert_policy_service_v3.ts.baseline +++ b/baselines/monitoring/test/gapic_alert_policy_service_v3.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v3.AlertPolicyServiceClient', () => { it('has servicePath', () => { const servicePath = alertpolicyserviceModule.v3.AlertPolicyServiceClient.servicePath; @@ -607,7 +627,7 @@ describe('v3.AlertPolicyServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listAlertPolicies.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listAlertPolicies, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listAlertPolicies.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -641,12 +661,69 @@ describe('v3.AlertPolicyServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listAlertPolicies.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listAlertPolicies, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listAlertPolicies.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listAlertPolicies without error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListAlertPoliciesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + generateSampleMessage(new protos.google.monitoring.v3.AlertPolicy()), + ]; + client.descriptors.page.listAlertPolicies.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.monitoring.v3.IAlertPolicy[] = []; + const iterable = client.listAlertPoliciesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listAlertPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listAlertPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listAlertPolicies with error', async () => { + const client = new alertpolicyserviceModule.v3.AlertPolicyServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListAlertPoliciesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listAlertPolicies.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAlertPoliciesAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IAlertPolicy[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listAlertPolicies.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listAlertPolicies.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/monitoring/test/gapic_group_service_v3.ts.baseline b/baselines/monitoring/test/gapic_group_service_v3.ts.baseline index b01829f19..22622930c 100644 --- a/baselines/monitoring/test/gapic_group_service_v3.ts.baseline +++ b/baselines/monitoring/test/gapic_group_service_v3.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v3.GroupServiceClient', () => { it('has servicePath', () => { const servicePath = groupserviceModule.v3.GroupServiceClient.servicePath; @@ -607,7 +627,7 @@ describe('v3.GroupServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listGroups.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listGroups, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listGroups.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -641,12 +661,69 @@ describe('v3.GroupServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listGroups.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listGroups, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listGroups.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listGroups without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListGroupsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.Group()), + generateSampleMessage(new protos.google.monitoring.v3.Group()), + generateSampleMessage(new protos.google.monitoring.v3.Group()), + ]; + client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.monitoring.v3.IGroup[] = []; + const iterable = client.listGroupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listGroups with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListGroupsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listGroups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listGroupsAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IGroup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listGroups.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listGroupMembers', () => { @@ -772,7 +849,7 @@ describe('v3.GroupServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listGroupMembers.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listGroupMembers, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listGroupMembers.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -806,12 +883,69 @@ describe('v3.GroupServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listGroupMembers.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listGroupMembers, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listGroupMembers.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listGroupMembers without error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListGroupMembersRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedResponse = [ + generateSampleMessage(new protos.google.api.MonitoredResource()), + generateSampleMessage(new protos.google.api.MonitoredResource()), + generateSampleMessage(new protos.google.api.MonitoredResource()), + ]; + client.descriptors.page.listGroupMembers.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.api.IMonitoredResource[] = []; + const iterable = client.listGroupMembersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listGroupMembers.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listGroupMembers.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listGroupMembers with error', async () => { + const client = new groupserviceModule.v3.GroupServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListGroupMembersRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listGroupMembers.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listGroupMembersAsync(request); + assert.rejects(async () => { + const responses: protos.google.api.IMonitoredResource[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listGroupMembers.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listGroupMembers.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/monitoring/test/gapic_metric_service_v3.ts.baseline b/baselines/monitoring/test/gapic_metric_service_v3.ts.baseline index 3e3bf958e..bb7acc30e 100644 --- a/baselines/monitoring/test/gapic_metric_service_v3.ts.baseline +++ b/baselines/monitoring/test/gapic_metric_service_v3.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v3.MetricServiceClient', () => { it('has servicePath', () => { const servicePath = metricserviceModule.v3.MetricServiceClient.servicePath; @@ -688,7 +708,7 @@ describe('v3.MetricServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listMonitoredResourceDescriptors.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listMonitoredResourceDescriptors, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listMonitoredResourceDescriptors.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -722,12 +742,69 @@ describe('v3.MetricServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listMonitoredResourceDescriptors.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listMonitoredResourceDescriptors, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listMonitoredResourceDescriptors.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listMonitoredResourceDescriptors without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedResponse = [ + generateSampleMessage(new protos.google.api.MonitoredResourceDescriptor()), + generateSampleMessage(new protos.google.api.MonitoredResourceDescriptor()), + generateSampleMessage(new protos.google.api.MonitoredResourceDescriptor()), + ]; + client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.api.IMonitoredResourceDescriptor[] = []; + const iterable = client.listMonitoredResourceDescriptorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listMonitoredResourceDescriptors with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListMonitoredResourceDescriptorsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMonitoredResourceDescriptorsAsync(request); + assert.rejects(async () => { + const responses: protos.google.api.IMonitoredResourceDescriptor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listMonitoredResourceDescriptors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listMetricDescriptors', () => { @@ -853,7 +930,7 @@ describe('v3.MetricServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listMetricDescriptors.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listMetricDescriptors, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listMetricDescriptors.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -887,12 +964,69 @@ describe('v3.MetricServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listMetricDescriptors.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listMetricDescriptors, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listMetricDescriptors.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listMetricDescriptors without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListMetricDescriptorsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedResponse = [ + generateSampleMessage(new protos.google.api.MetricDescriptor()), + generateSampleMessage(new protos.google.api.MetricDescriptor()), + generateSampleMessage(new protos.google.api.MetricDescriptor()), + ]; + client.descriptors.page.listMetricDescriptors.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.api.IMetricDescriptor[] = []; + const iterable = client.listMetricDescriptorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listMetricDescriptors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listMetricDescriptors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listMetricDescriptors with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListMetricDescriptorsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listMetricDescriptors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listMetricDescriptorsAsync(request); + assert.rejects(async () => { + const responses: protos.google.api.IMetricDescriptor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listMetricDescriptors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listMetricDescriptors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listTimeSeries', () => { @@ -1018,7 +1152,7 @@ describe('v3.MetricServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listTimeSeries.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listTimeSeries, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listTimeSeries.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -1052,12 +1186,69 @@ describe('v3.MetricServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listTimeSeries.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listTimeSeries, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listTimeSeries.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listTimeSeries without error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListTimeSeriesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + generateSampleMessage(new protos.google.monitoring.v3.TimeSeries()), + ]; + client.descriptors.page.listTimeSeries.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.monitoring.v3.ITimeSeries[] = []; + const iterable = client.listTimeSeriesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTimeSeries.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listTimeSeries.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listTimeSeries with error', async () => { + const client = new metricserviceModule.v3.MetricServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListTimeSeriesRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listTimeSeries.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTimeSeriesAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.ITimeSeries[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTimeSeries.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listTimeSeries.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/monitoring/test/gapic_notification_channel_service_v3.ts.baseline b/baselines/monitoring/test/gapic_notification_channel_service_v3.ts.baseline index 0e6100009..1dd132fad 100644 --- a/baselines/monitoring/test/gapic_notification_channel_service_v3.ts.baseline +++ b/baselines/monitoring/test/gapic_notification_channel_service_v3.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v3.NotificationChannelServiceClient', () => { it('has servicePath', () => { const servicePath = notificationchannelserviceModule.v3.NotificationChannelServiceClient.servicePath; @@ -943,7 +963,7 @@ describe('v3.NotificationChannelServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listNotificationChannelDescriptors.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listNotificationChannelDescriptors, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listNotificationChannelDescriptors.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -977,12 +997,69 @@ describe('v3.NotificationChannelServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listNotificationChannelDescriptors.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listNotificationChannelDescriptors, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listNotificationChannelDescriptors.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listNotificationChannelDescriptors without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListNotificationChannelDescriptorsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.NotificationChannelDescriptor()), + generateSampleMessage(new protos.google.monitoring.v3.NotificationChannelDescriptor()), + generateSampleMessage(new protos.google.monitoring.v3.NotificationChannelDescriptor()), + ]; + client.descriptors.page.listNotificationChannelDescriptors.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.monitoring.v3.INotificationChannelDescriptor[] = []; + const iterable = client.listNotificationChannelDescriptorsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNotificationChannelDescriptors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNotificationChannelDescriptors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNotificationChannelDescriptors with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListNotificationChannelDescriptorsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listNotificationChannelDescriptors.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNotificationChannelDescriptorsAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.INotificationChannelDescriptor[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNotificationChannelDescriptors.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNotificationChannelDescriptors.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listNotificationChannels', () => { @@ -1108,7 +1185,7 @@ describe('v3.NotificationChannelServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listNotificationChannels.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listNotificationChannels, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listNotificationChannels.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -1142,12 +1219,69 @@ describe('v3.NotificationChannelServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listNotificationChannels.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listNotificationChannels, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listNotificationChannels.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listNotificationChannels without error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListNotificationChannelsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.NotificationChannel()), + generateSampleMessage(new protos.google.monitoring.v3.NotificationChannel()), + generateSampleMessage(new protos.google.monitoring.v3.NotificationChannel()), + ]; + client.descriptors.page.listNotificationChannels.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.monitoring.v3.INotificationChannel[] = []; + const iterable = client.listNotificationChannelsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listNotificationChannels.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNotificationChannels.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listNotificationChannels with error', async () => { + const client = new notificationchannelserviceModule.v3.NotificationChannelServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListNotificationChannelsRequest()); + request.name = ''; + const expectedHeaderRequestParams = "name=";const expectedError = new Error('expected'); + client.descriptors.page.listNotificationChannels.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listNotificationChannelsAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.INotificationChannel[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listNotificationChannels.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listNotificationChannels.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/monitoring/test/gapic_service_monitoring_service_v3.ts.baseline b/baselines/monitoring/test/gapic_service_monitoring_service_v3.ts.baseline index 3e99893d6..2a835162e 100644 --- a/baselines/monitoring/test/gapic_service_monitoring_service_v3.ts.baseline +++ b/baselines/monitoring/test/gapic_service_monitoring_service_v3.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v3.ServiceMonitoringServiceClient', () => { it('has servicePath', () => { const servicePath = servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient.servicePath; @@ -946,7 +966,7 @@ describe('v3.ServiceMonitoringServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listServices.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listServices.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -980,12 +1000,69 @@ describe('v3.ServiceMonitoringServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listServices.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listServices, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listServices.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listServices without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListServicesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.Service()), + generateSampleMessage(new protos.google.monitoring.v3.Service()), + generateSampleMessage(new protos.google.monitoring.v3.Service()), + ]; + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.monitoring.v3.IService[] = []; + const iterable = client.listServicesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServices with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListServicesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listServices.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServicesAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IService[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServices.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listServiceLevelObjectives', () => { @@ -1111,7 +1188,7 @@ describe('v3.ServiceMonitoringServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listServiceLevelObjectives.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listServiceLevelObjectives, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listServiceLevelObjectives.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -1145,12 +1222,69 @@ describe('v3.ServiceMonitoringServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listServiceLevelObjectives.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listServiceLevelObjectives, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listServiceLevelObjectives.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listServiceLevelObjectives without error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListServiceLevelObjectivesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.ServiceLevelObjective()), + generateSampleMessage(new protos.google.monitoring.v3.ServiceLevelObjective()), + generateSampleMessage(new protos.google.monitoring.v3.ServiceLevelObjective()), + ]; + client.descriptors.page.listServiceLevelObjectives.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.monitoring.v3.IServiceLevelObjective[] = []; + const iterable = client.listServiceLevelObjectivesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listServiceLevelObjectives.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServiceLevelObjectives.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listServiceLevelObjectives with error', async () => { + const client = new servicemonitoringserviceModule.v3.ServiceMonitoringServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListServiceLevelObjectivesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listServiceLevelObjectives.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listServiceLevelObjectivesAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IServiceLevelObjective[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listServiceLevelObjectives.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listServiceLevelObjectives.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/monitoring/test/gapic_uptime_check_service_v3.ts.baseline b/baselines/monitoring/test/gapic_uptime_check_service_v3.ts.baseline index 0eb9e63db..50c3648db 100644 --- a/baselines/monitoring/test/gapic_uptime_check_service_v3.ts.baseline +++ b/baselines/monitoring/test/gapic_uptime_check_service_v3.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v3.UptimeCheckServiceClient', () => { it('has servicePath', () => { const servicePath = uptimecheckserviceModule.v3.UptimeCheckServiceClient.servicePath; @@ -607,7 +627,7 @@ describe('v3.UptimeCheckServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listUptimeCheckConfigs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listUptimeCheckConfigs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listUptimeCheckConfigs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -641,12 +661,69 @@ describe('v3.UptimeCheckServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listUptimeCheckConfigs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listUptimeCheckConfigs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listUptimeCheckConfigs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listUptimeCheckConfigs without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListUptimeCheckConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckConfig()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckConfig()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckConfig()), + ]; + client.descriptors.page.listUptimeCheckConfigs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.monitoring.v3.IUptimeCheckConfig[] = []; + const iterable = client.listUptimeCheckConfigsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listUptimeCheckConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listUptimeCheckConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listUptimeCheckConfigs with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListUptimeCheckConfigsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listUptimeCheckConfigs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listUptimeCheckConfigsAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IUptimeCheckConfig[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listUptimeCheckConfigs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listUptimeCheckConfigs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('listUptimeCheckIps', () => { @@ -774,6 +851,49 @@ describe('v3.UptimeCheckServiceClient', () => { assert((client.descriptors.page.listUptimeCheckIps.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listUptimeCheckIps, request)); }); + + it('uses async iteration with listUptimeCheckIps without error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListUptimeCheckIpsRequest());const expectedResponse = [ + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + generateSampleMessage(new protos.google.monitoring.v3.UptimeCheckIp()), + ]; + client.descriptors.page.listUptimeCheckIps.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.monitoring.v3.IUptimeCheckIp[] = []; + const iterable = client.listUptimeCheckIpsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listUptimeCheckIps.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listUptimeCheckIps with error', async () => { + const client = new uptimecheckserviceModule.v3.UptimeCheckServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.monitoring.v3.ListUptimeCheckIpsRequest());const expectedError = new Error('expected'); + client.descriptors.page.listUptimeCheckIps.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listUptimeCheckIpsAsync(request); + assert.rejects(async () => { + const responses: protos.google.monitoring.v3.IUptimeCheckIp[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listUptimeCheckIps.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); }); describe('Path templates', () => { diff --git a/baselines/redis/package.json b/baselines/redis/package.json index 4255d193d..4c3f84994 100644 --- a/baselines/redis/package.json +++ b/baselines/redis/package.json @@ -24,7 +24,7 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^2.0.0" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline b/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline index 8c83cc6ea..48cfa0434 100644 --- a/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline +++ b/baselines/redis/src/v1beta1/cloud_redis_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './cloud_redis_client_config.json'; @@ -275,9 +276,8 @@ export class CloudRedisClient { // and create an API call method for each. const cloudRedisStubMethods = ['listInstances', 'getInstance', 'createInstance', 'updateInstance', 'importInstance', 'exportInstance', 'failoverInstance', 'deleteInstance']; - for (const methodName of cloudRedisStubMethods) { - const innerCallPromise = this.cloudRedisStub.then( + const callPromise = this.cloudRedisStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -290,20 +290,14 @@ export class CloudRedisClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.cloudRedisStub; @@ -372,14 +366,14 @@ export class CloudRedisClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.redis.v1beta1.IInstance, - protos.google.cloud.redis.v1beta1.IGetInstanceRequest|undefined, - {}|undefined>): void; + protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; getInstance( request: protos.google.cloud.redis.v1beta1.IGetInstanceRequest, callback: Callback< protos.google.cloud.redis.v1beta1.IInstance, - protos.google.cloud.redis.v1beta1.IGetInstanceRequest|undefined, - {}|undefined>): void; + protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): void; /** * Gets the details of a specific Redis instance. * @@ -399,11 +393,12 @@ export class CloudRedisClient { request: protos.google.cloud.redis.v1beta1.IGetInstanceRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.redis.v1beta1.IInstance, - protos.google.cloud.redis.v1beta1.IGetInstanceRequest|undefined, {}|undefined>, + protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.redis.v1beta1.IInstance, - protos.google.cloud.redis.v1beta1.IGetInstanceRequest|undefined, - {}|undefined>): + protos.google.cloud.redis.v1beta1.IGetInstanceRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.redis.v1beta1.IInstance, protos.google.cloud.redis.v1beta1.IGetInstanceRequest|undefined, {}|undefined @@ -441,14 +436,14 @@ export class CloudRedisClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; createInstance( request: protos.google.cloud.redis.v1beta1.ICreateInstanceRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * Creates a Redis instance based on the specified tier and memory size. * @@ -490,11 +485,12 @@ export class CloudRedisClient { request: protos.google.cloud.redis.v1beta1.ICreateInstanceRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -531,14 +527,14 @@ export class CloudRedisClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; updateInstance( request: protos.google.cloud.redis.v1beta1.IUpdateInstanceRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * Updates the metadata and configuration of a specific Redis instance. * @@ -570,11 +566,12 @@ export class CloudRedisClient { request: protos.google.cloud.redis.v1beta1.IUpdateInstanceRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -611,14 +608,14 @@ export class CloudRedisClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; importInstance( request: protos.google.cloud.redis.v1beta1.IImportInstanceRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * Import a Redis RDB snapshot file from Cloud Storage into a Redis instance. * @@ -647,11 +644,12 @@ export class CloudRedisClient { request: protos.google.cloud.redis.v1beta1.IImportInstanceRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -688,14 +686,14 @@ export class CloudRedisClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; exportInstance( request: protos.google.cloud.redis.v1beta1.IExportInstanceRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * Export Redis instance data into a Redis RDB format file in Cloud Storage. * @@ -722,11 +720,12 @@ export class CloudRedisClient { request: protos.google.cloud.redis.v1beta1.IExportInstanceRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -763,14 +762,14 @@ export class CloudRedisClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; failoverInstance( request: protos.google.cloud.redis.v1beta1.IFailoverInstanceRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * Initiates a failover of the master node to current replica node for a * specific STANDARD tier Cloud Memorystore for Redis instance. @@ -794,11 +793,12 @@ export class CloudRedisClient { request: protos.google.cloud.redis.v1beta1.IFailoverInstanceRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -835,14 +835,14 @@ export class CloudRedisClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; deleteInstance( request: protos.google.cloud.redis.v1beta1.IDeleteInstanceRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * Deletes a specific Redis instance. Instance stops serving and data is * deleted. @@ -863,11 +863,12 @@ export class CloudRedisClient { request: protos.google.cloud.redis.v1beta1.IDeleteInstanceRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -905,13 +906,13 @@ export class CloudRedisClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.cloud.redis.v1beta1.IListInstancesRequest, - protos.google.cloud.redis.v1beta1.IListInstancesResponse|null, + protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, protos.google.cloud.redis.v1beta1.IInstance>): void; listInstances( request: protos.google.cloud.redis.v1beta1.IListInstancesRequest, callback: PaginationCallback< protos.google.cloud.redis.v1beta1.IListInstancesRequest, - protos.google.cloud.redis.v1beta1.IListInstancesResponse|null, + protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, protos.google.cloud.redis.v1beta1.IInstance>): void; /** * Lists all Redis instances owned by a project in either the specified @@ -962,11 +963,11 @@ export class CloudRedisClient { request: protos.google.cloud.redis.v1beta1.IListInstancesRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.cloud.redis.v1beta1.IListInstancesRequest, - protos.google.cloud.redis.v1beta1.IListInstancesResponse|null, + protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, protos.google.cloud.redis.v1beta1.IInstance>, callback?: PaginationCallback< protos.google.cloud.redis.v1beta1.IListInstancesRequest, - protos.google.cloud.redis.v1beta1.IListInstancesResponse|null, + protos.google.cloud.redis.v1beta1.IListInstancesResponse|null|undefined, protos.google.cloud.redis.v1beta1.IInstance>): Promise<[ protos.google.cloud.redis.v1beta1.IInstance[], @@ -1050,6 +1051,56 @@ export class CloudRedisClient { callSettings ); } + +/** + * Equivalent to {@link listInstances}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The resource name of the instance location using the form: + * `projects/{project_id}/locations/{location_id}` + * where `location_id` refers to a GCP region. + * @param {number} request.pageSize + * The maximum number of items to return. + * + * If not specified, a default value of 1000 will be used by the service. + * Regardless of the page_size value, the response may include a partial list + * and a caller should only rely on response's + * {@link CloudRedis.ListInstancesResponse.next_page_token|next_page_token} + * to determine if there are more instances left to be queried. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, + * if any. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listInstancesAsync( + request?: protos.google.cloud.redis.v1beta1.IListInstancesRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listInstances.asyncIterate( + this.innerApiCalls['listInstances'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/redis/test/gapic_cloud_redis_v1beta1.ts.baseline b/baselines/redis/test/gapic_cloud_redis_v1beta1.ts.baseline index 06d4c26dd..5cabdc6aa 100644 --- a/baselines/redis/test/gapic_cloud_redis_v1beta1.ts.baseline +++ b/baselines/redis/test/gapic_cloud_redis_v1beta1.ts.baseline @@ -82,6 +82,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v1beta1.CloudRedisClient', () => { it('has servicePath', () => { const servicePath = cloudredisModule.v1beta1.CloudRedisClient.servicePath; @@ -1044,7 +1064,7 @@ describe('v1beta1.CloudRedisClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listInstances.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listInstances.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -1078,12 +1098,69 @@ describe('v1beta1.CloudRedisClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listInstances.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listInstances, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listInstances.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listInstances without error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.redis.v1beta1.ListInstancesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + generateSampleMessage(new protos.google.cloud.redis.v1beta1.Instance()), + ]; + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.redis.v1beta1.IInstance[] = []; + const iterable = client.listInstancesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listInstances with error', async () => { + const client = new cloudredisModule.v1beta1.CloudRedisClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.redis.v1beta1.ListInstancesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listInstances.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listInstancesAsync(request); + assert.rejects(async () => { + const responses: protos.google.cloud.redis.v1beta1.IInstance[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listInstances.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/showcase/package.json b/baselines/showcase/package.json index eb9adc8a8..77baff6da 100644 --- a/baselines/showcase/package.json +++ b/baselines/showcase/package.json @@ -24,7 +24,7 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^2.0.0" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/baselines/showcase/src/v1beta1/echo_client.ts.baseline b/baselines/showcase/src/v1beta1/echo_client.ts.baseline index a950db818..e04650406 100644 --- a/baselines/showcase/src/v1beta1/echo_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/echo_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './echo_client_config.json'; @@ -248,9 +249,8 @@ export class EchoClient { // and create an API call method for each. const echoStubMethods = ['echo', 'expand', 'collect', 'chat', 'pagedExpand', 'wait', 'block']; - for (const methodName of echoStubMethods) { - const innerCallPromise = this.echoStub.then( + const callPromise = this.echoStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -263,20 +263,14 @@ export class EchoClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.echoStub; @@ -343,14 +337,14 @@ export class EchoClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): void; echo( request: protos.google.showcase.v1beta1.IEchoRequest, callback: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): void; /** * @param {Object} request * The request object that will be sent. @@ -368,11 +362,12 @@ export class EchoClient { request: protos.google.showcase.v1beta1.IEchoRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IEchoResponse, protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined @@ -402,14 +397,14 @@ export class EchoClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IBlockResponse, - protos.google.showcase.v1beta1.IBlockRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IBlockRequest|null|undefined, + {}|null|undefined>): void; block( request: protos.google.showcase.v1beta1.IBlockRequest, callback: Callback< protos.google.showcase.v1beta1.IBlockResponse, - protos.google.showcase.v1beta1.IBlockRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IBlockRequest|null|undefined, + {}|null|undefined>): void; /** * This method will block (wait) for the requested amount of time * and then return the response or error. @@ -434,11 +429,12 @@ export class EchoClient { request: protos.google.showcase.v1beta1.IBlockRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IBlockResponse, - protos.google.showcase.v1beta1.IBlockRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IBlockRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IBlockResponse, - protos.google.showcase.v1beta1.IBlockRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IBlockRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IBlockResponse, protos.google.showcase.v1beta1.IBlockRequest|undefined, {}|undefined @@ -486,12 +482,14 @@ export class EchoClient { options?: gax.CallOptions, callback?: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream; collect( callback?: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream; /** * This method will collect the words given to it. When the stream is closed @@ -506,10 +504,12 @@ export class EchoClient { collect( optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IEchoResponse, - protos.google.showcase.v1beta1.IEchoRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.IEchoRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream { if (optionsOrCallback instanceof Function && callback === undefined) { callback = optionsOrCallback; @@ -551,14 +551,14 @@ export class EchoClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; wait( request: protos.google.showcase.v1beta1.IWaitRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * This method will wait the requested amount of and then return. * This method showcases how a client handles a request timing out. @@ -584,11 +584,12 @@ export class EchoClient { request: protos.google.showcase.v1beta1.IWaitRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -619,13 +620,13 @@ export class EchoClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IPagedExpandRequest, - protos.google.showcase.v1beta1.IPagedExpandResponse|null, + protos.google.showcase.v1beta1.IPagedExpandResponse|null|undefined, protos.google.showcase.v1beta1.IEchoResponse>): void; pagedExpand( request: protos.google.showcase.v1beta1.IPagedExpandRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IPagedExpandRequest, - protos.google.showcase.v1beta1.IPagedExpandResponse|null, + protos.google.showcase.v1beta1.IPagedExpandResponse|null|undefined, protos.google.showcase.v1beta1.IEchoResponse>): void; /** * This is similar to the Expand method but instead of returning a stream of @@ -661,11 +662,11 @@ export class EchoClient { request: protos.google.showcase.v1beta1.IPagedExpandRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IPagedExpandRequest, - protos.google.showcase.v1beta1.IPagedExpandResponse|null, + protos.google.showcase.v1beta1.IPagedExpandResponse|null|undefined, protos.google.showcase.v1beta1.IEchoResponse>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IPagedExpandRequest, - protos.google.showcase.v1beta1.IPagedExpandResponse|null, + protos.google.showcase.v1beta1.IPagedExpandResponse|null|undefined, protos.google.showcase.v1beta1.IEchoResponse>): Promise<[ protos.google.showcase.v1beta1.IEchoResponse[], @@ -726,6 +727,40 @@ export class EchoClient { callSettings ); } + +/** + * Equivalent to {@link pagedExpand}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.content + * The string to expand. + * @param {number} request.pageSize + * The amount of words to returned in each page. + * @param {string} request.pageToken + * The position of the page to be returned. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + pagedExpandAsync( + request?: protos.google.showcase.v1beta1.IPagedExpandRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.pagedExpand.asyncIterate( + this.innerApiCalls['pagedExpand'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/showcase/src/v1beta1/identity_client.ts.baseline b/baselines/showcase/src/v1beta1/identity_client.ts.baseline index 74a2e42dd..d248053df 100644 --- a/baselines/showcase/src/v1beta1/identity_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/identity_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './identity_client_config.json'; @@ -210,9 +211,8 @@ export class IdentityClient { // and create an API call method for each. const identityStubMethods = ['createUser', 'getUser', 'updateUser', 'deleteUser', 'listUsers']; - for (const methodName of identityStubMethods) { - const innerCallPromise = this.identityStub.then( + const callPromise = this.identityStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -225,20 +225,14 @@ export class IdentityClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.identityStub; @@ -305,14 +299,14 @@ export class IdentityClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.ICreateUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateUserRequest|null|undefined, + {}|null|undefined>): void; createUser( request: protos.google.showcase.v1beta1.ICreateUserRequest, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.ICreateUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateUserRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a user. * @@ -330,11 +324,12 @@ export class IdentityClient { request: protos.google.showcase.v1beta1.ICreateUserRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.ICreateUserRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.ICreateUserRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.ICreateUserRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.ICreateUserRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IUser, protos.google.showcase.v1beta1.ICreateUserRequest|undefined, {}|undefined @@ -364,14 +359,14 @@ export class IdentityClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IGetUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetUserRequest|null|undefined, + {}|null|undefined>): void; getUser( request: protos.google.showcase.v1beta1.IGetUserRequest, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IGetUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetUserRequest|null|undefined, + {}|null|undefined>): void; /** * Retrieves the User with the given uri. * @@ -389,11 +384,12 @@ export class IdentityClient { request: protos.google.showcase.v1beta1.IGetUserRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IGetUserRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IGetUserRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IGetUserRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IGetUserRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IUser, protos.google.showcase.v1beta1.IGetUserRequest|undefined, {}|undefined @@ -430,14 +426,14 @@ export class IdentityClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IUpdateUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateUserRequest|null|undefined, + {}|null|undefined>): void; updateUser( request: protos.google.showcase.v1beta1.IUpdateUserRequest, callback: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IUpdateUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateUserRequest|null|undefined, + {}|null|undefined>): void; /** * Updates a user. * @@ -458,11 +454,12 @@ export class IdentityClient { request: protos.google.showcase.v1beta1.IUpdateUserRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IUpdateUserRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IUpdateUserRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IUser, - protos.google.showcase.v1beta1.IUpdateUserRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IUpdateUserRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IUser, protos.google.showcase.v1beta1.IUpdateUserRequest|undefined, {}|undefined @@ -499,14 +496,14 @@ export class IdentityClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteUserRequest|null|undefined, + {}|null|undefined>): void; deleteUser( request: protos.google.showcase.v1beta1.IDeleteUserRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteUserRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteUserRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a user, their profile, and all of their authored messages. * @@ -524,11 +521,12 @@ export class IdentityClient { request: protos.google.showcase.v1beta1.IDeleteUserRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteUserRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IDeleteUserRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteUserRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IDeleteUserRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.showcase.v1beta1.IDeleteUserRequest|undefined, {}|undefined @@ -567,13 +565,13 @@ export class IdentityClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IListUsersRequest, - protos.google.showcase.v1beta1.IListUsersResponse|null, + protos.google.showcase.v1beta1.IListUsersResponse|null|undefined, protos.google.showcase.v1beta1.IUser>): void; listUsers( request: protos.google.showcase.v1beta1.IListUsersRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IListUsersRequest, - protos.google.showcase.v1beta1.IListUsersResponse|null, + protos.google.showcase.v1beta1.IListUsersResponse|null|undefined, protos.google.showcase.v1beta1.IUser>): void; /** * Lists all users. @@ -609,11 +607,11 @@ export class IdentityClient { request: protos.google.showcase.v1beta1.IListUsersRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IListUsersRequest, - protos.google.showcase.v1beta1.IListUsersResponse|null, + protos.google.showcase.v1beta1.IListUsersResponse|null|undefined, protos.google.showcase.v1beta1.IUser>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IListUsersRequest, - protos.google.showcase.v1beta1.IListUsersResponse|null, + protos.google.showcase.v1beta1.IListUsersResponse|null|undefined, protos.google.showcase.v1beta1.IUser>): Promise<[ protos.google.showcase.v1beta1.IUser[], @@ -675,6 +673,41 @@ export class IdentityClient { callSettings ); } + +/** + * Equivalent to {@link listUsers}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.pageSize + * The maximum number of users to return. Server may return fewer users + * than requested. If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * The value of google.showcase.v1beta1.ListUsersResponse.next_page_token + * returned from the previous call to + * `google.showcase.v1beta1.Identity\ListUsers` method. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listUsersAsync( + request?: protos.google.showcase.v1beta1.IListUsersRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listUsers.asyncIterate( + this.innerApiCalls['listUsers'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/showcase/src/v1beta1/messaging_client.ts.baseline b/baselines/showcase/src/v1beta1/messaging_client.ts.baseline index 836c26d23..da65fd669 100644 --- a/baselines/showcase/src/v1beta1/messaging_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/messaging_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './messaging_client_config.json'; @@ -249,9 +250,8 @@ export class MessagingClient { // and create an API call method for each. const messagingStubMethods = ['createRoom', 'getRoom', 'updateRoom', 'deleteRoom', 'listRooms', 'createBlurb', 'getBlurb', 'updateBlurb', 'deleteBlurb', 'listBlurbs', 'searchBlurbs', 'streamBlurbs', 'sendBlurbs', 'connect']; - for (const methodName of messagingStubMethods) { - const innerCallPromise = this.messagingStub.then( + const callPromise = this.messagingStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -264,20 +264,14 @@ export class MessagingClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.messagingStub; @@ -344,14 +338,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.ICreateRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateRoomRequest|null|undefined, + {}|null|undefined>): void; createRoom( request: protos.google.showcase.v1beta1.ICreateRoomRequest, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.ICreateRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateRoomRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a room. * @@ -369,11 +363,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.ICreateRoomRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.ICreateRoomRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.ICreateRoomRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.ICreateRoomRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.ICreateRoomRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IRoom, protos.google.showcase.v1beta1.ICreateRoomRequest|undefined, {}|undefined @@ -403,14 +398,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IGetRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetRoomRequest|null|undefined, + {}|null|undefined>): void; getRoom( request: protos.google.showcase.v1beta1.IGetRoomRequest, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IGetRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetRoomRequest|null|undefined, + {}|null|undefined>): void; /** * Retrieves the Room with the given resource name. * @@ -428,11 +423,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IGetRoomRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IGetRoomRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IGetRoomRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IGetRoomRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IGetRoomRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IRoom, protos.google.showcase.v1beta1.IGetRoomRequest|undefined, {}|undefined @@ -469,14 +465,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IUpdateRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateRoomRequest|null|undefined, + {}|null|undefined>): void; updateRoom( request: protos.google.showcase.v1beta1.IUpdateRoomRequest, callback: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IUpdateRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateRoomRequest|null|undefined, + {}|null|undefined>): void; /** * Updates a room. * @@ -497,11 +493,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IUpdateRoomRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IUpdateRoomRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IUpdateRoomRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IRoom, - protos.google.showcase.v1beta1.IUpdateRoomRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IUpdateRoomRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IRoom, protos.google.showcase.v1beta1.IUpdateRoomRequest|undefined, {}|undefined @@ -538,14 +535,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteRoomRequest|null|undefined, + {}|null|undefined>): void; deleteRoom( request: protos.google.showcase.v1beta1.IDeleteRoomRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteRoomRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteRoomRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a room and all of its blurbs. * @@ -563,11 +560,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IDeleteRoomRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteRoomRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IDeleteRoomRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteRoomRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IDeleteRoomRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.showcase.v1beta1.IDeleteRoomRequest|undefined, {}|undefined @@ -604,14 +602,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): void; createBlurb( request: protos.google.showcase.v1beta1.ICreateBlurbRequest, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a blurb. If the parent is a room, the blurb is understood to be a * message in that room. If the parent is a profile, the blurb is understood @@ -634,11 +632,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.ICreateBlurbRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IBlurb, protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined @@ -675,14 +674,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IGetBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetBlurbRequest|null|undefined, + {}|null|undefined>): void; getBlurb( request: protos.google.showcase.v1beta1.IGetBlurbRequest, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IGetBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetBlurbRequest|null|undefined, + {}|null|undefined>): void; /** * Retrieves the Blurb with the given resource name. * @@ -700,11 +699,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IGetBlurbRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IGetBlurbRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IGetBlurbRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IGetBlurbRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IGetBlurbRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IBlurb, protos.google.showcase.v1beta1.IGetBlurbRequest|undefined, {}|undefined @@ -741,14 +741,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IUpdateBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateBlurbRequest|null|undefined, + {}|null|undefined>): void; updateBlurb( request: protos.google.showcase.v1beta1.IUpdateBlurbRequest, callback: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IUpdateBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IUpdateBlurbRequest|null|undefined, + {}|null|undefined>): void; /** * Updates a blurb. * @@ -769,11 +769,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IUpdateBlurbRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IUpdateBlurbRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IUpdateBlurbRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IBlurb, - protos.google.showcase.v1beta1.IUpdateBlurbRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IUpdateBlurbRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IBlurb, protos.google.showcase.v1beta1.IUpdateBlurbRequest|undefined, {}|undefined @@ -810,14 +811,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteBlurbRequest|null|undefined, + {}|null|undefined>): void; deleteBlurb( request: protos.google.showcase.v1beta1.IDeleteBlurbRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteBlurbRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteBlurbRequest|null|undefined, + {}|null|undefined>): void; /** * Deletes a blurb. * @@ -835,11 +836,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IDeleteBlurbRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteBlurbRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IDeleteBlurbRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteBlurbRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IDeleteBlurbRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.showcase.v1beta1.IDeleteBlurbRequest|undefined, {}|undefined @@ -901,12 +903,14 @@ export class MessagingClient { options?: gax.CallOptions, callback?: Callback< protos.google.showcase.v1beta1.ISendBlurbsResponse, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream; sendBlurbs( callback?: Callback< protos.google.showcase.v1beta1.ISendBlurbsResponse, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream; /** * This is a stream to create multiple blurbs. If an invalid blurb is @@ -920,10 +924,12 @@ export class MessagingClient { sendBlurbs( optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.ISendBlurbsResponse, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.ISendBlurbsResponse, - protos.google.showcase.v1beta1.ICreateBlurbRequest|undefined, {}|undefined>): + protos.google.showcase.v1beta1.ICreateBlurbRequest|null|undefined, + {}|null|undefined>): gax.CancellableStream { if (optionsOrCallback instanceof Function && callback === undefined) { callback = optionsOrCallback; @@ -966,14 +972,14 @@ export class MessagingClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; searchBlurbs( request: protos.google.showcase.v1beta1.ISearchBlurbsRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * This method searches through all blurbs across all rooms and profiles * for blurbs containing to words found in the query. Only posts that @@ -1006,11 +1012,12 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.ISearchBlurbsRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -1048,13 +1055,13 @@ export class MessagingClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IListRoomsRequest, - protos.google.showcase.v1beta1.IListRoomsResponse|null, + protos.google.showcase.v1beta1.IListRoomsResponse|null|undefined, protos.google.showcase.v1beta1.IRoom>): void; listRooms( request: protos.google.showcase.v1beta1.IListRoomsRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IListRoomsRequest, - protos.google.showcase.v1beta1.IListRoomsResponse|null, + protos.google.showcase.v1beta1.IListRoomsResponse|null|undefined, protos.google.showcase.v1beta1.IRoom>): void; /** * Lists all chat rooms. @@ -1090,11 +1097,11 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IListRoomsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IListRoomsRequest, - protos.google.showcase.v1beta1.IListRoomsResponse|null, + protos.google.showcase.v1beta1.IListRoomsResponse|null|undefined, protos.google.showcase.v1beta1.IRoom>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IListRoomsRequest, - protos.google.showcase.v1beta1.IListRoomsResponse|null, + protos.google.showcase.v1beta1.IListRoomsResponse|null|undefined, protos.google.showcase.v1beta1.IRoom>): Promise<[ protos.google.showcase.v1beta1.IRoom[], @@ -1156,6 +1163,41 @@ export class MessagingClient { callSettings ); } + +/** + * Equivalent to {@link listRooms}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.pageSize + * The maximum number of rooms return. Server may return fewer rooms + * than requested. If unspecified, server will pick an appropriate default. + * @param {string} request.pageToken + * The value of google.showcase.v1beta1.ListRoomsResponse.next_page_token + * returned from the previous call to + * `google.showcase.v1beta1.Messaging\ListRooms` method. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listRoomsAsync( + request?: protos.google.showcase.v1beta1.IListRoomsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listRooms.asyncIterate( + this.innerApiCalls['listRooms'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listBlurbs( request: protos.google.showcase.v1beta1.IListBlurbsRequest, options?: gax.CallOptions): @@ -1169,13 +1211,13 @@ export class MessagingClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IListBlurbsRequest, - protos.google.showcase.v1beta1.IListBlurbsResponse|null, + protos.google.showcase.v1beta1.IListBlurbsResponse|null|undefined, protos.google.showcase.v1beta1.IBlurb>): void; listBlurbs( request: protos.google.showcase.v1beta1.IListBlurbsRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IListBlurbsRequest, - protos.google.showcase.v1beta1.IListBlurbsResponse|null, + protos.google.showcase.v1beta1.IListBlurbsResponse|null|undefined, protos.google.showcase.v1beta1.IBlurb>): void; /** * Lists blurbs for a specific chat room or user profile depending on the @@ -1215,11 +1257,11 @@ export class MessagingClient { request: protos.google.showcase.v1beta1.IListBlurbsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IListBlurbsRequest, - protos.google.showcase.v1beta1.IListBlurbsResponse|null, + protos.google.showcase.v1beta1.IListBlurbsResponse|null|undefined, protos.google.showcase.v1beta1.IBlurb>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IListBlurbsRequest, - protos.google.showcase.v1beta1.IListBlurbsResponse|null, + protos.google.showcase.v1beta1.IListBlurbsResponse|null|undefined, protos.google.showcase.v1beta1.IBlurb>): Promise<[ protos.google.showcase.v1beta1.IBlurb[], @@ -1298,6 +1340,51 @@ export class MessagingClient { callSettings ); } + +/** + * Equivalent to {@link listBlurbs}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The resource name of the requested room or profile whos blurbs to list. + * @param {number} request.pageSize + * The maximum number of blurbs to return. Server may return fewer + * blurbs than requested. If unspecified, server will pick an appropriate + * default. + * @param {string} request.pageToken + * The value of google.showcase.v1beta1.ListBlurbsResponse.next_page_token + * returned from the previous call to + * `google.showcase.v1beta1.Messaging\ListBlurbs` method. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listBlurbsAsync( + request?: protos.google.showcase.v1beta1.IListBlurbsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listBlurbs.asyncIterate( + this.innerApiCalls['listBlurbs'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/showcase/src/v1beta1/testing_client.ts.baseline b/baselines/showcase/src/v1beta1/testing_client.ts.baseline index 140bdb537..892df6b4f 100644 --- a/baselines/showcase/src/v1beta1/testing_client.ts.baseline +++ b/baselines/showcase/src/v1beta1/testing_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './testing_client_config.json'; @@ -213,9 +214,8 @@ export class TestingClient { // and create an API call method for each. const testingStubMethods = ['createSession', 'getSession', 'listSessions', 'deleteSession', 'reportSession', 'listTests', 'deleteTest', 'verifyTest']; - for (const methodName of testingStubMethods) { - const innerCallPromise = this.testingStub.then( + const callPromise = this.testingStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -228,20 +228,14 @@ export class TestingClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.testingStub; @@ -308,14 +302,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.ICreateSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateSessionRequest|null|undefined, + {}|null|undefined>): void; createSession( request: protos.google.showcase.v1beta1.ICreateSessionRequest, callback: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.ICreateSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.ICreateSessionRequest|null|undefined, + {}|null|undefined>): void; /** * Creates a new testing session. * @@ -335,11 +329,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.ICreateSessionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.ICreateSessionRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.ICreateSessionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.ICreateSessionRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.ICreateSessionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.ISession, protos.google.showcase.v1beta1.ICreateSessionRequest|undefined, {}|undefined @@ -369,14 +364,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.IGetSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetSessionRequest|null|undefined, + {}|null|undefined>): void; getSession( request: protos.google.showcase.v1beta1.IGetSessionRequest, callback: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.IGetSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IGetSessionRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a testing session. * @@ -394,11 +389,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IGetSessionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.IGetSessionRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IGetSessionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.ISession, - protos.google.showcase.v1beta1.IGetSessionRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IGetSessionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.ISession, protos.google.showcase.v1beta1.IGetSessionRequest|undefined, {}|undefined @@ -435,14 +431,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>): void; deleteSession( request: protos.google.showcase.v1beta1.IDeleteSessionRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>): void; /** * Delete a test session. * @@ -460,11 +456,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IDeleteSessionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteSessionRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteSessionRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IDeleteSessionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.showcase.v1beta1.IDeleteSessionRequest|undefined, {}|undefined @@ -501,14 +498,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IReportSessionResponse, - protos.google.showcase.v1beta1.IReportSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IReportSessionRequest|null|undefined, + {}|null|undefined>): void; reportSession( request: protos.google.showcase.v1beta1.IReportSessionRequest, callback: Callback< protos.google.showcase.v1beta1.IReportSessionResponse, - protos.google.showcase.v1beta1.IReportSessionRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IReportSessionRequest|null|undefined, + {}|null|undefined>): void; /** * Report on the status of a session. * This generates a report detailing which tests have been completed, @@ -528,11 +525,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IReportSessionRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IReportSessionResponse, - protos.google.showcase.v1beta1.IReportSessionRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IReportSessionRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IReportSessionResponse, - protos.google.showcase.v1beta1.IReportSessionRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IReportSessionRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IReportSessionResponse, protos.google.showcase.v1beta1.IReportSessionRequest|undefined, {}|undefined @@ -569,14 +567,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteTestRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteTestRequest|null|undefined, + {}|null|undefined>): void; deleteTest( request: protos.google.showcase.v1beta1.IDeleteTestRequest, callback: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteTestRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IDeleteTestRequest|null|undefined, + {}|null|undefined>): void; /** * Explicitly decline to implement a test. * @@ -599,11 +597,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IDeleteTestRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteTestRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IDeleteTestRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.protobuf.IEmpty, - protos.google.showcase.v1beta1.IDeleteTestRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IDeleteTestRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.protobuf.IEmpty, protos.google.showcase.v1beta1.IDeleteTestRequest|undefined, {}|undefined @@ -640,14 +639,14 @@ export class TestingClient { options: gax.CallOptions, callback: Callback< protos.google.showcase.v1beta1.IVerifyTestResponse, - protos.google.showcase.v1beta1.IVerifyTestRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IVerifyTestRequest|null|undefined, + {}|null|undefined>): void; verifyTest( request: protos.google.showcase.v1beta1.IVerifyTestRequest, callback: Callback< protos.google.showcase.v1beta1.IVerifyTestResponse, - protos.google.showcase.v1beta1.IVerifyTestRequest|undefined, - {}|undefined>): void; + protos.google.showcase.v1beta1.IVerifyTestRequest|null|undefined, + {}|null|undefined>): void; /** * Register a response to a test. * @@ -672,11 +671,12 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IVerifyTestRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.showcase.v1beta1.IVerifyTestResponse, - protos.google.showcase.v1beta1.IVerifyTestRequest|undefined, {}|undefined>, + protos.google.showcase.v1beta1.IVerifyTestRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.showcase.v1beta1.IVerifyTestResponse, - protos.google.showcase.v1beta1.IVerifyTestRequest|undefined, - {}|undefined>): + protos.google.showcase.v1beta1.IVerifyTestRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.showcase.v1beta1.IVerifyTestResponse, protos.google.showcase.v1beta1.IVerifyTestRequest|undefined, {}|undefined @@ -715,13 +715,13 @@ export class TestingClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IListSessionsRequest, - protos.google.showcase.v1beta1.IListSessionsResponse|null, + protos.google.showcase.v1beta1.IListSessionsResponse|null|undefined, protos.google.showcase.v1beta1.ISession>): void; listSessions( request: protos.google.showcase.v1beta1.IListSessionsRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IListSessionsRequest, - protos.google.showcase.v1beta1.IListSessionsResponse|null, + protos.google.showcase.v1beta1.IListSessionsResponse|null|undefined, protos.google.showcase.v1beta1.ISession>): void; /** * Lists the current test sessions. @@ -754,11 +754,11 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IListSessionsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IListSessionsRequest, - protos.google.showcase.v1beta1.IListSessionsResponse|null, + protos.google.showcase.v1beta1.IListSessionsResponse|null|undefined, protos.google.showcase.v1beta1.ISession>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IListSessionsRequest, - protos.google.showcase.v1beta1.IListSessionsResponse|null, + protos.google.showcase.v1beta1.IListSessionsResponse|null|undefined, protos.google.showcase.v1beta1.ISession>): Promise<[ protos.google.showcase.v1beta1.ISession[], @@ -817,6 +817,38 @@ export class TestingClient { callSettings ); } + +/** + * Equivalent to {@link listSessions}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {number} request.pageSize + * The maximum number of sessions to return per page. + * @param {string} request.pageToken + * The page token, for retrieving subsequent pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listSessionsAsync( + request?: protos.google.showcase.v1beta1.IListSessionsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listSessions.asyncIterate( + this.innerApiCalls['listSessions'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } listTests( request: protos.google.showcase.v1beta1.IListTestsRequest, options?: gax.CallOptions): @@ -830,13 +862,13 @@ export class TestingClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.showcase.v1beta1.IListTestsRequest, - protos.google.showcase.v1beta1.IListTestsResponse|null, + protos.google.showcase.v1beta1.IListTestsResponse|null|undefined, protos.google.showcase.v1beta1.ITest>): void; listTests( request: protos.google.showcase.v1beta1.IListTestsRequest, callback: PaginationCallback< protos.google.showcase.v1beta1.IListTestsRequest, - protos.google.showcase.v1beta1.IListTestsResponse|null, + protos.google.showcase.v1beta1.IListTestsResponse|null|undefined, protos.google.showcase.v1beta1.ITest>): void; /** * List the tests of a sessesion. @@ -871,11 +903,11 @@ export class TestingClient { request: protos.google.showcase.v1beta1.IListTestsRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.showcase.v1beta1.IListTestsRequest, - protos.google.showcase.v1beta1.IListTestsResponse|null, + protos.google.showcase.v1beta1.IListTestsResponse|null|undefined, protos.google.showcase.v1beta1.ITest>, callback?: PaginationCallback< protos.google.showcase.v1beta1.IListTestsRequest, - protos.google.showcase.v1beta1.IListTestsResponse|null, + protos.google.showcase.v1beta1.IListTestsResponse|null|undefined, protos.google.showcase.v1beta1.ITest>): Promise<[ protos.google.showcase.v1beta1.ITest[], @@ -950,6 +982,47 @@ export class TestingClient { callSettings ); } + +/** + * Equivalent to {@link listTests}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * The session. + * @param {number} request.pageSize + * The maximum number of tests to return per page. + * @param {string} request.pageToken + * The page token, for retrieving subsequent pages. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listTestsAsync( + request?: protos.google.showcase.v1beta1.IListTestsRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listTests.asyncIterate( + this.innerApiCalls['listTests'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/showcase/test/gapic_echo_v1beta1.ts.baseline b/baselines/showcase/test/gapic_echo_v1beta1.ts.baseline index cf686819a..cff616f0c 100644 --- a/baselines/showcase/test/gapic_echo_v1beta1.ts.baseline +++ b/baselines/showcase/test/gapic_echo_v1beta1.ts.baseline @@ -115,6 +115,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v1beta1.EchoClient', () => { it('has servicePath', () => { const servicePath = echoModule.v1beta1.EchoClient.servicePath; @@ -684,6 +704,49 @@ describe('v1beta1.EchoClient', () => { assert((client.descriptors.page.pagedExpand.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.pagedExpand, request)); }); + + it('uses async iteration with pagedExpand without error', async () => { + const client = new echoModule.v1beta1.EchoClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.PagedExpandRequest());const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.EchoResponse()), + generateSampleMessage(new protos.google.showcase.v1beta1.EchoResponse()), + generateSampleMessage(new protos.google.showcase.v1beta1.EchoResponse()), + ]; + client.descriptors.page.pagedExpand.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.IEchoResponse[] = []; + const iterable = client.pagedExpandAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.pagedExpand.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with pagedExpand with error', async () => { + const client = new echoModule.v1beta1.EchoClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.PagedExpandRequest());const expectedError = new Error('expected'); + client.descriptors.page.pagedExpand.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.pagedExpandAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.IEchoResponse[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.pagedExpand.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); }); describe('Path templates', () => { diff --git a/baselines/showcase/test/gapic_identity_v1beta1.ts.baseline b/baselines/showcase/test/gapic_identity_v1beta1.ts.baseline index bb9538d45..5c6eb6ace 100644 --- a/baselines/showcase/test/gapic_identity_v1beta1.ts.baseline +++ b/baselines/showcase/test/gapic_identity_v1beta1.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v1beta1.IdentityClient', () => { it('has servicePath', () => { const servicePath = identityModule.v1beta1.IdentityClient.servicePath; @@ -585,6 +605,49 @@ describe('v1beta1.IdentityClient', () => { assert((client.descriptors.page.listUsers.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listUsers, request)); }); + + it('uses async iteration with listUsers without error', async () => { + const client = new identityModule.v1beta1.IdentityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListUsersRequest());const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.User()), + generateSampleMessage(new protos.google.showcase.v1beta1.User()), + generateSampleMessage(new protos.google.showcase.v1beta1.User()), + ]; + client.descriptors.page.listUsers.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.IUser[] = []; + const iterable = client.listUsersAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listUsers.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listUsers with error', async () => { + const client = new identityModule.v1beta1.IdentityClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListUsersRequest());const expectedError = new Error('expected'); + client.descriptors.page.listUsers.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listUsersAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.IUser[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listUsers.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); }); describe('Path templates', () => { diff --git a/baselines/showcase/test/gapic_messaging_v1beta1.ts.baseline b/baselines/showcase/test/gapic_messaging_v1beta1.ts.baseline index 4209dabcf..184156ed4 100644 --- a/baselines/showcase/test/gapic_messaging_v1beta1.ts.baseline +++ b/baselines/showcase/test/gapic_messaging_v1beta1.ts.baseline @@ -115,6 +115,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v1beta1.MessagingClient', () => { it('has servicePath', () => { const servicePath = messagingModule.v1beta1.MessagingClient.servicePath; @@ -1266,6 +1286,49 @@ describe('v1beta1.MessagingClient', () => { assert((client.descriptors.page.listRooms.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listRooms, request)); }); + + it('uses async iteration with listRooms without error', async () => { + const client = new messagingModule.v1beta1.MessagingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListRoomsRequest());const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.Room()), + generateSampleMessage(new protos.google.showcase.v1beta1.Room()), + generateSampleMessage(new protos.google.showcase.v1beta1.Room()), + ]; + client.descriptors.page.listRooms.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.IRoom[] = []; + const iterable = client.listRoomsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listRooms.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listRooms with error', async () => { + const client = new messagingModule.v1beta1.MessagingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListRoomsRequest());const expectedError = new Error('expected'); + client.descriptors.page.listRooms.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listRoomsAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.IRoom[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listRooms.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); }); describe('listBlurbs', () => { @@ -1391,7 +1454,7 @@ describe('v1beta1.MessagingClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listBlurbs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listBlurbs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listBlurbs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -1425,12 +1488,69 @@ describe('v1beta1.MessagingClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listBlurbs.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listBlurbs, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listBlurbs.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listBlurbs without error', async () => { + const client = new messagingModule.v1beta1.MessagingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListBlurbsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.Blurb()), + generateSampleMessage(new protos.google.showcase.v1beta1.Blurb()), + generateSampleMessage(new protos.google.showcase.v1beta1.Blurb()), + ]; + client.descriptors.page.listBlurbs.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.IBlurb[] = []; + const iterable = client.listBlurbsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBlurbs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listBlurbs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listBlurbs with error', async () => { + const client = new messagingModule.v1beta1.MessagingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListBlurbsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listBlurbs.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listBlurbsAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.IBlurb[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBlurbs.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listBlurbs.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/showcase/test/gapic_testing_v1beta1.ts.baseline b/baselines/showcase/test/gapic_testing_v1beta1.ts.baseline index a49d849e7..8c434c389 100644 --- a/baselines/showcase/test/gapic_testing_v1beta1.ts.baseline +++ b/baselines/showcase/test/gapic_testing_v1beta1.ts.baseline @@ -66,6 +66,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v1beta1.TestingClient', () => { it('has servicePath', () => { const servicePath = testingModule.v1beta1.TestingClient.servicePath; @@ -750,6 +770,49 @@ describe('v1beta1.TestingClient', () => { assert((client.descriptors.page.listSessions.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listSessions, request)); }); + + it('uses async iteration with listSessions without error', async () => { + const client = new testingModule.v1beta1.TestingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListSessionsRequest());const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.Session()), + generateSampleMessage(new protos.google.showcase.v1beta1.Session()), + generateSampleMessage(new protos.google.showcase.v1beta1.Session()), + ]; + client.descriptors.page.listSessions.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.ISession[] = []; + const iterable = client.listSessionsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listSessions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); + + it('uses async iteration with listSessions with error', async () => { + const client = new testingModule.v1beta1.TestingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListSessionsRequest());const expectedError = new Error('expected'); + client.descriptors.page.listSessions.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSessionsAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.ISession[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listSessions.asyncIterate as SinonStub) + .getCall(0).args[1], request); + }); }); describe('listTests', () => { @@ -875,7 +938,7 @@ describe('v1beta1.TestingClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listTests.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listTests, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listTests.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -909,12 +972,69 @@ describe('v1beta1.TestingClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listTests.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listTests, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listTests.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listTests without error', async () => { + const client = new testingModule.v1beta1.TestingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListTestsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.showcase.v1beta1.Test()), + generateSampleMessage(new protos.google.showcase.v1beta1.Test()), + generateSampleMessage(new protos.google.showcase.v1beta1.Test()), + ]; + client.descriptors.page.listTests.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.showcase.v1beta1.ITest[] = []; + const iterable = client.listTestsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTests.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listTests.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listTests with error', async () => { + const client = new testingModule.v1beta1.TestingClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.showcase.v1beta1.ListTestsRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listTests.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listTestsAsync(request); + assert.rejects(async () => { + const responses: protos.google.showcase.v1beta1.ITest[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTests.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listTests.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/baselines/texttospeech/package.json b/baselines/texttospeech/package.json index e690169b4..52f70b103 100644 --- a/baselines/texttospeech/package.json +++ b/baselines/texttospeech/package.json @@ -24,7 +24,7 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^2.0.0" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/baselines/texttospeech/src/v1/text_to_speech_client.ts.baseline b/baselines/texttospeech/src/v1/text_to_speech_client.ts.baseline index 56ed8b107..68fc244ae 100644 --- a/baselines/texttospeech/src/v1/text_to_speech_client.ts.baseline +++ b/baselines/texttospeech/src/v1/text_to_speech_client.ts.baseline @@ -17,7 +17,7 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax'; import * as path from 'path'; import * as protos from '../../protos/protos'; @@ -173,9 +173,8 @@ export class TextToSpeechClient { // and create an API call method for each. const textToSpeechStubMethods = ['listVoices', 'synthesizeSpeech']; - for (const methodName of textToSpeechStubMethods) { - const innerCallPromise = this.textToSpeechStub.then( + const callPromise = this.textToSpeechStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -188,20 +187,14 @@ export class TextToSpeechClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.textToSpeechStub; @@ -270,14 +263,14 @@ export class TextToSpeechClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.texttospeech.v1.IListVoicesResponse, - protos.google.cloud.texttospeech.v1.IListVoicesRequest|undefined, - {}|undefined>): void; + protos.google.cloud.texttospeech.v1.IListVoicesRequest|null|undefined, + {}|null|undefined>): void; listVoices( request: protos.google.cloud.texttospeech.v1.IListVoicesRequest, callback: Callback< protos.google.cloud.texttospeech.v1.IListVoicesResponse, - protos.google.cloud.texttospeech.v1.IListVoicesRequest|undefined, - {}|undefined>): void; + protos.google.cloud.texttospeech.v1.IListVoicesRequest|null|undefined, + {}|null|undefined>): void; /** * Returns a list of Voice supported for synthesis. * @@ -302,11 +295,12 @@ export class TextToSpeechClient { request: protos.google.cloud.texttospeech.v1.IListVoicesRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.texttospeech.v1.IListVoicesResponse, - protos.google.cloud.texttospeech.v1.IListVoicesRequest|undefined, {}|undefined>, + protos.google.cloud.texttospeech.v1.IListVoicesRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.texttospeech.v1.IListVoicesResponse, - protos.google.cloud.texttospeech.v1.IListVoicesRequest|undefined, - {}|undefined>): + protos.google.cloud.texttospeech.v1.IListVoicesRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.texttospeech.v1.IListVoicesResponse, protos.google.cloud.texttospeech.v1.IListVoicesRequest|undefined, {}|undefined @@ -336,14 +330,14 @@ export class TextToSpeechClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.texttospeech.v1.ISynthesizeSpeechResponse, - protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest|undefined, - {}|undefined>): void; + protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest|null|undefined, + {}|null|undefined>): void; synthesizeSpeech( request: protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest, callback: Callback< protos.google.cloud.texttospeech.v1.ISynthesizeSpeechResponse, - protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest|undefined, - {}|undefined>): void; + protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest|null|undefined, + {}|null|undefined>): void; /** * Synthesizes speech synchronously: receive results after all text input * has been processed. @@ -366,11 +360,12 @@ export class TextToSpeechClient { request: protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.texttospeech.v1.ISynthesizeSpeechResponse, - protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest|undefined, {}|undefined>, + protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.texttospeech.v1.ISynthesizeSpeechResponse, - protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest|undefined, - {}|undefined>): + protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.texttospeech.v1.ISynthesizeSpeechResponse, protos.google.cloud.texttospeech.v1.ISynthesizeSpeechRequest|undefined, {}|undefined diff --git a/baselines/translate/package.json b/baselines/translate/package.json index 5c7fde7d9..e387591be 100644 --- a/baselines/translate/package.json +++ b/baselines/translate/package.json @@ -24,7 +24,7 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^2.0.0" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/baselines/translate/src/v3beta1/translation_service_client.ts.baseline b/baselines/translate/src/v3beta1/translation_service_client.ts.baseline index 2ae210cab..41da2a0d2 100644 --- a/baselines/translate/src/v3beta1/translation_service_client.ts.baseline +++ b/baselines/translate/src/v3beta1/translation_service_client.ts.baseline @@ -17,10 +17,11 @@ // ** All changes to this file may be overwritten. ** import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback} from 'google-gax'; import * as path from 'path'; import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import * as gapicConfig from './translation_service_client_config.json'; @@ -237,9 +238,8 @@ export class TranslationServiceClient { // and create an API call method for each. const translationServiceStubMethods = ['translateText', 'detectLanguage', 'getSupportedLanguages', 'batchTranslateText', 'createGlossary', 'listGlossaries', 'getGlossary', 'deleteGlossary']; - for (const methodName of translationServiceStubMethods) { - const innerCallPromise = this.translationServiceStub.then( + const callPromise = this.translationServiceStub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -252,20 +252,14 @@ export class TranslationServiceClient { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.translationServiceStub; @@ -335,14 +329,14 @@ export class TranslationServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.translation.v3beta1.ITranslateTextResponse, - protos.google.cloud.translation.v3beta1.ITranslateTextRequest|undefined, - {}|undefined>): void; + protos.google.cloud.translation.v3beta1.ITranslateTextRequest|null|undefined, + {}|null|undefined>): void; translateText( request: protos.google.cloud.translation.v3beta1.ITranslateTextRequest, callback: Callback< protos.google.cloud.translation.v3beta1.ITranslateTextResponse, - protos.google.cloud.translation.v3beta1.ITranslateTextRequest|undefined, - {}|undefined>): void; + protos.google.cloud.translation.v3beta1.ITranslateTextRequest|null|undefined, + {}|null|undefined>): void; /** * Translates input text and returns translated text. * @@ -420,11 +414,12 @@ export class TranslationServiceClient { request: protos.google.cloud.translation.v3beta1.ITranslateTextRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.translation.v3beta1.ITranslateTextResponse, - protos.google.cloud.translation.v3beta1.ITranslateTextRequest|undefined, {}|undefined>, + protos.google.cloud.translation.v3beta1.ITranslateTextRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.translation.v3beta1.ITranslateTextResponse, - protos.google.cloud.translation.v3beta1.ITranslateTextRequest|undefined, - {}|undefined>): + protos.google.cloud.translation.v3beta1.ITranslateTextRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.translation.v3beta1.ITranslateTextResponse, protos.google.cloud.translation.v3beta1.ITranslateTextRequest|undefined, {}|undefined @@ -461,14 +456,14 @@ export class TranslationServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.translation.v3beta1.IDetectLanguageResponse, - protos.google.cloud.translation.v3beta1.IDetectLanguageRequest|undefined, - {}|undefined>): void; + protos.google.cloud.translation.v3beta1.IDetectLanguageRequest|null|undefined, + {}|null|undefined>): void; detectLanguage( request: protos.google.cloud.translation.v3beta1.IDetectLanguageRequest, callback: Callback< protos.google.cloud.translation.v3beta1.IDetectLanguageResponse, - protos.google.cloud.translation.v3beta1.IDetectLanguageRequest|undefined, - {}|undefined>): void; + protos.google.cloud.translation.v3beta1.IDetectLanguageRequest|null|undefined, + {}|null|undefined>): void; /** * Detects the language of text within a request. * @@ -520,11 +515,12 @@ export class TranslationServiceClient { request: protos.google.cloud.translation.v3beta1.IDetectLanguageRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.translation.v3beta1.IDetectLanguageResponse, - protos.google.cloud.translation.v3beta1.IDetectLanguageRequest|undefined, {}|undefined>, + protos.google.cloud.translation.v3beta1.IDetectLanguageRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.translation.v3beta1.IDetectLanguageResponse, - protos.google.cloud.translation.v3beta1.IDetectLanguageRequest|undefined, - {}|undefined>): + protos.google.cloud.translation.v3beta1.IDetectLanguageRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.translation.v3beta1.IDetectLanguageResponse, protos.google.cloud.translation.v3beta1.IDetectLanguageRequest|undefined, {}|undefined @@ -561,14 +557,14 @@ export class TranslationServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.translation.v3beta1.ISupportedLanguages, - protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest|undefined, - {}|undefined>): void; + protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest|null|undefined, + {}|null|undefined>): void; getSupportedLanguages( request: protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest, callback: Callback< protos.google.cloud.translation.v3beta1.ISupportedLanguages, - protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest|undefined, - {}|undefined>): void; + protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest|null|undefined, + {}|null|undefined>): void; /** * Returns a list of supported languages for translation. * @@ -617,11 +613,12 @@ export class TranslationServiceClient { request: protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.translation.v3beta1.ISupportedLanguages, - protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest|undefined, {}|undefined>, + protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.translation.v3beta1.ISupportedLanguages, - protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest|undefined, - {}|undefined>): + protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.translation.v3beta1.ISupportedLanguages, protos.google.cloud.translation.v3beta1.IGetSupportedLanguagesRequest|undefined, {}|undefined @@ -658,14 +655,14 @@ export class TranslationServiceClient { options: gax.CallOptions, callback: Callback< protos.google.cloud.translation.v3beta1.IGlossary, - protos.google.cloud.translation.v3beta1.IGetGlossaryRequest|undefined, - {}|undefined>): void; + protos.google.cloud.translation.v3beta1.IGetGlossaryRequest|null|undefined, + {}|null|undefined>): void; getGlossary( request: protos.google.cloud.translation.v3beta1.IGetGlossaryRequest, callback: Callback< protos.google.cloud.translation.v3beta1.IGlossary, - protos.google.cloud.translation.v3beta1.IGetGlossaryRequest|undefined, - {}|undefined>): void; + protos.google.cloud.translation.v3beta1.IGetGlossaryRequest|null|undefined, + {}|null|undefined>): void; /** * Gets a glossary. Returns NOT_FOUND, if the glossary doesn't * exist. @@ -684,11 +681,12 @@ export class TranslationServiceClient { request: protos.google.cloud.translation.v3beta1.IGetGlossaryRequest, optionsOrCallback?: gax.CallOptions|Callback< protos.google.cloud.translation.v3beta1.IGlossary, - protos.google.cloud.translation.v3beta1.IGetGlossaryRequest|undefined, {}|undefined>, + protos.google.cloud.translation.v3beta1.IGetGlossaryRequest|null|undefined, + {}|null|undefined>, callback?: Callback< protos.google.cloud.translation.v3beta1.IGlossary, - protos.google.cloud.translation.v3beta1.IGetGlossaryRequest|undefined, - {}|undefined>): + protos.google.cloud.translation.v3beta1.IGetGlossaryRequest|null|undefined, + {}|null|undefined>): Promise<[ protos.google.cloud.translation.v3beta1.IGlossary, protos.google.cloud.translation.v3beta1.IGetGlossaryRequest|undefined, {}|undefined @@ -726,14 +724,14 @@ export class TranslationServiceClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; batchTranslateText( request: protos.google.cloud.translation.v3beta1.IBatchTranslateTextRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * Translates a large volume of text in asynchronous batch mode. * This function provides real-time output as the inputs are being processed. @@ -807,11 +805,12 @@ export class TranslationServiceClient { request: protos.google.cloud.translation.v3beta1.IBatchTranslateTextRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -848,14 +847,14 @@ export class TranslationServiceClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; createGlossary( request: protos.google.cloud.translation.v3beta1.ICreateGlossaryRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * Creates a glossary and returns the long-running operation. Returns * NOT_FOUND, if the project doesn't exist. @@ -876,11 +875,12 @@ export class TranslationServiceClient { request: protos.google.cloud.translation.v3beta1.ICreateGlossaryRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -917,14 +917,14 @@ export class TranslationServiceClient { options: gax.CallOptions, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; deleteGlossary( request: protos.google.cloud.translation.v3beta1.IDeleteGlossaryRequest, callback: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): void; + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): void; /** * Deletes a glossary, or cancels glossary construction * if the glossary isn't created yet. @@ -944,11 +944,12 @@ export class TranslationServiceClient { request: protos.google.cloud.translation.v3beta1.IDeleteGlossaryRequest, optionsOrCallback?: gax.CallOptions|Callback< LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined>, + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation, - protos.google.longrunning.IOperation|undefined, - {}|undefined>): + protos.google.longrunning.IOperation|null|undefined, + {}|null|undefined>): Promise<[ LROperation, protos.google.longrunning.IOperation|undefined, {}|undefined @@ -986,13 +987,13 @@ export class TranslationServiceClient { options: gax.CallOptions, callback: PaginationCallback< protos.google.cloud.translation.v3beta1.IListGlossariesRequest, - protos.google.cloud.translation.v3beta1.IListGlossariesResponse|null, + protos.google.cloud.translation.v3beta1.IListGlossariesResponse|null|undefined, protos.google.cloud.translation.v3beta1.IGlossary>): void; listGlossaries( request: protos.google.cloud.translation.v3beta1.IListGlossariesRequest, callback: PaginationCallback< protos.google.cloud.translation.v3beta1.IListGlossariesRequest, - protos.google.cloud.translation.v3beta1.IListGlossariesResponse|null, + protos.google.cloud.translation.v3beta1.IListGlossariesResponse|null|undefined, protos.google.cloud.translation.v3beta1.IGlossary>): void; /** * Lists glossaries in a project. Returns NOT_FOUND, if the project doesn't @@ -1036,11 +1037,11 @@ export class TranslationServiceClient { request: protos.google.cloud.translation.v3beta1.IListGlossariesRequest, optionsOrCallback?: gax.CallOptions|PaginationCallback< protos.google.cloud.translation.v3beta1.IListGlossariesRequest, - protos.google.cloud.translation.v3beta1.IListGlossariesResponse|null, + protos.google.cloud.translation.v3beta1.IListGlossariesResponse|null|undefined, protos.google.cloud.translation.v3beta1.IGlossary>, callback?: PaginationCallback< protos.google.cloud.translation.v3beta1.IListGlossariesRequest, - protos.google.cloud.translation.v3beta1.IListGlossariesResponse|null, + protos.google.cloud.translation.v3beta1.IListGlossariesResponse|null|undefined, protos.google.cloud.translation.v3beta1.IGlossary>): Promise<[ protos.google.cloud.translation.v3beta1.IGlossary[], @@ -1123,6 +1124,55 @@ export class TranslationServiceClient { callSettings ); } + +/** + * Equivalent to {@link listGlossaries}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the project from which to list all of the glossaries. + * @param {number} [request.pageSize] + * Optional. Requested page size. The server may return fewer glossaries than + * requested. If unspecified, the server picks an appropriate default. + * @param {string} [request.pageToken] + * Optional. A token identifying a page of results the server should return. + * Typically, this is the value of [ListGlossariesResponse.next_page_token] + * returned from the previous call to `ListGlossaries` method. + * The first page is returned if `page_token`is empty or missing. + * @param {string} [request.filter] + * Optional. Filter specifying constraints of a list operation. + * Filtering is not supported yet, and the parameter currently has no effect. + * If missing, no filtering is performed. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. + */ + listGlossariesAsync( + request?: protos.google.cloud.translation.v3beta1.IListGlossariesRequest, + options?: gax.CallOptions): + AsyncIterable{ + request = request || {}; + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers[ + 'x-goog-request-params' + ] = gax.routingHeader.fromParams({ + 'parent': request.parent || '', + }); + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.listGlossaries.asyncIterate( + this.innerApiCalls['listGlossaries'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable; + } // -------------------- // -- Path templates -- // -------------------- diff --git a/baselines/translate/test/gapic_translation_service_v3beta1.ts.baseline b/baselines/translate/test/gapic_translation_service_v3beta1.ts.baseline index b6bf08880..9a151b3f9 100644 --- a/baselines/translate/test/gapic_translation_service_v3beta1.ts.baseline +++ b/baselines/translate/test/gapic_translation_service_v3beta1.ts.baseline @@ -82,6 +82,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: return sinon.stub().returns(mockStream); } +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} + describe('v3beta1.TranslationServiceClient', () => { it('has servicePath', () => { const servicePath = translationserviceModule.v3beta1.TranslationServiceClient.servicePath; @@ -956,7 +976,7 @@ describe('v3beta1.TranslationServiceClient', () => { assert.deepStrictEqual(responses, expectedResponse); assert((client.descriptors.page.listGlossaries.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listGlossaries, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listGlossaries.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -990,12 +1010,69 @@ describe('v3beta1.TranslationServiceClient', () => { assert.rejects(async () => { await promise; }, expectedError); assert((client.descriptors.page.listGlossaries.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.listGlossaries, request)); - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.listGlossaries.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); }); + + it('uses async iteration with listGlossaries without error', async () => { + const client = new translationserviceModule.v3beta1.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.translation.v3beta1.ListGlossariesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedResponse = [ + generateSampleMessage(new protos.google.cloud.translation.v3beta1.Glossary()), + generateSampleMessage(new protos.google.cloud.translation.v3beta1.Glossary()), + generateSampleMessage(new protos.google.cloud.translation.v3beta1.Glossary()), + ]; + client.descriptors.page.listGlossaries.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: protos.google.cloud.translation.v3beta1.IGlossary[] = []; + const iterable = client.listGlossariesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listGlossaries.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listGlossaries.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listGlossaries with error', async () => { + const client = new translationserviceModule.v3beta1.TranslationServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage(new protos.google.cloud.translation.v3beta1.ListGlossariesRequest()); + request.parent = ''; + const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); + client.descriptors.page.listGlossaries.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listGlossariesAsync(request); + assert.rejects(async () => { + const responses: protos.google.cloud.translation.v3beta1.IGlossary[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listGlossaries.asyncIterate as SinonStub) + .getCall(0).args[1], request); + assert.strictEqual( + (client.descriptors.page.listGlossaries.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); }); describe('Path templates', () => { diff --git a/package.json b/package.json index 47341e31a..a44456c24 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "file-system": "^2.2.2", "fs-extra": "^9.0.0", "get-stdin": "^7.0.0", - "google-gax": "^2.0.0", + "google-gax": "^2.0.1", "js-yaml": "^3.13.1", "nunjucks": "^3.2.1", "object-hash": "^2.0.3", diff --git a/templates/typescript_gapic/_util.njk b/templates/typescript_gapic/_util.njk index db972f00f..5972519a5 100644 --- a/templates/typescript_gapic/_util.njk +++ b/templates/typescript_gapic/_util.njk @@ -34,6 +34,14 @@ limitations under the License. {{- printReturnPageStream(method) }} {%- endmacro -%} +{%- macro printCommentsPageAsync(method) -%} + {{- printPageAsyncHeader(method) -}} + {{- printRequest(method) -}} + {{- printCommentsForParams(method) -}} + {{- printOptions() -}} + {{- printReturnPageAsync(method) }} +{%- endmacro -%} + {%- macro printCommentsForService(service) -%} {%- set lines = service.comments -%} {% for line in lines %} @@ -53,6 +61,14 @@ limitations under the License. {%- endfor %} {%- endmacro -%} + +{%- macro printPageAsyncHeader(method) %} + * Equivalent to {@link {{ method.name.toCamelCase() }}}, but returns an iterable object. + * + * for-await-of syntax is used with the iterable to recursively get response element on-demand. + * +{%- endmacro -%} + {%- macro printPageStreamHeader(method) %} * Equivalent to {@link {{ method.name.toCamelCase() }}}, but returns a NodeJS Stream object. * @@ -165,6 +181,11 @@ limitations under the License. * An object stream which emits an object representing {{ typeLink(method.pagingResponseType) }} on 'data' event. {%- endmacro -%} +{%- macro printReturnPageAsync(method) %} + * @returns {Object} + * An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols. +{%- endmacro -%} + {%- macro printRequestField(oneComment) %} {%- if oneComment.fieldBehavior and oneComment.fieldBehavior === 1 -%} [request.{{ oneComment.paramName.toCamelCase() }}] diff --git a/templates/typescript_gapic/package.json b/templates/typescript_gapic/package.json index 28ab576f8..6c7bc637e 100644 --- a/templates/typescript_gapic/package.json +++ b/templates/typescript_gapic/package.json @@ -24,7 +24,7 @@ "test": "c8 mocha build/test" }, "dependencies": { - "google-gax": "^2.0.0" + "google-gax": "^2.0.1" }, "devDependencies": { "@types/mocha": "^5.2.7", diff --git a/templates/typescript_gapic/src/$version/$service_client.ts.njk b/templates/typescript_gapic/src/$version/$service_client.ts.njk index d9f085d97..5c96915d4 100644 --- a/templates/typescript_gapic/src/$version/$service_client.ts.njk +++ b/templates/typescript_gapic/src/$version/$service_client.ts.njk @@ -20,13 +20,14 @@ limitations under the License. {% import "../../_util.njk" as util -%} import * as gax from 'google-gax'; -import {APICallback, Callback, CallOptions, Descriptors, ClientOptions +import {GaxCall, Callback, CallOptions, Descriptors, ClientOptions {%- if service.longRunning.length > 0 %}, LROperation{%- endif -%} {%- if service.paging.length > 0 %}, PaginationCallback{%- endif -%} } from 'google-gax'; import * as path from 'path'; {% if (service.paging.length > 0) %} import { Transform } from 'stream'; +import { RequestType } from 'google-gax/build/src/apitypes'; {%- endif %} import * as protos from '../../protos/protos'; import * as gapicConfig from './{{ service.name.toSnakeCase() }}_client_config.json'; @@ -298,9 +299,8 @@ export class {{ service.name }}Client { '{{ method.name.toCamelCase() }}' {%- endfor -%} ]; - for (const methodName of {{ service.name.toCamelCase() }}StubMethods) { - const innerCallPromise = this.{{ service.name.toCamelCase() }}Stub.then( + const callPromise = this.{{ service.name.toCamelCase() }}Stub.then( stub => (...args: Array<{}>) => { if (this._terminated) { return Promise.reject('The client has already been closed.'); @@ -313,20 +313,14 @@ export class {{ service.name }}Client { }); const apiCall = this._gaxModule.createApiCall( - innerCallPromise, + callPromise, this._defaults[methodName], this.descriptors.page[methodName] || this.descriptors.stream[methodName] || this.descriptors.longrunning[methodName] ); - this.innerApiCalls[methodName] = ( - argument: {}, - callOptions?: CallOptions, - callback?: APICallback - ) => { - return apiCall(argument, callOptions, callback); - }; + this.innerApiCalls[methodName] = apiCall; } return this.{{ service.name.toCamelCase() }}Stub; @@ -405,14 +399,14 @@ export class {{ service.name }}Client { options: gax.CallOptions, callback: Callback< {{ util.toInterface(method.outputInterface) }}, - {{ util.toInterface(method.inputInterface) }}|undefined, - {}|undefined>): void; + {{ util.toInterface(method.inputInterface) }}|null|undefined, + {}|null|undefined>): void; {{ method.name.toCamelCase() }}( request: {{ util.toInterface(method.inputInterface) }}, callback: Callback< {{ util.toInterface(method.outputInterface) }}, - {{ util.toInterface(method.inputInterface) }}|undefined, - {}|undefined>): void; + {{ util.toInterface(method.inputInterface) }}|null|undefined, + {}|null|undefined>): void; /** {{- util.printComments(method, service) }} */ @@ -420,11 +414,12 @@ export class {{ service.name }}Client { request: {{ util.toInterface(method.inputInterface) }}, optionsOrCallback?: gax.CallOptions|Callback< {{ util.toInterface(method.outputInterface) }}, - {{ util.toInterface(method.inputInterface) }}|undefined, {}|undefined>, + {{ util.toInterface(method.inputInterface) }}|null|undefined, + {}|null|undefined>, callback?: Callback< {{ util.toInterface(method.outputInterface) }}, - {{ util.toInterface(method.inputInterface) }}|undefined, - {}|undefined>): + {{ util.toInterface(method.inputInterface) }}|null|undefined, + {}|null|undefined>): Promise<[ {{ util.toInterface(method.outputInterface) }}, {{ util.toInterface(method.inputInterface) }}|undefined, {}|undefined @@ -472,12 +467,14 @@ export class {{ service.name }}Client { options?: gax.CallOptions, callback?: Callback< {{ util.toInterface(method.outputInterface) }}, - {{ util.toInterface(method.inputInterface) }}|undefined, {}|undefined>): + {{ util.toInterface(method.inputInterface) }}|null|undefined, + {}|null|undefined>): gax.CancellableStream; {{ method.name.toCamelCase() }}( callback?: Callback< {{ util.toInterface(method.outputInterface) }}, - {{ util.toInterface(method.inputInterface) }}|undefined, {}|undefined>): + {{ util.toInterface(method.inputInterface) }}|null|undefined, + {}|null|undefined>): gax.CancellableStream; /** {{- util.printComments(method, service) }} @@ -485,10 +482,12 @@ export class {{ service.name }}Client { {{ method.name.toCamelCase() }}( optionsOrCallback?: gax.CallOptions|Callback< {{ util.toInterface(method.outputInterface) }}, - {{ util.toInterface(method.inputInterface) }}|undefined, {}|undefined>, + {{ util.toInterface(method.inputInterface) }}|null|undefined, + {}|null|undefined>, callback?: Callback< {{ util.toInterface(method.outputInterface) }}, - {{ util.toInterface(method.inputInterface) }}|undefined, {}|undefined>): + {{ util.toInterface(method.inputInterface) }}|null|undefined, + {}|null|undefined>): gax.CancellableStream { if (optionsOrCallback instanceof Function && callback === undefined) { callback = optionsOrCallback; @@ -513,14 +512,14 @@ export class {{ service.name }}Client { options: gax.CallOptions, callback: Callback< LROperation<{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, {{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>, - {{ util.toInterface(method.outputInterface) }}|undefined, - {}|undefined>): void; + {{ util.toInterface(method.outputInterface) }}|null|undefined, + {}|null|undefined>): void; {{ method.name.toCamelCase() }}( request: {{ util.toInterface(method.inputInterface) }}, callback: Callback< LROperation<{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, {{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>, - {{ util.toInterface(method.outputInterface) }}|undefined, - {}|undefined>): void; + {{ util.toInterface(method.outputInterface) }}|null|undefined, + {}|null|undefined>): void; /** {{- util.printComments(method, service) }} */ @@ -528,11 +527,12 @@ export class {{ service.name }}Client { request: {{ util.toInterface(method.inputInterface) }}, optionsOrCallback?: gax.CallOptions|Callback< LROperation<{{ util.toInterface(method.longRunningResponseType, method.inputType)}}, {{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>, - {{ util.toInterface(method.outputInterface) }}|undefined, {}|undefined>, + {{ util.toInterface(method.outputInterface) }}|null|undefined, + {}|null|undefined>, callback?: Callback< LROperation<{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, {{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>, - {{ util.toInterface(method.outputInterface) }}|undefined, - {}|undefined>): + {{ util.toInterface(method.outputInterface) }}|null|undefined, + {}|null|undefined>): Promise<[ LROperation<{{ util.toInterface(method.longRunningResponseType, method.inputType) }}, {{ util.toInterface(method.longRunningMetadataType, method.inputType) }}>, {{ util.toInterface(method.outputInterface) }}|undefined, {}|undefined @@ -565,13 +565,13 @@ export class {{ service.name }}Client { options: gax.CallOptions, callback: PaginationCallback< {{ util.toInterface(method.inputInterface) }}, - {{ util.toInterface(method.outputInterface) }}|null, + {{ util.toInterface(method.outputInterface) }}|null|undefined, {{ util.toInterface(method.pagingResponseType) }}>): void; {{ method.name.toCamelCase() }}( request: {{ util.toInterface(method.inputInterface) }}, callback: PaginationCallback< {{ util.toInterface(method.inputInterface) }}, - {{ util.toInterface(method.outputInterface) }}|null, + {{ util.toInterface(method.outputInterface) }}|null|undefined, {{ util.toInterface(method.pagingResponseType) }}>): void; /** {{- util.printComments(method, service) }} @@ -580,11 +580,11 @@ export class {{ service.name }}Client { request: {{ util.toInterface(method.inputInterface) }}, optionsOrCallback?: gax.CallOptions|PaginationCallback< {{ util.toInterface(method.inputInterface) }}, - {{ util.toInterface(method.outputInterface) }}|null, + {{ util.toInterface(method.outputInterface) }}|null|undefined, {{ util.toInterface(method.pagingResponseType) }}>, callback?: PaginationCallback< {{ util.toInterface(method.inputInterface) }}, - {{ util.toInterface(method.outputInterface) }}|null, + {{ util.toInterface(method.outputInterface) }}|null|undefined, {{ util.toInterface(method.pagingResponseType) }}>): Promise<[ {{ util.toInterface(method.pagingResponseType) }}[], @@ -622,6 +622,25 @@ export class {{ service.name }}Client { callSettings ); } + +/** +{{- util.printCommentsPageAsync(method) }} + */ + {{ method.name.toCamelCase() }}Async( + request?: {{ util.toInterface(method.inputInterface) }}, + options?: gax.CallOptions): + AsyncIterable<{{ util.toInterface(method.pagingResponseType) }}>{ + request = request || {}; + {{ util.buildHeaderRequestParam(method) }} + options = options || {}; + const callSettings = new gax.CallSettings(options); + this.initialize(); + return this.descriptors.page.{{ method.name.toCamelCase() }}.asyncIterate( + this.innerApiCalls['{{ method.name.toCamelCase() }}'] as GaxCall, + request as unknown as RequestType, + callSettings + ) as AsyncIterable<{{ util.toInterface(method.pagingResponseType) }}>; + } {%- endfor %} {%- if (service.pathTemplates.length > 0) %} // -------------------- diff --git a/templates/typescript_gapic/test/gapic_$service_$version.ts.njk b/templates/typescript_gapic/test/gapic_$service_$version.ts.njk index ba9f81813..e8a326220 100644 --- a/templates/typescript_gapic/test/gapic_$service_$version.ts.njk +++ b/templates/typescript_gapic/test/gapic_$service_$version.ts.njk @@ -131,6 +131,26 @@ function stubPageStreamingCall(responses?: ResponseType[], error?: } return sinon.stub().returns(mockStream); } + +function stubAsyncIterationCall(responses?: ResponseType[], error?: Error) { + let counter = 0; + const asyncIterable = { + [Symbol.asyncIterator]() { + return { + async next() { + if (error) { + return Promise.reject(error); + } + if (counter >= responses!.length) { + return Promise.resolve({done: true, value: undefined}); + } + return Promise.resolve({done: false, value: responses![counter++]}); + } + }; + } + }; + return sinon.stub().returns(asyncIterable); +} {%- endif %} describe('{{ api.naming.version }}.{{ service.name }}Client', () => { @@ -616,7 +636,7 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { assert((client.descriptors.page.{{ method.name.toCamelCase() }}.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.{{ method.name.toCamelCase() }}, request)); {%- if method.headerRequestParams.length > 0 %} - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.{{ method.name.toCamelCase() }}.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams @@ -650,11 +670,66 @@ describe('{{ api.naming.version }}.{{ service.name }}Client', () => { assert((client.descriptors.page.{{ method.name.toCamelCase() }}.createStream as SinonStub) .getCall(0).calledWith(client.innerApiCalls.{{ method.name.toCamelCase() }}, request)); {%- if method.headerRequestParams.length > 0 %} - assert.deepStrictEqual( + assert.strictEqual( (client.descriptors.page.{{ method.name.toCamelCase() }}.createStream as SinonStub) .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], expectedHeaderRequestParams ); +{%- endif %} + }); + + it('uses async iteration with {{ method.name.toCamelCase() }} without error', async () => { + const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + {{ util.initRequestWithHeaderParam(method) -}} + {{ util.initPagingResponse(method) }} + client.descriptors.page.{{ method.name.toCamelCase() }}.asyncIterate = stubAsyncIterationCall(expectedResponse); + const responses: {{ util.toInterface(method.pagingResponseType) }}[] = []; + const iterable = client.{{ method.name.toCamelCase() }}Async(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.{{ method.name.toCamelCase() }}.asyncIterate as SinonStub) + .getCall(0).args[1], request); +{%- if method.headerRequestParams.length > 0 %} + assert.strictEqual( + (client.descriptors.page.{{ method.name.toCamelCase() }}.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); +{%- endif %} + }); + + it('uses async iteration with {{ method.name.toCamelCase() }} with error', async () => { + const client = new {{ service.name.toLowerCase() }}Module.{{ api.naming.version }}.{{ service.name }}Client({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + {{ util.initRequestWithHeaderParam(method) -}} + const expectedError = new Error('expected'); + client.descriptors.page.{{ method.name.toCamelCase() }}.asyncIterate = stubAsyncIterationCall(undefined, expectedError); + const iterable = client.{{ method.name.toCamelCase() }}Async(request); + assert.rejects(async () => { + const responses: {{ util.toInterface(method.pagingResponseType) }}[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.{{ method.name.toCamelCase() }}.asyncIterate as SinonStub) + .getCall(0).args[1], request); +{%- if method.headerRequestParams.length > 0 %} + assert.strictEqual( + (client.descriptors.page.{{ method.name.toCamelCase() }}.asyncIterate as SinonStub) + .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); {%- endif %} }); }); diff --git a/test-fixtures/test-application-js/index.js b/test-fixtures/test-application-js/index.js index e0347cd0c..f1b2be0a6 100644 --- a/test-fixtures/test-application-js/index.js +++ b/test-fixtures/test-application-js/index.js @@ -52,6 +52,7 @@ function runTest(client, opts) { } testPagedExpand(client); testPagedExpandStream(client); + testPagedExpandAsync(client); testWait(client); } @@ -100,6 +101,22 @@ function testPagedExpand(client) { }); } +function testPagedExpandAsync(client) { + it('pagedExpandAsync', async () => { + const words = ['nobody', 'ever', 'reads', 'test', 'input']; + const request = { + content: words.join(' '), + pageSize: 2, + }; + const iterable = client.pagedExpandAsync(request); + const result = []; + for await (const resource of iterable) { + result.push(resource.content); + } + assert.deepStrictEqual(words, result); + }); +} + function testPagedExpandStream(client) { it('pagedExpand with streaming', async () => { const words = ['I', 'did', 'not', 'even', 'know', 'it', 'works']; diff --git a/test-fixtures/test-application-ts/package.json b/test-fixtures/test-application-ts/package.json index 7100537fa..cce361799 100644 --- a/test-fixtures/test-application-ts/package.json +++ b/test-fixtures/test-application-ts/package.json @@ -15,8 +15,8 @@ "showcase": "file:./showcase-0.1.0.tgz" }, "devDependencies": { - "gts": "^1.1.2", - "typescript": "~3.8.2", + "gts": "next", + "typescript": "^3.8.3", "@types/node": "^12.12.32", "@types/mocha": "^5.2.7", "mocha": "^6.2.3", diff --git a/test-fixtures/test-application-ts/src/index.ts b/test-fixtures/test-application-ts/src/index.ts index 54698a70f..f287c2452 100644 --- a/test-fixtures/test-application-ts/src/index.ts +++ b/test-fixtures/test-application-ts/src/index.ts @@ -15,15 +15,13 @@ import * as assert from 'assert'; import * as showcase from 'showcase'; -import * as grpc from '@grpc/grpc-js'; // to create credentials for local Showcase server - interface ClientOptions{ - [name: string]: Object; + [name: string]: {}; servicePath: string; port: number; } interface Options { - [name: string]: Object; + [name: string]: {}; } // Fake auth client for fallback const authStub = { @@ -93,6 +91,7 @@ function runTest(client: showcase.v1beta1.EchoClient, opts: Options) { testChat(client); } testPagedExpand(client); + testPagedExpandAsync(client); testWait(client); } @@ -129,7 +128,7 @@ function testExpand(client: showcase.v1beta1.EchoClient) { } function testPagedExpand(client: showcase.v1beta1.EchoClient) { - it('pagedExpand', async () => { + it('pagedExpandAsync', async () => { const words = ['nobody', 'ever', 'reads', 'test', 'input']; const request = { content: words.join(' '), @@ -141,6 +140,22 @@ function testPagedExpand(client: showcase.v1beta1.EchoClient) { }); } +function testPagedExpandAsync(client: showcase.v1beta1.EchoClient) { + it('pagedExpandAsync', async () => { + const words = ['nobody', 'ever', 'reads', 'test', 'input']; + const request = { + content: words.join(' '), + pageSize: 2, + }; + const iterable = client.pagedExpandAsync(request); + const result: string[] = []; + for await (const resource of iterable) { + result.push(resource.content!); + } + assert.deepStrictEqual(words, result); + }); +} + function testCollect(client: showcase.v1beta1.EchoClient) { it('collect', async () => { const words = ['nobody', 'ever', 'reads', 'test', 'input'];