diff --git a/src/v2/bigtable_instance_admin_client.ts b/src/v2/bigtable_instance_admin_client.ts index 63306282c..d55fb25f6 100644 --- a/src/v2/bigtable_instance_admin_client.ts +++ b/src/v2/bigtable_instance_admin_client.ts @@ -18,10 +18,21 @@ /* global window */ import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; - -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; + +import {Transform} from 'stream'; +import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -30,7 +41,7 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './bigtable_instance_admin_client_config.json'; -import { operationsProtos } from 'google-gax'; +import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; /** @@ -97,12 +108,18 @@ export class BigtableInstanceAdminClient { */ constructor(opts?: ClientOptions) { // Ensure that options include all the required fields. - const staticMembers = this.constructor as typeof BigtableInstanceAdminClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const staticMembers = this + .constructor as typeof BigtableInstanceAdminClient; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. @@ -120,7 +137,7 @@ export class BigtableInstanceAdminClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -133,13 +150,9 @@ export class BigtableInstanceAdminClient { this.auth.defaultScopes = staticMembers.scopes; } this.locationsClient = new LocationsClient(this._gaxGrpc, opts); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -147,7 +160,7 @@ export class BigtableInstanceAdminClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { + } else if (opts.fallback === 'rest') { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -190,10 +203,16 @@ export class BigtableInstanceAdminClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listAppProfiles: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'appProfiles'), - listHotTablets: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'hotTablets') + listAppProfiles: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'appProfiles' + ), + listHotTablets: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'hotTablets' + ), }; const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); @@ -202,69 +221,119 @@ export class BigtableInstanceAdminClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback === 'rest') { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v2/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v2/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v2/{name=operations/**}:cancel',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=operations/**}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=operations/**}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=operations/projects/**}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v2/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v2/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v2/{name=operations/**}:cancel', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v2/{name=operations/**}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=operations/**}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=operations/projects/**}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createInstanceResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.Instance') as gax.protobuf.Type; + '.google.bigtable.admin.v2.Instance' + ) as gax.protobuf.Type; const createInstanceMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.CreateInstanceMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.CreateInstanceMetadata' + ) as gax.protobuf.Type; const partialUpdateInstanceResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.Instance') as gax.protobuf.Type; + '.google.bigtable.admin.v2.Instance' + ) as gax.protobuf.Type; const partialUpdateInstanceMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.UpdateInstanceMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.UpdateInstanceMetadata' + ) as gax.protobuf.Type; const createClusterResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.Cluster') as gax.protobuf.Type; + '.google.bigtable.admin.v2.Cluster' + ) as gax.protobuf.Type; const createClusterMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.CreateClusterMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.CreateClusterMetadata' + ) as gax.protobuf.Type; const updateClusterResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.Cluster') as gax.protobuf.Type; + '.google.bigtable.admin.v2.Cluster' + ) as gax.protobuf.Type; const updateClusterMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.UpdateClusterMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.UpdateClusterMetadata' + ) as gax.protobuf.Type; const partialUpdateClusterResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.Cluster') as gax.protobuf.Type; + '.google.bigtable.admin.v2.Cluster' + ) as gax.protobuf.Type; const partialUpdateClusterMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.PartialUpdateClusterMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.PartialUpdateClusterMetadata' + ) as gax.protobuf.Type; const updateAppProfileResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.AppProfile') as gax.protobuf.Type; + '.google.bigtable.admin.v2.AppProfile' + ) as gax.protobuf.Type; const updateAppProfileMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.UpdateAppProfileMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.UpdateAppProfileMetadata' + ) as gax.protobuf.Type; this.descriptors.longrunning = { createInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createInstanceResponse.decode.bind(createInstanceResponse), - createInstanceMetadata.decode.bind(createInstanceMetadata)), + createInstanceMetadata.decode.bind(createInstanceMetadata) + ), partialUpdateInstance: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - partialUpdateInstanceResponse.decode.bind(partialUpdateInstanceResponse), - partialUpdateInstanceMetadata.decode.bind(partialUpdateInstanceMetadata)), + partialUpdateInstanceResponse.decode.bind( + partialUpdateInstanceResponse + ), + partialUpdateInstanceMetadata.decode.bind(partialUpdateInstanceMetadata) + ), createCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createClusterResponse.decode.bind(createClusterResponse), - createClusterMetadata.decode.bind(createClusterMetadata)), + createClusterMetadata.decode.bind(createClusterMetadata) + ), updateCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateClusterResponse.decode.bind(updateClusterResponse), - updateClusterMetadata.decode.bind(updateClusterMetadata)), + updateClusterMetadata.decode.bind(updateClusterMetadata) + ), partialUpdateCluster: new this._gaxModule.LongrunningDescriptor( this.operationsClient, partialUpdateClusterResponse.decode.bind(partialUpdateClusterResponse), - partialUpdateClusterMetadata.decode.bind(partialUpdateClusterMetadata)), + partialUpdateClusterMetadata.decode.bind(partialUpdateClusterMetadata) + ), updateAppProfile: new this._gaxModule.LongrunningDescriptor( this.operationsClient, updateAppProfileResponse.decode.bind(updateAppProfileResponse), - updateAppProfileMetadata.decode.bind(updateAppProfileMetadata)) + updateAppProfileMetadata.decode.bind(updateAppProfileMetadata) + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.bigtable.admin.v2.BigtableInstanceAdmin', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.bigtable.admin.v2.BigtableInstanceAdmin', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -295,28 +364,55 @@ export class BigtableInstanceAdminClient { // Put together the "service stub" for // google.bigtable.admin.v2.BigtableInstanceAdmin. this.bigtableInstanceAdminStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.bigtable.admin.v2.BigtableInstanceAdmin') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.bigtable.admin.v2.BigtableInstanceAdmin' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.bigtable.admin.v2.BigtableInstanceAdmin, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath + ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const bigtableInstanceAdminStubMethods = - ['createInstance', 'getInstance', 'listInstances', 'updateInstance', 'partialUpdateInstance', 'deleteInstance', 'createCluster', 'getCluster', 'listClusters', 'updateCluster', 'partialUpdateCluster', 'deleteCluster', 'createAppProfile', 'getAppProfile', 'listAppProfiles', 'updateAppProfile', 'deleteAppProfile', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions', 'listHotTablets']; + const bigtableInstanceAdminStubMethods = [ + 'createInstance', + 'getInstance', + 'listInstances', + 'updateInstance', + 'partialUpdateInstance', + 'deleteInstance', + 'createCluster', + 'getCluster', + 'listClusters', + 'updateCluster', + 'partialUpdateCluster', + 'deleteCluster', + 'createAppProfile', + 'getAppProfile', + 'listAppProfiles', + 'updateAppProfile', + 'deleteAppProfile', + 'getIamPolicy', + 'setIamPolicy', + 'testIamPermissions', + 'listHotTablets', + ]; for (const methodName of bigtableInstanceAdminStubMethods) { const callPromise = this.bigtableInstanceAdminStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + stub => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + } + ); const descriptor = this.descriptors.page[methodName] || @@ -372,7 +468,7 @@ export class BigtableInstanceAdminClient { 'https://www.googleapis.com/auth/cloud-bigtable.admin', 'https://www.googleapis.com/auth/cloud-bigtable.admin.cluster', 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only' + 'https://www.googleapis.com/auth/cloud-platform.read-only', ]; } @@ -382,8 +478,9 @@ export class BigtableInstanceAdminClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -394,1769 +491,2246 @@ export class BigtableInstanceAdminClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Gets information about an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the requested instance. Values are of the form - * `projects/{project}/instances/{instance}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Instance]{@link google.bigtable.admin.v2.Instance}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.get_instance.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_GetInstance_async - */ + /** + * Gets information about an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the requested instance. Values are of the form + * `projects/{project}/instances/{instance}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Instance]{@link google.bigtable.admin.v2.Instance}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.get_instance.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_GetInstance_async + */ getInstance( - request?: protos.google.bigtable.admin.v2.IGetInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IGetInstanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IGetInstanceRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IGetInstanceRequest | undefined, + {} | undefined + ] + >; getInstance( - request: protos.google.bigtable.admin.v2.IGetInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IGetInstanceRequest | null | undefined, + {} | null | undefined + > + ): void; getInstance( - request: protos.google.bigtable.admin.v2.IGetInstanceRequest, - callback: Callback< - protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetInstanceRequest, + callback: Callback< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IGetInstanceRequest | null | undefined, + {} | null | undefined + > + ): void; getInstance( - request?: protos.google.bigtable.admin.v2.IGetInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IGetInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IGetInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IGetInstanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IGetInstanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IGetInstanceRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IGetInstanceRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getInstance(request, options, callback); } -/** - * Lists information about instances in a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the project for which a list of instances is requested. - * Values are of the form `projects/{project}`. - * @param {string} request.pageToken - * DEPRECATED: This field is unused and ignored. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ListInstancesResponse]{@link google.bigtable.admin.v2.ListInstancesResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.list_instances.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_ListInstances_async - */ + /** + * Lists information about instances in a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the project for which a list of instances is requested. + * Values are of the form `projects/{project}`. + * @param {string} request.pageToken + * DEPRECATED: This field is unused and ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ListInstancesResponse]{@link google.bigtable.admin.v2.ListInstancesResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.list_instances.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_ListInstances_async + */ listInstances( - request?: protos.google.bigtable.admin.v2.IListInstancesRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IListInstancesResponse, - protos.google.bigtable.admin.v2.IListInstancesRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IListInstancesRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IListInstancesResponse, + protos.google.bigtable.admin.v2.IListInstancesRequest | undefined, + {} | undefined + ] + >; listInstances( - request: protos.google.bigtable.admin.v2.IListInstancesRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.IListInstancesResponse, - protos.google.bigtable.admin.v2.IListInstancesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IListInstancesRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.IListInstancesResponse, + protos.google.bigtable.admin.v2.IListInstancesRequest | null | undefined, + {} | null | undefined + > + ): void; listInstances( - request: protos.google.bigtable.admin.v2.IListInstancesRequest, - callback: Callback< - protos.google.bigtable.admin.v2.IListInstancesResponse, - protos.google.bigtable.admin.v2.IListInstancesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IListInstancesRequest, + callback: Callback< + protos.google.bigtable.admin.v2.IListInstancesResponse, + protos.google.bigtable.admin.v2.IListInstancesRequest | null | undefined, + {} | null | undefined + > + ): void; listInstances( - request?: protos.google.bigtable.admin.v2.IListInstancesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.IListInstancesResponse, - protos.google.bigtable.admin.v2.IListInstancesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IListInstancesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.IListInstancesResponse, - protos.google.bigtable.admin.v2.IListInstancesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.IListInstancesResponse, - protos.google.bigtable.admin.v2.IListInstancesRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IListInstancesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.IListInstancesResponse, + protos.google.bigtable.admin.v2.IListInstancesRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IListInstancesResponse, + protos.google.bigtable.admin.v2.IListInstancesRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listInstances(request, options, callback); } -/** - * Updates an instance within a project. This method updates only the display - * name and type for an Instance. To update other Instance properties, such as - * labels, use PartialUpdateInstance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The unique name of the instance. Values are of the form - * `projects/{project}/instances/{@link a-z0-9\\-|a-z}+[a-z0-9]`. - * @param {string} request.displayName - * Required. The descriptive name for this instance as it appears in UIs. - * Can be changed at any time, but should be kept globally unique - * to avoid confusion. - * @param {google.bigtable.admin.v2.Instance.State} request.state - * Output only. The current state of the instance. - * @param {google.bigtable.admin.v2.Instance.Type} request.type - * Required. The type of the instance. Defaults to `PRODUCTION`. - * @param {number[]} request.labels - * Required. Labels are a flexible and lightweight mechanism for organizing - * cloud resources into groups that reflect a customer's organizational needs - * and deployment strategies. They can be used to filter resources and - * aggregate metrics. - * - * * Label keys must be between 1 and 63 characters long and must conform to - * the regular expression: `{@link \p{Ll}\p{Lo}\p{N}_-|\p{Ll}\p{Lo}}{0,62}`. - * * Label values must be between 0 and 63 characters long and must conform to - * the regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}`. - * * No more than 64 labels can be associated with a given resource. - * * Keys and values must both be under 128 bytes. - * @param {google.protobuf.Timestamp} request.createTime - * Output only. A server-assigned timestamp representing when this Instance - * was created. For instances created before this field was added (August - * 2021), this value is `seconds: 0, nanos: 1`. - * @param {boolean} request.satisfiesPzs - * Output only. Reserved for future use. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Instance]{@link google.bigtable.admin.v2.Instance}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.update_instance.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateInstance_async - */ + /** + * Updates an instance within a project. This method updates only the display + * name and type for an Instance. To update other Instance properties, such as + * labels, use PartialUpdateInstance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The unique name of the instance. Values are of the form + * `projects/{project}/instances/{@link a-z0-9\\-|a-z}+[a-z0-9]`. + * @param {string} request.displayName + * Required. The descriptive name for this instance as it appears in UIs. + * Can be changed at any time, but should be kept globally unique + * to avoid confusion. + * @param {google.bigtable.admin.v2.Instance.State} request.state + * Output only. The current state of the instance. + * @param {google.bigtable.admin.v2.Instance.Type} request.type + * Required. The type of the instance. Defaults to `PRODUCTION`. + * @param {number[]} request.labels + * Required. Labels are a flexible and lightweight mechanism for organizing + * cloud resources into groups that reflect a customer's organizational needs + * and deployment strategies. They can be used to filter resources and + * aggregate metrics. + * + * * Label keys must be between 1 and 63 characters long and must conform to + * the regular expression: `{@link \p{Ll}\p{Lo}\p{N}_-|\p{Ll}\p{Lo}}{0,62}`. + * * Label values must be between 0 and 63 characters long and must conform to + * the regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}`. + * * No more than 64 labels can be associated with a given resource. + * * Keys and values must both be under 128 bytes. + * @param {google.protobuf.Timestamp} request.createTime + * Output only. A server-assigned timestamp representing when this Instance + * was created. For instances created before this field was added (August + * 2021), this value is `seconds: 0, nanos: 1`. + * @param {boolean} request.satisfiesPzs + * Output only. Reserved for future use. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Instance]{@link google.bigtable.admin.v2.Instance}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.update_instance.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateInstance_async + */ updateInstance( - request?: protos.google.bigtable.admin.v2.IInstance, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IInstance|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IInstance, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IInstance | undefined, + {} | undefined + ] + >; updateInstance( - request: protos.google.bigtable.admin.v2.IInstance, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IInstance|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IInstance, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IInstance | null | undefined, + {} | null | undefined + > + ): void; updateInstance( - request: protos.google.bigtable.admin.v2.IInstance, - callback: Callback< - protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IInstance|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IInstance, + callback: Callback< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IInstance | null | undefined, + {} | null | undefined + > + ): void; updateInstance( - request?: protos.google.bigtable.admin.v2.IInstance, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IInstance|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IInstance, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IInstance|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.IInstance, - protos.google.bigtable.admin.v2.IInstance|undefined, {}|undefined - ]>|void { + protos.google.bigtable.admin.v2.IInstance | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IInstance | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IInstance | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.updateInstance(request, options, callback); } -/** - * Delete an instance from a project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the instance to be deleted. - * Values are of the form `projects/{project}/instances/{instance}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.delete_instance.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_DeleteInstance_async - */ + /** + * Delete an instance from a project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the instance to be deleted. + * Values are of the form `projects/{project}/instances/{instance}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.delete_instance.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_DeleteInstance_async + */ deleteInstance( - request?: protos.google.bigtable.admin.v2.IDeleteInstanceRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteInstanceRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IDeleteInstanceRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteInstanceRequest | undefined, + {} | undefined + ] + >; deleteInstance( - request: protos.google.bigtable.admin.v2.IDeleteInstanceRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteInstanceRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteInstanceRequest | null | undefined, + {} | null | undefined + > + ): void; deleteInstance( - request: protos.google.bigtable.admin.v2.IDeleteInstanceRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteInstanceRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteInstanceRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteInstanceRequest | null | undefined, + {} | null | undefined + > + ): void; deleteInstance( - request?: protos.google.bigtable.admin.v2.IDeleteInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteInstanceRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IDeleteInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteInstanceRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteInstanceRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IDeleteInstanceRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteInstanceRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteInstanceRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteInstance(request, options, callback); } -/** - * Gets information about a cluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the requested cluster. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Cluster]{@link google.bigtable.admin.v2.Cluster}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.get_cluster.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_GetCluster_async - */ + /** + * Gets information about a cluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the requested cluster. Values are of the form + * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Cluster]{@link google.bigtable.admin.v2.Cluster}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.get_cluster.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_GetCluster_async + */ getCluster( - request?: protos.google.bigtable.admin.v2.IGetClusterRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.ICluster, - protos.google.bigtable.admin.v2.IGetClusterRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IGetClusterRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IGetClusterRequest | undefined, + {} | undefined + ] + >; getCluster( - request: protos.google.bigtable.admin.v2.IGetClusterRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.ICluster, - protos.google.bigtable.admin.v2.IGetClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetClusterRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IGetClusterRequest | null | undefined, + {} | null | undefined + > + ): void; getCluster( - request: protos.google.bigtable.admin.v2.IGetClusterRequest, - callback: Callback< - protos.google.bigtable.admin.v2.ICluster, - protos.google.bigtable.admin.v2.IGetClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetClusterRequest, + callback: Callback< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IGetClusterRequest | null | undefined, + {} | null | undefined + > + ): void; getCluster( - request?: protos.google.bigtable.admin.v2.IGetClusterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.ICluster, - protos.google.bigtable.admin.v2.IGetClusterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IGetClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.ICluster, - protos.google.bigtable.admin.v2.IGetClusterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.ICluster, - protos.google.bigtable.admin.v2.IGetClusterRequest|undefined, {}|undefined - ]>|void { + protos.google.bigtable.admin.v2.IGetClusterRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IGetClusterRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IGetClusterRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getCluster(request, options, callback); } -/** - * Lists information about clusters in an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the instance for which a list of clusters is requested. - * Values are of the form `projects/{project}/instances/{instance}`. - * Use `{instance} = '-'` to list Clusters for all Instances in a project, - * e.g., `projects/myproject/instances/-`. - * @param {string} request.pageToken - * DEPRECATED: This field is unused and ignored. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [ListClustersResponse]{@link google.bigtable.admin.v2.ListClustersResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.list_clusters.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_ListClusters_async - */ + /** + * Lists information about clusters in an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the instance for which a list of clusters is requested. + * Values are of the form `projects/{project}/instances/{instance}`. + * Use `{instance} = '-'` to list Clusters for all Instances in a project, + * e.g., `projects/myproject/instances/-`. + * @param {string} request.pageToken + * DEPRECATED: This field is unused and ignored. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [ListClustersResponse]{@link google.bigtable.admin.v2.ListClustersResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.list_clusters.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_ListClusters_async + */ listClusters( - request?: protos.google.bigtable.admin.v2.IListClustersRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IListClustersResponse, - protos.google.bigtable.admin.v2.IListClustersRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IListClustersRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IListClustersResponse, + protos.google.bigtable.admin.v2.IListClustersRequest | undefined, + {} | undefined + ] + >; listClusters( - request: protos.google.bigtable.admin.v2.IListClustersRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.IListClustersResponse, - protos.google.bigtable.admin.v2.IListClustersRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IListClustersRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.IListClustersResponse, + protos.google.bigtable.admin.v2.IListClustersRequest | null | undefined, + {} | null | undefined + > + ): void; listClusters( - request: protos.google.bigtable.admin.v2.IListClustersRequest, - callback: Callback< - protos.google.bigtable.admin.v2.IListClustersResponse, - protos.google.bigtable.admin.v2.IListClustersRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IListClustersRequest, + callback: Callback< + protos.google.bigtable.admin.v2.IListClustersResponse, + protos.google.bigtable.admin.v2.IListClustersRequest | null | undefined, + {} | null | undefined + > + ): void; listClusters( - request?: protos.google.bigtable.admin.v2.IListClustersRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.IListClustersResponse, - protos.google.bigtable.admin.v2.IListClustersRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IListClustersRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.IListClustersResponse, - protos.google.bigtable.admin.v2.IListClustersRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.IListClustersResponse, - protos.google.bigtable.admin.v2.IListClustersRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IListClustersRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.IListClustersResponse, + protos.google.bigtable.admin.v2.IListClustersRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IListClustersResponse, + protos.google.bigtable.admin.v2.IListClustersRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listClusters(request, options, callback); } -/** - * Deletes a cluster from an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the cluster to be deleted. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.delete_cluster.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_DeleteCluster_async - */ + /** + * Deletes a cluster from an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the cluster to be deleted. Values are of the form + * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.delete_cluster.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_DeleteCluster_async + */ deleteCluster( - request?: protos.google.bigtable.admin.v2.IDeleteClusterRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteClusterRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IDeleteClusterRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteClusterRequest | undefined, + {} | undefined + ] + >; deleteCluster( - request: protos.google.bigtable.admin.v2.IDeleteClusterRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteClusterRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteClusterRequest | null | undefined, + {} | null | undefined + > + ): void; deleteCluster( - request: protos.google.bigtable.admin.v2.IDeleteClusterRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteClusterRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteClusterRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteClusterRequest | null | undefined, + {} | null | undefined + > + ): void; deleteCluster( - request?: protos.google.bigtable.admin.v2.IDeleteClusterRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteClusterRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IDeleteClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteClusterRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteClusterRequest|undefined, {}|undefined - ]>|void { - request = request || {}; - let options: CallOptions; - if (typeof optionsOrCallback === 'function' && callback === undefined) { - callback = optionsOrCallback; - options = {}; - } - else { + | protos.google.bigtable.admin.v2.IDeleteClusterRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteClusterRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteClusterRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteCluster(request, options, callback); } -/** - * Creates an app profile within an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the instance in which to create the new app profile. - * Values are of the form - * `projects/{project}/instances/{instance}`. - * @param {string} request.appProfileId - * Required. The ID to be used when referring to the new app profile within its - * instance, e.g., just `myprofile` rather than - * `projects/myproject/instances/myinstance/appProfiles/myprofile`. - * @param {google.bigtable.admin.v2.AppProfile} request.appProfile - * Required. The app profile to be created. - * Fields marked `OutputOnly` will be ignored. - * @param {boolean} request.ignoreWarnings - * If true, ignore safety checks when creating the app profile. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AppProfile]{@link google.bigtable.admin.v2.AppProfile}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.create_app_profile.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateAppProfile_async - */ + /** + * Creates an app profile within an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the instance in which to create the new app profile. + * Values are of the form + * `projects/{project}/instances/{instance}`. + * @param {string} request.appProfileId + * Required. The ID to be used when referring to the new app profile within its + * instance, e.g., just `myprofile` rather than + * `projects/myproject/instances/myinstance/appProfiles/myprofile`. + * @param {google.bigtable.admin.v2.AppProfile} request.appProfile + * Required. The app profile to be created. + * Fields marked `OutputOnly` will be ignored. + * @param {boolean} request.ignoreWarnings + * If true, ignore safety checks when creating the app profile. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AppProfile]{@link google.bigtable.admin.v2.AppProfile}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.create_app_profile.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateAppProfile_async + */ createAppProfile( - request?: protos.google.bigtable.admin.v2.ICreateAppProfileRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.ICreateAppProfileRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.ICreateAppProfileRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.ICreateAppProfileRequest | undefined, + {} | undefined + ] + >; createAppProfile( - request: protos.google.bigtable.admin.v2.ICreateAppProfileRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.ICreateAppProfileRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateAppProfileRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.IAppProfile, + | protos.google.bigtable.admin.v2.ICreateAppProfileRequest + | null + | undefined, + {} | null | undefined + > + ): void; createAppProfile( - request: protos.google.bigtable.admin.v2.ICreateAppProfileRequest, - callback: Callback< - protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.ICreateAppProfileRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateAppProfileRequest, + callback: Callback< + protos.google.bigtable.admin.v2.IAppProfile, + | protos.google.bigtable.admin.v2.ICreateAppProfileRequest + | null + | undefined, + {} | null | undefined + > + ): void; createAppProfile( - request?: protos.google.bigtable.admin.v2.ICreateAppProfileRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.ICreateAppProfileRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.ICreateAppProfileRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.ICreateAppProfileRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.ICreateAppProfileRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.ICreateAppProfileRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.IAppProfile, + | protos.google.bigtable.admin.v2.ICreateAppProfileRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.ICreateAppProfileRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createAppProfile(request, options, callback); } -/** - * Gets information about an app profile. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the requested app profile. Values are of the form - * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [AppProfile]{@link google.bigtable.admin.v2.AppProfile}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.get_app_profile.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_GetAppProfile_async - */ + /** + * Gets information about an app profile. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the requested app profile. Values are of the form + * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [AppProfile]{@link google.bigtable.admin.v2.AppProfile}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.get_app_profile.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_GetAppProfile_async + */ getAppProfile( - request?: protos.google.bigtable.admin.v2.IGetAppProfileRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.IGetAppProfileRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IGetAppProfileRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IGetAppProfileRequest | undefined, + {} | undefined + ] + >; getAppProfile( - request: protos.google.bigtable.admin.v2.IGetAppProfileRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.IGetAppProfileRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetAppProfileRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IGetAppProfileRequest | null | undefined, + {} | null | undefined + > + ): void; getAppProfile( - request: protos.google.bigtable.admin.v2.IGetAppProfileRequest, - callback: Callback< - protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.IGetAppProfileRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetAppProfileRequest, + callback: Callback< + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IGetAppProfileRequest | null | undefined, + {} | null | undefined + > + ): void; getAppProfile( - request?: protos.google.bigtable.admin.v2.IGetAppProfileRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.IGetAppProfileRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IGetAppProfileRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.IGetAppProfileRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.IAppProfile, - protos.google.bigtable.admin.v2.IGetAppProfileRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IGetAppProfileRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IGetAppProfileRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IGetAppProfileRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getAppProfile(request, options, callback); } -/** - * Deletes an app profile from an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the app profile to be deleted. Values are of the form - * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. - * @param {boolean} request.ignoreWarnings - * Required. If true, ignore safety checks when deleting the app profile. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.delete_app_profile.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_DeleteAppProfile_async - */ + /** + * Deletes an app profile from an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the app profile to be deleted. Values are of the form + * `projects/{project}/instances/{instance}/appProfiles/{app_profile}`. + * @param {boolean} request.ignoreWarnings + * Required. If true, ignore safety checks when deleting the app profile. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.delete_app_profile.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_DeleteAppProfile_async + */ deleteAppProfile( - request?: protos.google.bigtable.admin.v2.IDeleteAppProfileRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteAppProfileRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IDeleteAppProfileRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteAppProfileRequest | undefined, + {} | undefined + ] + >; deleteAppProfile( - request: protos.google.bigtable.admin.v2.IDeleteAppProfileRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteAppProfileRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteAppProfileRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.bigtable.admin.v2.IDeleteAppProfileRequest + | null + | undefined, + {} | null | undefined + > + ): void; deleteAppProfile( - request: protos.google.bigtable.admin.v2.IDeleteAppProfileRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteAppProfileRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteAppProfileRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + | protos.google.bigtable.admin.v2.IDeleteAppProfileRequest + | null + | undefined, + {} | null | undefined + > + ): void; deleteAppProfile( - request?: protos.google.bigtable.admin.v2.IDeleteAppProfileRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteAppProfileRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IDeleteAppProfileRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteAppProfileRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteAppProfileRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IDeleteAppProfileRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + | protos.google.bigtable.admin.v2.IDeleteAppProfileRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteAppProfileRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteAppProfile(request, options, callback); } -/** - * Gets the access control policy for an instance resource. Returns an empty - * policy if an instance exists but does not have a policy set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.get_iam_policy.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_GetIamPolicy_async - */ + /** + * Gets the access control policy for an instance resource. Returns an empty + * policy if an instance exists but does not have a policy set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.get_iam_policy.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_GetIamPolicy_async + */ getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined + ] + >; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'resource': request.resource || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + resource: request.resource || '', + }); this.initialize(); return this.innerApiCalls.getIamPolicy(request, options, callback); } -/** - * Sets the access control policy on an instance resource. Replaces any - * existing policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.set_iam_policy.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_SetIamPolicy_async - */ + /** + * Sets the access control policy on an instance resource. Replaces any + * existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.set_iam_policy.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_SetIamPolicy_async + */ setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined + ] + >; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'resource': request.resource || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + resource: request.resource || '', + }); this.initialize(); return this.innerApiCalls.setIamPolicy(request, options, callback); } -/** - * Returns permissions that the caller has on the specified instance resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.test_iam_permissions.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_TestIamPermissions_async - */ + /** + * Returns permissions that the caller has on the specified instance resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.test_iam_permissions.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_TestIamPermissions_async + */ testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined + ] + >; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ): void; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ): void; testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'resource': request.resource || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + resource: request.resource || '', + }); this.initialize(); return this.innerApiCalls.testIamPermissions(request, options, callback); } -/** - * Create an instance within a project. - * - * Note that exactly one of Cluster.serve_nodes and - * Cluster.cluster_config.cluster_autoscaling_config can be set. If - * serve_nodes is set to non-zero, then the cluster is manually scaled. If - * cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is - * enabled. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the project in which to create the new instance. - * Values are of the form `projects/{project}`. - * @param {string} request.instanceId - * Required. The ID to be used when referring to the new instance within its project, - * e.g., just `myinstance` rather than - * `projects/myproject/instances/myinstance`. - * @param {google.bigtable.admin.v2.Instance} request.instance - * Required. The instance to create. - * Fields marked `OutputOnly` must be left blank. - * @param {number[]} request.clusters - * Required. The clusters to be created within the instance, mapped by desired - * cluster ID, e.g., just `mycluster` rather than - * `projects/myproject/instances/myinstance/clusters/mycluster`. - * Fields marked `OutputOnly` must be left blank. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.create_instance.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateInstance_async - */ + /** + * Create an instance within a project. + * + * Note that exactly one of Cluster.serve_nodes and + * Cluster.cluster_config.cluster_autoscaling_config can be set. If + * serve_nodes is set to non-zero, then the cluster is manually scaled. If + * cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is + * enabled. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the project in which to create the new instance. + * Values are of the form `projects/{project}`. + * @param {string} request.instanceId + * Required. The ID to be used when referring to the new instance within its project, + * e.g., just `myinstance` rather than + * `projects/myproject/instances/myinstance`. + * @param {google.bigtable.admin.v2.Instance} request.instance + * Required. The instance to create. + * Fields marked `OutputOnly` must be left blank. + * @param {number[]} request.clusters + * Required. The clusters to be created within the instance, mapped by desired + * cluster ID, e.g., just `mycluster` rather than + * `projects/myproject/instances/myinstance/clusters/mycluster`. + * Fields marked `OutputOnly` must be left blank. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.create_instance.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateInstance_async + */ createInstance( - request?: protos.google.bigtable.admin.v2.ICreateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.ICreateInstanceRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.ICreateInstanceMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; createInstance( - request: protos.google.bigtable.admin.v2.ICreateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.ICreateInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; createInstance( - request: protos.google.bigtable.admin.v2.ICreateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateInstanceRequest, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.ICreateInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; createInstance( - request?: protos.google.bigtable.admin.v2.ICreateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.ICreateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.ICreateInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.ICreateInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.ICreateInstanceMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createInstance(request, options, callback); } -/** - * Check the status of the long running operation returned by `createInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.create_instance.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateInstance_async - */ - async checkCreateInstanceProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `createInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.create_instance.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateInstance_async + */ + async checkCreateInstanceProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.Instance, + protos.google.bigtable.admin.v2.CreateInstanceMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createInstance, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.createInstance, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.Instance, + protos.google.bigtable.admin.v2.CreateInstanceMetadata + >; } -/** - * Partially updates an instance within a project. This method can modify all - * fields of an Instance and is the preferred way to update an Instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.bigtable.admin.v2.Instance} request.instance - * Required. The Instance which will (partially) replace the current value. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. The subset of Instance fields which should be replaced. - * Must be explicitly set. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.partial_update_instance.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_PartialUpdateInstance_async - */ + /** + * Partially updates an instance within a project. This method can modify all + * fields of an Instance and is the preferred way to update an Instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.bigtable.admin.v2.Instance} request.instance + * Required. The Instance which will (partially) replace the current value. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The subset of Instance fields which should be replaced. + * Must be explicitly set. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.partial_update_instance.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_PartialUpdateInstance_async + */ partialUpdateInstance( - request?: protos.google.bigtable.admin.v2.IPartialUpdateInstanceRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IPartialUpdateInstanceRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IUpdateInstanceMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; partialUpdateInstance( - request: protos.google.bigtable.admin.v2.IPartialUpdateInstanceRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IPartialUpdateInstanceRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IUpdateInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; partialUpdateInstance( - request: protos.google.bigtable.admin.v2.IPartialUpdateInstanceRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IPartialUpdateInstanceRequest, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IUpdateInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; partialUpdateInstance( - request?: protos.google.bigtable.admin.v2.IPartialUpdateInstanceRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.IPartialUpdateInstanceRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IUpdateInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IUpdateInstanceMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IUpdateInstanceMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'instance.name': request.instance!.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + 'instance.name': request.instance!.name || '', + }); this.initialize(); return this.innerApiCalls.partialUpdateInstance(request, options, callback); } -/** - * Check the status of the long running operation returned by `partialUpdateInstance()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.partial_update_instance.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_PartialUpdateInstance_async - */ - async checkPartialUpdateInstanceProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `partialUpdateInstance()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.partial_update_instance.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_PartialUpdateInstance_async + */ + async checkPartialUpdateInstanceProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.Instance, + protos.google.bigtable.admin.v2.UpdateInstanceMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.partialUpdateInstance, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.partialUpdateInstance, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.Instance, + protos.google.bigtable.admin.v2.UpdateInstanceMetadata + >; } -/** - * Creates a cluster within an instance. - * - * Note that exactly one of Cluster.serve_nodes and - * Cluster.cluster_config.cluster_autoscaling_config can be set. If - * serve_nodes is set to non-zero, then the cluster is manually scaled. If - * cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is - * enabled. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the instance in which to create the new cluster. - * Values are of the form - * `projects/{project}/instances/{instance}`. - * @param {string} request.clusterId - * Required. The ID to be used when referring to the new cluster within its instance, - * e.g., just `mycluster` rather than - * `projects/myproject/instances/myinstance/clusters/mycluster`. - * @param {google.bigtable.admin.v2.Cluster} request.cluster - * Required. The cluster to be created. - * Fields marked `OutputOnly` must be left blank. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.create_cluster.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateCluster_async - */ + /** + * Creates a cluster within an instance. + * + * Note that exactly one of Cluster.serve_nodes and + * Cluster.cluster_config.cluster_autoscaling_config can be set. If + * serve_nodes is set to non-zero, then the cluster is manually scaled. If + * cluster_config.cluster_autoscaling_config is non-empty, then autoscaling is + * enabled. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the instance in which to create the new cluster. + * Values are of the form + * `projects/{project}/instances/{instance}`. + * @param {string} request.clusterId + * Required. The ID to be used when referring to the new cluster within its instance, + * e.g., just `mycluster` rather than + * `projects/myproject/instances/myinstance/clusters/mycluster`. + * @param {google.bigtable.admin.v2.Cluster} request.cluster + * Required. The cluster to be created. + * Fields marked `OutputOnly` must be left blank. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.create_cluster.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateCluster_async + */ createCluster( - request?: protos.google.bigtable.admin.v2.ICreateClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.ICreateClusterRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.ICreateClusterMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; createCluster( - request: protos.google.bigtable.admin.v2.ICreateClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.ICreateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; createCluster( - request: protos.google.bigtable.admin.v2.ICreateClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateClusterRequest, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.ICreateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; createCluster( - request?: protos.google.bigtable.admin.v2.ICreateClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.ICreateClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.ICreateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.ICreateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.ICreateClusterMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createCluster(request, options, callback); } -/** - * Check the status of the long running operation returned by `createCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.create_cluster.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateCluster_async - */ - async checkCreateClusterProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `createCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.create_cluster.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_CreateCluster_async + */ + async checkCreateClusterProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.Cluster, + protos.google.bigtable.admin.v2.CreateClusterMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createCluster, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.createCluster, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.Cluster, + protos.google.bigtable.admin.v2.CreateClusterMetadata + >; } -/** - * Updates a cluster within an instance. - * - * Note that UpdateCluster does not support updating - * cluster_config.cluster_autoscaling_config. In order to update it, you - * must use PartialUpdateCluster. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * The unique name of the cluster. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{@link -a-z0-9|a-z}*`. - * @param {string} request.location - * Immutable. The location where this cluster's nodes and storage reside. For - * best performance, clients should be located as close as possible to this - * cluster. Currently only zones are supported, so values should be of the - * form `projects/{project}/locations/{zone}`. - * @param {google.bigtable.admin.v2.Cluster.State} request.state - * Output only. The current state of the cluster. - * @param {number} request.serveNodes - * The number of nodes allocated to this cluster. More nodes enable higher - * throughput and more consistent performance. - * @param {google.bigtable.admin.v2.Cluster.ClusterConfig} request.clusterConfig - * Configuration for this cluster. - * @param {google.bigtable.admin.v2.StorageType} request.defaultStorageType - * Immutable. The type of storage used by this cluster to serve its - * parent instance's tables, unless explicitly overridden. - * @param {google.bigtable.admin.v2.Cluster.EncryptionConfig} request.encryptionConfig - * Immutable. The encryption configuration for CMEK-protected clusters. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.update_cluster.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateCluster_async - */ + /** + * Updates a cluster within an instance. + * + * Note that UpdateCluster does not support updating + * cluster_config.cluster_autoscaling_config. In order to update it, you + * must use PartialUpdateCluster. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * The unique name of the cluster. Values are of the form + * `projects/{project}/instances/{instance}/clusters/{@link -a-z0-9|a-z}*`. + * @param {string} request.location + * Immutable. The location where this cluster's nodes and storage reside. For + * best performance, clients should be located as close as possible to this + * cluster. Currently only zones are supported, so values should be of the + * form `projects/{project}/locations/{zone}`. + * @param {google.bigtable.admin.v2.Cluster.State} request.state + * Output only. The current state of the cluster. + * @param {number} request.serveNodes + * The number of nodes allocated to this cluster. More nodes enable higher + * throughput and more consistent performance. + * @param {google.bigtable.admin.v2.Cluster.ClusterConfig} request.clusterConfig + * Configuration for this cluster. + * @param {google.bigtable.admin.v2.StorageType} request.defaultStorageType + * Immutable. The type of storage used by this cluster to serve its + * parent instance's tables, unless explicitly overridden. + * @param {google.bigtable.admin.v2.Cluster.EncryptionConfig} request.encryptionConfig + * Immutable. The encryption configuration for CMEK-protected clusters. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.update_cluster.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateCluster_async + */ updateCluster( - request?: protos.google.bigtable.admin.v2.ICluster, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.ICluster, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; updateCluster( - request: protos.google.bigtable.admin.v2.ICluster, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICluster, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; updateCluster( - request: protos.google.bigtable.admin.v2.ICluster, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICluster, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; updateCluster( - request?: protos.google.bigtable.admin.v2.ICluster, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.ICluster, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.updateCluster(request, options, callback); } -/** - * Check the status of the long running operation returned by `updateCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.update_cluster.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateCluster_async - */ - async checkUpdateClusterProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `updateCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.update_cluster.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateCluster_async + */ + async checkUpdateClusterProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.Cluster, + protos.google.bigtable.admin.v2.UpdateClusterMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateCluster, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.updateCluster, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.Cluster, + protos.google.bigtable.admin.v2.UpdateClusterMetadata + >; } -/** - * Partially updates a cluster within a project. This method is the preferred - * way to update a Cluster. - * - * To enable and update autoscaling, set - * cluster_config.cluster_autoscaling_config. When autoscaling is enabled, - * serve_nodes is treated as an OUTPUT_ONLY field, meaning that updates to it - * are ignored. Note that an update cannot simultaneously set serve_nodes to - * non-zero and cluster_config.cluster_autoscaling_config to non-empty, and - * also specify both in the update_mask. - * - * To disable autoscaling, clear cluster_config.cluster_autoscaling_config, - * and explicitly set a serve_node count via the update_mask. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.bigtable.admin.v2.Cluster} request.cluster - * Required. The Cluster which contains the partial updates to be applied, subject to - * the update_mask. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. The subset of Cluster fields which should be replaced. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.partial_update_cluster.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_PartialUpdateCluster_async - */ + /** + * Partially updates a cluster within a project. This method is the preferred + * way to update a Cluster. + * + * To enable and update autoscaling, set + * cluster_config.cluster_autoscaling_config. When autoscaling is enabled, + * serve_nodes is treated as an OUTPUT_ONLY field, meaning that updates to it + * are ignored. Note that an update cannot simultaneously set serve_nodes to + * non-zero and cluster_config.cluster_autoscaling_config to non-empty, and + * also specify both in the update_mask. + * + * To disable autoscaling, clear cluster_config.cluster_autoscaling_config, + * and explicitly set a serve_node count via the update_mask. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.bigtable.admin.v2.Cluster} request.cluster + * Required. The Cluster which contains the partial updates to be applied, subject to + * the update_mask. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The subset of Cluster fields which should be replaced. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.partial_update_cluster.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_PartialUpdateCluster_async + */ partialUpdateCluster( - request?: protos.google.bigtable.admin.v2.IPartialUpdateClusterRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IPartialUpdateClusterRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IPartialUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; partialUpdateCluster( - request: protos.google.bigtable.admin.v2.IPartialUpdateClusterRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IPartialUpdateClusterRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IPartialUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; partialUpdateCluster( - request: protos.google.bigtable.admin.v2.IPartialUpdateClusterRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IPartialUpdateClusterRequest, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IPartialUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; partialUpdateCluster( - request?: protos.google.bigtable.admin.v2.IPartialUpdateClusterRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.IPartialUpdateClusterRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IPartialUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IPartialUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IPartialUpdateClusterMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'cluster.name': request.cluster!.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + 'cluster.name': request.cluster!.name || '', + }); this.initialize(); return this.innerApiCalls.partialUpdateCluster(request, options, callback); } -/** - * Check the status of the long running operation returned by `partialUpdateCluster()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.partial_update_cluster.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_PartialUpdateCluster_async - */ - async checkPartialUpdateClusterProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `partialUpdateCluster()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.partial_update_cluster.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_PartialUpdateCluster_async + */ + async checkPartialUpdateClusterProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.Cluster, + protos.google.bigtable.admin.v2.PartialUpdateClusterMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.partialUpdateCluster, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.partialUpdateCluster, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.Cluster, + protos.google.bigtable.admin.v2.PartialUpdateClusterMetadata + >; } -/** - * Updates an app profile within an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.bigtable.admin.v2.AppProfile} request.appProfile - * Required. The app profile which will (partially) replace the current value. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. The subset of app profile fields which should be replaced. - * If unset, all fields will be replaced. - * @param {boolean} request.ignoreWarnings - * If true, ignore safety checks when updating the app profile. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.update_app_profile.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateAppProfile_async - */ + /** + * Updates an app profile within an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.bigtable.admin.v2.AppProfile} request.appProfile + * Required. The app profile which will (partially) replace the current value. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. The subset of app profile fields which should be replaced. + * If unset, all fields will be replaced. + * @param {boolean} request.ignoreWarnings + * If true, ignore safety checks when updating the app profile. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.update_app_profile.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateAppProfile_async + */ updateAppProfile( - request?: protos.google.bigtable.admin.v2.IUpdateAppProfileRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IUpdateAppProfileRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IUpdateAppProfileMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; updateAppProfile( - request: protos.google.bigtable.admin.v2.IUpdateAppProfileRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IUpdateAppProfileRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IUpdateAppProfileMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; updateAppProfile( - request: protos.google.bigtable.admin.v2.IUpdateAppProfileRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IUpdateAppProfileRequest, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IUpdateAppProfileMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; updateAppProfile( - request?: protos.google.bigtable.admin.v2.IUpdateAppProfileRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.IUpdateAppProfileRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IUpdateAppProfileMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IUpdateAppProfileMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IUpdateAppProfileMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'app_profile.name': request.appProfile!.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + 'app_profile.name': request.appProfile!.name || '', + }); this.initialize(); return this.innerApiCalls.updateAppProfile(request, options, callback); } -/** - * Check the status of the long running operation returned by `updateAppProfile()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.update_app_profile.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateAppProfile_async - */ - async checkUpdateAppProfileProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `updateAppProfile()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.update_app_profile.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_UpdateAppProfile_async + */ + async checkUpdateAppProfileProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.AppProfile, + protos.google.bigtable.admin.v2.UpdateAppProfileMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateAppProfile, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; - } - /** - * Lists information about app profiles in an instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the instance for which a list of app profiles is - * requested. Values are of the form - * `projects/{project}/instances/{instance}`. - * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, - * e.g., `projects/myproject/instances/-`. - * @param {number} request.pageSize - * Maximum number of results per page. - * - * A page_size of zero lets the server choose the number of items to return. - * A page_size which is strictly positive will return at most that many items. - * A negative page_size will cause an error. - * - * Following the first request, subsequent paginated calls are not required - * to pass a page_size. If a page_size is set in subsequent calls, it must - * match the page_size given in the first request. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a previous call. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [AppProfile]{@link google.bigtable.admin.v2.AppProfile}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listAppProfilesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.updateAppProfile, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.AppProfile, + protos.google.bigtable.admin.v2.UpdateAppProfileMetadata + >; + } + /** + * Lists information about app profiles in an instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the instance for which a list of app profiles is + * requested. Values are of the form + * `projects/{project}/instances/{instance}`. + * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, + * e.g., `projects/myproject/instances/-`. + * @param {number} request.pageSize + * Maximum number of results per page. + * + * A page_size of zero lets the server choose the number of items to return. + * A page_size which is strictly positive will return at most that many items. + * A negative page_size will cause an error. + * + * Following the first request, subsequent paginated calls are not required + * to pass a page_size. If a page_size is set in subsequent calls, it must + * match the page_size given in the first request. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [AppProfile]{@link google.bigtable.admin.v2.AppProfile}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listAppProfilesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ listAppProfiles( - request?: protos.google.bigtable.admin.v2.IListAppProfilesRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IAppProfile[], - protos.google.bigtable.admin.v2.IListAppProfilesRequest|null, - protos.google.bigtable.admin.v2.IListAppProfilesResponse - ]>; + request?: protos.google.bigtable.admin.v2.IListAppProfilesRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IAppProfile[], + protos.google.bigtable.admin.v2.IListAppProfilesRequest | null, + protos.google.bigtable.admin.v2.IListAppProfilesResponse + ] + >; listAppProfiles( - request: protos.google.bigtable.admin.v2.IListAppProfilesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.bigtable.admin.v2.IListAppProfilesRequest, - protos.google.bigtable.admin.v2.IListAppProfilesResponse|null|undefined, - protos.google.bigtable.admin.v2.IAppProfile>): void; + request: protos.google.bigtable.admin.v2.IListAppProfilesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.bigtable.admin.v2.IListAppProfilesRequest, + | protos.google.bigtable.admin.v2.IListAppProfilesResponse + | null + | undefined, + protos.google.bigtable.admin.v2.IAppProfile + > + ): void; listAppProfiles( - request: protos.google.bigtable.admin.v2.IListAppProfilesRequest, - callback: PaginationCallback< - protos.google.bigtable.admin.v2.IListAppProfilesRequest, - protos.google.bigtable.admin.v2.IListAppProfilesResponse|null|undefined, - protos.google.bigtable.admin.v2.IAppProfile>): void; + request: protos.google.bigtable.admin.v2.IListAppProfilesRequest, + callback: PaginationCallback< + protos.google.bigtable.admin.v2.IListAppProfilesRequest, + | protos.google.bigtable.admin.v2.IListAppProfilesResponse + | null + | undefined, + protos.google.bigtable.admin.v2.IAppProfile + > + ): void; listAppProfiles( - request?: protos.google.bigtable.admin.v2.IListAppProfilesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.bigtable.admin.v2.IListAppProfilesRequest, - protos.google.bigtable.admin.v2.IListAppProfilesResponse|null|undefined, - protos.google.bigtable.admin.v2.IAppProfile>, - callback?: PaginationCallback< + request?: protos.google.bigtable.admin.v2.IListAppProfilesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.bigtable.admin.v2.IListAppProfilesRequest, - protos.google.bigtable.admin.v2.IListAppProfilesResponse|null|undefined, - protos.google.bigtable.admin.v2.IAppProfile>): - Promise<[ - protos.google.bigtable.admin.v2.IAppProfile[], - protos.google.bigtable.admin.v2.IListAppProfilesRequest|null, - protos.google.bigtable.admin.v2.IListAppProfilesResponse - ]>|void { + | protos.google.bigtable.admin.v2.IListAppProfilesResponse + | null + | undefined, + protos.google.bigtable.admin.v2.IAppProfile + >, + callback?: PaginationCallback< + protos.google.bigtable.admin.v2.IListAppProfilesRequest, + | protos.google.bigtable.admin.v2.IListAppProfilesResponse + | null + | undefined, + protos.google.bigtable.admin.v2.IAppProfile + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IAppProfile[], + protos.google.bigtable.admin.v2.IListAppProfilesRequest | null, + protos.google.bigtable.admin.v2.IListAppProfilesResponse + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listAppProfiles(request, options, callback); } -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the instance for which a list of app profiles is - * requested. Values are of the form - * `projects/{project}/instances/{instance}`. - * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, - * e.g., `projects/myproject/instances/-`. - * @param {number} request.pageSize - * Maximum number of results per page. - * - * A page_size of zero lets the server choose the number of items to return. - * A page_size which is strictly positive will return at most that many items. - * A negative page_size will cause an error. - * - * Following the first request, subsequent paginated calls are not required - * to pass a page_size. If a page_size is set in subsequent calls, it must - * match the page_size given in the first request. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a previous call. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [AppProfile]{@link google.bigtable.admin.v2.AppProfile} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listAppProfilesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the instance for which a list of app profiles is + * requested. Values are of the form + * `projects/{project}/instances/{instance}`. + * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, + * e.g., `projects/myproject/instances/-`. + * @param {number} request.pageSize + * Maximum number of results per page. + * + * A page_size of zero lets the server choose the number of items to return. + * A page_size which is strictly positive will return at most that many items. + * A negative page_size will cause an error. + * + * Following the first request, subsequent paginated calls are not required + * to pass a page_size. If a page_size is set in subsequent calls, it must + * match the page_size given in the first request. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [AppProfile]{@link google.bigtable.admin.v2.AppProfile} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listAppProfilesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ listAppProfilesStream( - request?: protos.google.bigtable.admin.v2.IListAppProfilesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.bigtable.admin.v2.IListAppProfilesRequest, + options?: CallOptions + ): Transform { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const defaultCallSettings = this._defaults['listAppProfiles']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -2167,56 +2741,55 @@ export class BigtableInstanceAdminClient { ); } -/** - * Equivalent to `listAppProfiles`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the instance for which a list of app profiles is - * requested. Values are of the form - * `projects/{project}/instances/{instance}`. - * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, - * e.g., `projects/myproject/instances/-`. - * @param {number} request.pageSize - * Maximum number of results per page. - * - * A page_size of zero lets the server choose the number of items to return. - * A page_size which is strictly positive will return at most that many items. - * A negative page_size will cause an error. - * - * Following the first request, subsequent paginated calls are not required - * to pass a page_size. If a page_size is set in subsequent calls, it must - * match the page_size given in the first request. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [AppProfile]{@link google.bigtable.admin.v2.AppProfile}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.list_app_profiles.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_ListAppProfiles_async - */ + /** + * Equivalent to `listAppProfiles`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the instance for which a list of app profiles is + * requested. Values are of the form + * `projects/{project}/instances/{instance}`. + * Use `{instance} = '-'` to list AppProfiles for all Instances in a project, + * e.g., `projects/myproject/instances/-`. + * @param {number} request.pageSize + * Maximum number of results per page. + * + * A page_size of zero lets the server choose the number of items to return. + * A page_size which is strictly positive will return at most that many items. + * A negative page_size will cause an error. + * + * Following the first request, subsequent paginated calls are not required + * to pass a page_size. If a page_size is set in subsequent calls, it must + * match the page_size given in the first request. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [AppProfile]{@link google.bigtable.admin.v2.AppProfile}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.list_app_profiles.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_ListAppProfiles_async + */ listAppProfilesAsync( - request?: protos.google.bigtable.admin.v2.IListAppProfilesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.bigtable.admin.v2.IListAppProfilesRequest, + options?: 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const defaultCallSettings = this._defaults['listAppProfiles']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -2226,161 +2799,178 @@ export class BigtableInstanceAdminClient { callSettings ) as AsyncIterable; } - /** - * Lists hot tablets in a cluster, within the time range provided. Hot - * tablets are ordered based on CPU usage. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The cluster name to list hot tablets. - * Value is in the following form: - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param {google.protobuf.Timestamp} request.startTime - * The start time to list hot tablets. The hot tablets in the response will - * have start times between the requested start time and end time. Start time - * defaults to Now if it is unset, and end time defaults to Now - 24 hours if - * it is unset. The start time should be less than the end time, and the - * maximum allowed time range between start time and end time is 48 hours. - * Start time and end time should have values between Now and Now - 14 days. - * @param {google.protobuf.Timestamp} request.endTime - * The end time to list hot tablets. - * @param {number} request.pageSize - * Maximum number of results per page. - * - * A page_size that is empty or zero lets the server choose the number of - * items to return. A page_size which is strictly positive will return at most - * that many items. A negative page_size will cause an error. - * - * Following the first request, subsequent paginated calls do not need a - * page_size field. If a page_size is set in subsequent calls, it must match - * the page_size given in the first request. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a previous call. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [HotTablet]{@link google.bigtable.admin.v2.HotTablet}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listHotTabletsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ + /** + * Lists hot tablets in a cluster, within the time range provided. Hot + * tablets are ordered based on CPU usage. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The cluster name to list hot tablets. + * Value is in the following form: + * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * @param {google.protobuf.Timestamp} request.startTime + * The start time to list hot tablets. The hot tablets in the response will + * have start times between the requested start time and end time. Start time + * defaults to Now if it is unset, and end time defaults to Now - 24 hours if + * it is unset. The start time should be less than the end time, and the + * maximum allowed time range between start time and end time is 48 hours. + * Start time and end time should have values between Now and Now - 14 days. + * @param {google.protobuf.Timestamp} request.endTime + * The end time to list hot tablets. + * @param {number} request.pageSize + * Maximum number of results per page. + * + * A page_size that is empty or zero lets the server choose the number of + * items to return. A page_size which is strictly positive will return at most + * that many items. A negative page_size will cause an error. + * + * Following the first request, subsequent paginated calls do not need a + * page_size field. If a page_size is set in subsequent calls, it must match + * the page_size given in the first request. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [HotTablet]{@link google.bigtable.admin.v2.HotTablet}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listHotTabletsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ listHotTablets( - request?: protos.google.bigtable.admin.v2.IListHotTabletsRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IHotTablet[], - protos.google.bigtable.admin.v2.IListHotTabletsRequest|null, - protos.google.bigtable.admin.v2.IListHotTabletsResponse - ]>; + request?: protos.google.bigtable.admin.v2.IListHotTabletsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IHotTablet[], + protos.google.bigtable.admin.v2.IListHotTabletsRequest | null, + protos.google.bigtable.admin.v2.IListHotTabletsResponse + ] + >; listHotTablets( - request: protos.google.bigtable.admin.v2.IListHotTabletsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.bigtable.admin.v2.IListHotTabletsRequest, - protos.google.bigtable.admin.v2.IListHotTabletsResponse|null|undefined, - protos.google.bigtable.admin.v2.IHotTablet>): void; + request: protos.google.bigtable.admin.v2.IListHotTabletsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.bigtable.admin.v2.IListHotTabletsRequest, + | protos.google.bigtable.admin.v2.IListHotTabletsResponse + | null + | undefined, + protos.google.bigtable.admin.v2.IHotTablet + > + ): void; listHotTablets( - request: protos.google.bigtable.admin.v2.IListHotTabletsRequest, - callback: PaginationCallback< - protos.google.bigtable.admin.v2.IListHotTabletsRequest, - protos.google.bigtable.admin.v2.IListHotTabletsResponse|null|undefined, - protos.google.bigtable.admin.v2.IHotTablet>): void; + request: protos.google.bigtable.admin.v2.IListHotTabletsRequest, + callback: PaginationCallback< + protos.google.bigtable.admin.v2.IListHotTabletsRequest, + | protos.google.bigtable.admin.v2.IListHotTabletsResponse + | null + | undefined, + protos.google.bigtable.admin.v2.IHotTablet + > + ): void; listHotTablets( - request?: protos.google.bigtable.admin.v2.IListHotTabletsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.bigtable.admin.v2.IListHotTabletsRequest, - protos.google.bigtable.admin.v2.IListHotTabletsResponse|null|undefined, - protos.google.bigtable.admin.v2.IHotTablet>, - callback?: PaginationCallback< + request?: protos.google.bigtable.admin.v2.IListHotTabletsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.bigtable.admin.v2.IListHotTabletsRequest, - protos.google.bigtable.admin.v2.IListHotTabletsResponse|null|undefined, - protos.google.bigtable.admin.v2.IHotTablet>): - Promise<[ - protos.google.bigtable.admin.v2.IHotTablet[], - protos.google.bigtable.admin.v2.IListHotTabletsRequest|null, - protos.google.bigtable.admin.v2.IListHotTabletsResponse - ]>|void { + | protos.google.bigtable.admin.v2.IListHotTabletsResponse + | null + | undefined, + protos.google.bigtable.admin.v2.IHotTablet + >, + callback?: PaginationCallback< + protos.google.bigtable.admin.v2.IListHotTabletsRequest, + | protos.google.bigtable.admin.v2.IListHotTabletsResponse + | null + | undefined, + protos.google.bigtable.admin.v2.IHotTablet + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IHotTablet[], + protos.google.bigtable.admin.v2.IListHotTabletsRequest | null, + protos.google.bigtable.admin.v2.IListHotTabletsResponse + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listHotTablets(request, options, callback); } -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The cluster name to list hot tablets. - * Value is in the following form: - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param {google.protobuf.Timestamp} request.startTime - * The start time to list hot tablets. The hot tablets in the response will - * have start times between the requested start time and end time. Start time - * defaults to Now if it is unset, and end time defaults to Now - 24 hours if - * it is unset. The start time should be less than the end time, and the - * maximum allowed time range between start time and end time is 48 hours. - * Start time and end time should have values between Now and Now - 14 days. - * @param {google.protobuf.Timestamp} request.endTime - * The end time to list hot tablets. - * @param {number} request.pageSize - * Maximum number of results per page. - * - * A page_size that is empty or zero lets the server choose the number of - * items to return. A page_size which is strictly positive will return at most - * that many items. A negative page_size will cause an error. - * - * Following the first request, subsequent paginated calls do not need a - * page_size field. If a page_size is set in subsequent calls, it must match - * the page_size given in the first request. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a previous call. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [HotTablet]{@link google.bigtable.admin.v2.HotTablet} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listHotTabletsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The cluster name to list hot tablets. + * Value is in the following form: + * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * @param {google.protobuf.Timestamp} request.startTime + * The start time to list hot tablets. The hot tablets in the response will + * have start times between the requested start time and end time. Start time + * defaults to Now if it is unset, and end time defaults to Now - 24 hours if + * it is unset. The start time should be less than the end time, and the + * maximum allowed time range between start time and end time is 48 hours. + * Start time and end time should have values between Now and Now - 14 days. + * @param {google.protobuf.Timestamp} request.endTime + * The end time to list hot tablets. + * @param {number} request.pageSize + * Maximum number of results per page. + * + * A page_size that is empty or zero lets the server choose the number of + * items to return. A page_size which is strictly positive will return at most + * that many items. A negative page_size will cause an error. + * + * Following the first request, subsequent paginated calls do not need a + * page_size field. If a page_size is set in subsequent calls, it must match + * the page_size given in the first request. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [HotTablet]{@link google.bigtable.admin.v2.HotTablet} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listHotTabletsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ listHotTabletsStream( - request?: protos.google.bigtable.admin.v2.IListHotTabletsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.bigtable.admin.v2.IListHotTabletsRequest, + options?: CallOptions + ): Transform { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const defaultCallSettings = this._defaults['listHotTablets']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -2391,63 +2981,62 @@ export class BigtableInstanceAdminClient { ); } -/** - * Equivalent to `listHotTablets`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The cluster name to list hot tablets. - * Value is in the following form: - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param {google.protobuf.Timestamp} request.startTime - * The start time to list hot tablets. The hot tablets in the response will - * have start times between the requested start time and end time. Start time - * defaults to Now if it is unset, and end time defaults to Now - 24 hours if - * it is unset. The start time should be less than the end time, and the - * maximum allowed time range between start time and end time is 48 hours. - * Start time and end time should have values between Now and Now - 14 days. - * @param {google.protobuf.Timestamp} request.endTime - * The end time to list hot tablets. - * @param {number} request.pageSize - * Maximum number of results per page. - * - * A page_size that is empty or zero lets the server choose the number of - * items to return. A page_size which is strictly positive will return at most - * that many items. A negative page_size will cause an error. - * - * Following the first request, subsequent paginated calls do not need a - * page_size field. If a page_size is set in subsequent calls, it must match - * the page_size given in the first request. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [HotTablet]{@link google.bigtable.admin.v2.HotTablet}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_instance_admin.list_hot_tablets.js - * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_ListHotTablets_async - */ + /** + * Equivalent to `listHotTablets`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The cluster name to list hot tablets. + * Value is in the following form: + * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * @param {google.protobuf.Timestamp} request.startTime + * The start time to list hot tablets. The hot tablets in the response will + * have start times between the requested start time and end time. Start time + * defaults to Now if it is unset, and end time defaults to Now - 24 hours if + * it is unset. The start time should be less than the end time, and the + * maximum allowed time range between start time and end time is 48 hours. + * Start time and end time should have values between Now and Now - 14 days. + * @param {google.protobuf.Timestamp} request.endTime + * The end time to list hot tablets. + * @param {number} request.pageSize + * Maximum number of results per page. + * + * A page_size that is empty or zero lets the server choose the number of + * items to return. A page_size which is strictly positive will return at most + * that many items. A negative page_size will cause an error. + * + * Following the first request, subsequent paginated calls do not need a + * page_size field. If a page_size is set in subsequent calls, it must match + * the page_size given in the first request. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [HotTablet]{@link google.bigtable.admin.v2.HotTablet}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_instance_admin.list_hot_tablets.js + * region_tag:bigtableadmin_v2_generated_BigtableInstanceAdmin_ListHotTablets_async + */ listHotTabletsAsync( - request?: protos.google.bigtable.admin.v2.IListHotTabletsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.bigtable.admin.v2.IListHotTabletsRequest, + options?: 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const defaultCallSettings = this._defaults['listHotTablets']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -2457,7 +3046,7 @@ export class BigtableInstanceAdminClient { callSettings ) as AsyncIterable; } -/** + /** * Gets information about a location. * * @param {Object} request @@ -2498,7 +3087,7 @@ export class BigtableInstanceAdminClient { return this.locationsClient.getLocation(request, options, callback); } -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -2537,7 +3126,7 @@ export class BigtableInstanceAdminClient { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -2653,7 +3242,7 @@ export class BigtableInstanceAdminClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, options?: | gax.CallOptions @@ -2726,7 +3315,7 @@ export class BigtableInstanceAdminClient { * @param {string} app_profile * @returns {string} Resource name string. */ - appProfilePath(project:string,instance:string,appProfile:string) { + appProfilePath(project: string, instance: string, appProfile: string) { return this.pathTemplates.appProfilePathTemplate.render({ project: project, instance: instance, @@ -2742,7 +3331,8 @@ export class BigtableInstanceAdminClient { * @returns {string} A string representing the project. */ matchProjectFromAppProfileName(appProfileName: string) { - return this.pathTemplates.appProfilePathTemplate.match(appProfileName).project; + return this.pathTemplates.appProfilePathTemplate.match(appProfileName) + .project; } /** @@ -2753,7 +3343,8 @@ export class BigtableInstanceAdminClient { * @returns {string} A string representing the instance. */ matchInstanceFromAppProfileName(appProfileName: string) { - return this.pathTemplates.appProfilePathTemplate.match(appProfileName).instance; + return this.pathTemplates.appProfilePathTemplate.match(appProfileName) + .instance; } /** @@ -2764,7 +3355,8 @@ export class BigtableInstanceAdminClient { * @returns {string} A string representing the app_profile. */ matchAppProfileFromAppProfileName(appProfileName: string) { - return this.pathTemplates.appProfilePathTemplate.match(appProfileName).app_profile; + return this.pathTemplates.appProfilePathTemplate.match(appProfileName) + .app_profile; } /** @@ -2776,7 +3368,12 @@ export class BigtableInstanceAdminClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,instance:string,cluster:string,backup:string) { + backupPath( + project: string, + instance: string, + cluster: string, + backup: string + ) { return this.pathTemplates.backupPathTemplate.render({ project: project, instance: instance, @@ -2837,7 +3434,7 @@ export class BigtableInstanceAdminClient { * @param {string} cluster * @returns {string} Resource name string. */ - clusterPath(project:string,instance:string,cluster:string) { + clusterPath(project: string, instance: string, cluster: string) { return this.pathTemplates.clusterPathTemplate.render({ project: project, instance: instance, @@ -2887,7 +3484,12 @@ export class BigtableInstanceAdminClient { * @param {string} hot_tablet * @returns {string} Resource name string. */ - hotTabletPath(project:string,instance:string,cluster:string,hotTablet:string) { + hotTabletPath( + project: string, + instance: string, + cluster: string, + hotTablet: string + ) { return this.pathTemplates.hotTabletPathTemplate.render({ project: project, instance: instance, @@ -2904,7 +3506,8 @@ export class BigtableInstanceAdminClient { * @returns {string} A string representing the project. */ matchProjectFromHotTabletName(hotTabletName: string) { - return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName).project; + return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName) + .project; } /** @@ -2915,7 +3518,8 @@ export class BigtableInstanceAdminClient { * @returns {string} A string representing the instance. */ matchInstanceFromHotTabletName(hotTabletName: string) { - return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName).instance; + return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName) + .instance; } /** @@ -2926,7 +3530,8 @@ export class BigtableInstanceAdminClient { * @returns {string} A string representing the cluster. */ matchClusterFromHotTabletName(hotTabletName: string) { - return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName).cluster; + return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName) + .cluster; } /** @@ -2937,7 +3542,8 @@ export class BigtableInstanceAdminClient { * @returns {string} A string representing the hot_tablet. */ matchHotTabletFromHotTabletName(hotTabletName: string) { - return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName).hot_tablet; + return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName) + .hot_tablet; } /** @@ -2947,7 +3553,7 @@ export class BigtableInstanceAdminClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,instance:string) { + instancePath(project: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, instance: instance, @@ -2982,7 +3588,7 @@ export class BigtableInstanceAdminClient { * @param {string} project * @returns {string} Resource name string. */ - projectPath(project:string) { + projectPath(project: string) { return this.pathTemplates.projectPathTemplate.render({ project: project, }); @@ -3008,7 +3614,12 @@ export class BigtableInstanceAdminClient { * @param {string} snapshot * @returns {string} Resource name string. */ - snapshotPath(project:string,instance:string,cluster:string,snapshot:string) { + snapshotPath( + project: string, + instance: string, + cluster: string, + snapshot: string + ) { return this.pathTemplates.snapshotPathTemplate.render({ project: project, instance: instance, @@ -3069,7 +3680,7 @@ export class BigtableInstanceAdminClient { * @param {string} table * @returns {string} Resource name string. */ - tablePath(project:string,instance:string,table:string) { + tablePath(project: string, instance: string, table: string) { return this.pathTemplates.tablePathTemplate.render({ project: project, instance: instance, diff --git a/src/v2/bigtable_table_admin_client.ts b/src/v2/bigtable_table_admin_client.ts index 8b1b843dd..04be949fc 100644 --- a/src/v2/bigtable_table_admin_client.ts +++ b/src/v2/bigtable_table_admin_client.ts @@ -18,10 +18,21 @@ /* global window */ import * as gax from 'google-gax'; -import {Callback, CallOptions, Descriptors, ClientOptions, GrpcClientOptions, LROperation, PaginationCallback, GaxCall, LocationsClient, LocationProtos} from 'google-gax'; +import { + Callback, + CallOptions, + Descriptors, + ClientOptions, + GrpcClientOptions, + LROperation, + PaginationCallback, + GaxCall, + LocationsClient, + LocationProtos, +} from 'google-gax'; -import { Transform } from 'stream'; -import { RequestType } from 'google-gax/build/src/apitypes'; +import {Transform} from 'stream'; +import {RequestType} from 'google-gax/build/src/apitypes'; import * as protos from '../../protos/protos'; import jsonProtos = require('../../protos/protos.json'); /** @@ -30,7 +41,7 @@ import jsonProtos = require('../../protos/protos.json'); * This file defines retry strategy and timeouts for all API methods in this library. */ import * as gapicConfig from './bigtable_table_admin_client_config.json'; -import { operationsProtos } from 'google-gax'; +import {operationsProtos} from 'google-gax'; const version = require('../../../package.json').version; /** @@ -100,11 +111,16 @@ export class BigtableTableAdminClient { constructor(opts?: ClientOptions) { // Ensure that options include all the required fields. const staticMembers = this.constructor as typeof BigtableTableAdminClient; - const servicePath = opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; - this._providedCustomServicePath = !!(opts?.servicePath || opts?.apiEndpoint); + const servicePath = + opts?.servicePath || opts?.apiEndpoint || staticMembers.servicePath; + this._providedCustomServicePath = !!( + opts?.servicePath || opts?.apiEndpoint + ); const port = opts?.port || staticMembers.port; const clientConfig = opts?.clientConfig ?? {}; - const fallback = opts?.fallback ?? (typeof window !== 'undefined' && typeof window?.fetch === 'function'); + const fallback = + opts?.fallback ?? + (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. @@ -122,7 +138,7 @@ export class BigtableTableAdminClient { this._opts = opts; // Save the auth object to the client, for use by other methods. - this.auth = (this._gaxGrpc.auth as gax.GoogleAuth); + this.auth = this._gaxGrpc.auth as gax.GoogleAuth; // Set useJWTAccessWithScope on the auth object. this.auth.useJWTAccessWithScope = true; @@ -135,13 +151,9 @@ export class BigtableTableAdminClient { this.auth.defaultScopes = staticMembers.scopes; } this.locationsClient = new LocationsClient(this._gaxGrpc, opts); - // Determine the client header string. - const clientHeader = [ - `gax/${this._gaxModule.version}`, - `gapic/${version}`, - ]; + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; if (typeof process !== 'undefined' && 'versions' in process) { clientHeader.push(`gl-node/${process.versions.node}`); } else { @@ -149,7 +161,7 @@ export class BigtableTableAdminClient { } if (!opts.fallback) { clientHeader.push(`grpc/${this._gaxGrpc.grpcVersion}`); - } else if (opts.fallback === 'rest' ) { + } else if (opts.fallback === 'rest') { clientHeader.push(`rest/${this._gaxGrpc.grpcVersion}`); } if (opts.libName && opts.libVersion) { @@ -189,12 +201,21 @@ export class BigtableTableAdminClient { // (e.g. 50 results at a time, with tokens to get subsequent // pages). Denote the keys used for pagination and results. this.descriptors.page = { - listTables: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'tables'), - listSnapshots: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'snapshots'), - listBackups: - new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'backups') + listTables: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'tables' + ), + listSnapshots: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'snapshots' + ), + listBackups: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'backups' + ), }; const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos); @@ -203,69 +224,121 @@ export class BigtableTableAdminClient { // rather than holding a request open. const lroOptions: GrpcClientOptions = { auth: this.auth, - grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined + grpc: 'grpc' in this._gaxGrpc ? this._gaxGrpc.grpc : undefined, }; if (opts.fallback === 'rest') { lroOptions.protoJson = protoFilesRoot; - lroOptions.httpRules = [{selector: 'google.cloud.location.Locations.GetLocation',get: '/v2/{name=projects/*/locations/*}',},{selector: 'google.cloud.location.Locations.ListLocations',get: '/v2/{name=projects/*}/locations',},{selector: 'google.longrunning.Operations.CancelOperation',post: '/v2/{name=operations/**}:cancel',},{selector: 'google.longrunning.Operations.DeleteOperation',delete: '/v2/{name=operations/**}',},{selector: 'google.longrunning.Operations.GetOperation',get: '/v2/{name=operations/**}',},{selector: 'google.longrunning.Operations.ListOperations',get: '/v2/{name=operations/projects/**}/operations',}]; + lroOptions.httpRules = [ + { + selector: 'google.cloud.location.Locations.GetLocation', + get: '/v2/{name=projects/*/locations/*}', + }, + { + selector: 'google.cloud.location.Locations.ListLocations', + get: '/v2/{name=projects/*}/locations', + }, + { + selector: 'google.longrunning.Operations.CancelOperation', + post: '/v2/{name=operations/**}:cancel', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v2/{name=operations/**}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v2/{name=operations/**}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v2/{name=operations/projects/**}/operations', + }, + ]; } - this.operationsClient = this._gaxModule.lro(lroOptions).operationsClient(opts); + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); const createTableFromSnapshotResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.Table') as gax.protobuf.Type; + '.google.bigtable.admin.v2.Table' + ) as gax.protobuf.Type; const createTableFromSnapshotMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.CreateTableFromSnapshotMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.CreateTableFromSnapshotMetadata' + ) as gax.protobuf.Type; const undeleteTableResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.Table') as gax.protobuf.Type; + '.google.bigtable.admin.v2.Table' + ) as gax.protobuf.Type; const undeleteTableMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.UndeleteTableMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.UndeleteTableMetadata' + ) as gax.protobuf.Type; const snapshotTableResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.Snapshot') as gax.protobuf.Type; + '.google.bigtable.admin.v2.Snapshot' + ) as gax.protobuf.Type; const snapshotTableMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.SnapshotTableMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.SnapshotTableMetadata' + ) as gax.protobuf.Type; const createBackupResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.Backup') as gax.protobuf.Type; + '.google.bigtable.admin.v2.Backup' + ) as gax.protobuf.Type; const createBackupMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.CreateBackupMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.CreateBackupMetadata' + ) as gax.protobuf.Type; const restoreTableResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.Table') as gax.protobuf.Type; + '.google.bigtable.admin.v2.Table' + ) as gax.protobuf.Type; const restoreTableMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.RestoreTableMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.RestoreTableMetadata' + ) as gax.protobuf.Type; const copyBackupResponse = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.Backup') as gax.protobuf.Type; + '.google.bigtable.admin.v2.Backup' + ) as gax.protobuf.Type; const copyBackupMetadata = protoFilesRoot.lookup( - '.google.bigtable.admin.v2.CopyBackupMetadata') as gax.protobuf.Type; + '.google.bigtable.admin.v2.CopyBackupMetadata' + ) as gax.protobuf.Type; this.descriptors.longrunning = { createTableFromSnapshot: new this._gaxModule.LongrunningDescriptor( this.operationsClient, - createTableFromSnapshotResponse.decode.bind(createTableFromSnapshotResponse), - createTableFromSnapshotMetadata.decode.bind(createTableFromSnapshotMetadata)), + createTableFromSnapshotResponse.decode.bind( + createTableFromSnapshotResponse + ), + createTableFromSnapshotMetadata.decode.bind( + createTableFromSnapshotMetadata + ) + ), undeleteTable: new this._gaxModule.LongrunningDescriptor( this.operationsClient, undeleteTableResponse.decode.bind(undeleteTableResponse), - undeleteTableMetadata.decode.bind(undeleteTableMetadata)), + undeleteTableMetadata.decode.bind(undeleteTableMetadata) + ), snapshotTable: new this._gaxModule.LongrunningDescriptor( this.operationsClient, snapshotTableResponse.decode.bind(snapshotTableResponse), - snapshotTableMetadata.decode.bind(snapshotTableMetadata)), + snapshotTableMetadata.decode.bind(snapshotTableMetadata) + ), createBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, createBackupResponse.decode.bind(createBackupResponse), - createBackupMetadata.decode.bind(createBackupMetadata)), + createBackupMetadata.decode.bind(createBackupMetadata) + ), restoreTable: new this._gaxModule.LongrunningDescriptor( this.operationsClient, restoreTableResponse.decode.bind(restoreTableResponse), - restoreTableMetadata.decode.bind(restoreTableMetadata)), + restoreTableMetadata.decode.bind(restoreTableMetadata) + ), copyBackup: new this._gaxModule.LongrunningDescriptor( this.operationsClient, copyBackupResponse.decode.bind(copyBackupResponse), - copyBackupMetadata.decode.bind(copyBackupMetadata)) + copyBackupMetadata.decode.bind(copyBackupMetadata) + ), }; // Put together the default options sent with requests. this._defaults = this._gaxGrpc.constructSettings( - 'google.bigtable.admin.v2.BigtableTableAdmin', gapicConfig as gax.ClientConfig, - opts.clientConfig || {}, {'x-goog-api-client': clientHeader.join(' ')}); + 'google.bigtable.admin.v2.BigtableTableAdmin', + gapicConfig as gax.ClientConfig, + opts.clientConfig || {}, + {'x-goog-api-client': clientHeader.join(' ')} + ); // Set up a dictionary of "inner API calls"; the core implementation // of calling the API is handled in `google-gax`, with this code @@ -296,28 +369,58 @@ export class BigtableTableAdminClient { // Put together the "service stub" for // google.bigtable.admin.v2.BigtableTableAdmin. this.bigtableTableAdminStub = this._gaxGrpc.createStub( - this._opts.fallback ? - (this._protos as protobuf.Root).lookupService('google.bigtable.admin.v2.BigtableTableAdmin') : - // eslint-disable-next-line @typescript-eslint/no-explicit-any + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.bigtable.admin.v2.BigtableTableAdmin' + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.bigtable.admin.v2.BigtableTableAdmin, - this._opts, this._providedCustomServicePath) as Promise<{[method: string]: Function}>; + this._opts, + this._providedCustomServicePath + ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides // and create an API call method for each. - const bigtableTableAdminStubMethods = - ['createTable', 'createTableFromSnapshot', 'listTables', 'getTable', 'deleteTable', 'undeleteTable', 'modifyColumnFamilies', 'dropRowRange', 'generateConsistencyToken', 'checkConsistency', 'snapshotTable', 'getSnapshot', 'listSnapshots', 'deleteSnapshot', 'createBackup', 'getBackup', 'updateBackup', 'deleteBackup', 'listBackups', 'restoreTable', 'copyBackup', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions']; + const bigtableTableAdminStubMethods = [ + 'createTable', + 'createTableFromSnapshot', + 'listTables', + 'getTable', + 'deleteTable', + 'undeleteTable', + 'modifyColumnFamilies', + 'dropRowRange', + 'generateConsistencyToken', + 'checkConsistency', + 'snapshotTable', + 'getSnapshot', + 'listSnapshots', + 'deleteSnapshot', + 'createBackup', + 'getBackup', + 'updateBackup', + 'deleteBackup', + 'listBackups', + 'restoreTable', + 'copyBackup', + 'getIamPolicy', + 'setIamPolicy', + 'testIamPermissions', + ]; for (const methodName of bigtableTableAdminStubMethods) { const callPromise = this.bigtableTableAdminStub.then( - stub => (...args: Array<{}>) => { - if (this._terminated) { - return Promise.reject('The client has already been closed.'); - } - const func = stub[methodName]; - return func.apply(stub, args); - }, - (err: Error|null|undefined) => () => { + stub => + (...args: Array<{}>) => { + if (this._terminated) { + return Promise.reject('The client has already been closed.'); + } + const func = stub[methodName]; + return func.apply(stub, args); + }, + (err: Error | null | undefined) => () => { throw err; - }); + } + ); const descriptor = this.descriptors.page[methodName] || @@ -372,7 +475,7 @@ export class BigtableTableAdminClient { 'https://www.googleapis.com/auth/cloud-bigtable.admin', 'https://www.googleapis.com/auth/cloud-bigtable.admin.table', 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/cloud-platform.read-only' + 'https://www.googleapis.com/auth/cloud-platform.read-only', ]; } @@ -382,8 +485,9 @@ export class BigtableTableAdminClient { * Return the project ID used by this class. * @returns {Promise} A promise that resolves to string containing the project ID. */ - getProjectId(callback?: Callback): - Promise|void { + getProjectId( + callback?: Callback + ): Promise | void { if (callback) { this.auth.getProjectId(callback); return; @@ -394,1973 +498,2492 @@ export class BigtableTableAdminClient { // ------------------- // -- Service calls -- // ------------------- -/** - * Creates a new table in the specified instance. - * The table can be created with a full set of initial column families, - * specified in the request. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the instance in which to create the table. - * Values are of the form `projects/{project}/instances/{instance}`. - * @param {string} request.tableId - * Required. The name by which the new table should be referred to within the - * parent instance, e.g., `foobar` rather than `{parent}/tables/foobar`. - * Maximum 50 characters. - * @param {google.bigtable.admin.v2.Table} request.table - * Required. The Table to create. - * @param {number[]} request.initialSplits - * The optional list of row keys that will be used to initially split the - * table into several tablets (tablets are similar to HBase regions). - * Given two split keys, `s1` and `s2`, three tablets will be created, - * spanning the key ranges: `[, s1), [s1, s2), [s2, )`. - * - * Example: - * - * * Row keys := `["a", "apple", "custom", "customer_1", "customer_2",` - * `"other", "zz"]` - * * initial_split_keys := `["apple", "customer_1", "customer_2", "other"]` - * * Key assignment: - * - Tablet 1 `[, apple) => {"a"}.` - * - Tablet 2 `[apple, customer_1) => {"apple", "custom"}.` - * - Tablet 3 `[customer_1, customer_2) => {"customer_1"}.` - * - Tablet 4 `[customer_2, other) => {"customer_2"}.` - * - Tablet 5 `[other, ) => {"other", "zz"}.` - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Table]{@link google.bigtable.admin.v2.Table}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.create_table.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CreateTable_async - */ + /** + * Creates a new table in the specified instance. + * The table can be created with a full set of initial column families, + * specified in the request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the instance in which to create the table. + * Values are of the form `projects/{project}/instances/{instance}`. + * @param {string} request.tableId + * Required. The name by which the new table should be referred to within the + * parent instance, e.g., `foobar` rather than `{parent}/tables/foobar`. + * Maximum 50 characters. + * @param {google.bigtable.admin.v2.Table} request.table + * Required. The Table to create. + * @param {number[]} request.initialSplits + * The optional list of row keys that will be used to initially split the + * table into several tablets (tablets are similar to HBase regions). + * Given two split keys, `s1` and `s2`, three tablets will be created, + * spanning the key ranges: `[, s1), [s1, s2), [s2, )`. + * + * Example: + * + * * Row keys := `["a", "apple", "custom", "customer_1", "customer_2",` + * `"other", "zz"]` + * * initial_split_keys := `["apple", "customer_1", "customer_2", "other"]` + * * Key assignment: + * - Tablet 1 `[, apple) => {"a"}.` + * - Tablet 2 `[apple, customer_1) => {"apple", "custom"}.` + * - Tablet 3 `[customer_1, customer_2) => {"customer_1"}.` + * - Tablet 4 `[customer_2, other) => {"customer_2"}.` + * - Tablet 5 `[other, ) => {"other", "zz"}.` + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Table]{@link google.bigtable.admin.v2.Table}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.create_table.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CreateTable_async + */ createTable( - request?: protos.google.bigtable.admin.v2.ICreateTableRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.ICreateTableRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.ICreateTableRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableRequest | undefined, + {} | undefined + ] + >; createTable( - request: protos.google.bigtable.admin.v2.ICreateTableRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.ICreateTableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateTableRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableRequest | null | undefined, + {} | null | undefined + > + ): void; createTable( - request: protos.google.bigtable.admin.v2.ICreateTableRequest, - callback: Callback< - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.ICreateTableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateTableRequest, + callback: Callback< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableRequest | null | undefined, + {} | null | undefined + > + ): void; createTable( - request?: protos.google.bigtable.admin.v2.ICreateTableRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.ICreateTableRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.ICreateTableRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.ICreateTableRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.ICreateTableRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.ICreateTableRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createTable(request, options, callback); } -/** - * Gets metadata information about the specified table. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the requested table. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param {google.bigtable.admin.v2.Table.View} request.view - * The view to be applied to the returned table's fields. - * Defaults to `SCHEMA_VIEW` if unspecified. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Table]{@link google.bigtable.admin.v2.Table}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.get_table.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_GetTable_async - */ + /** + * Gets metadata information about the specified table. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the requested table. + * Values are of the form + * `projects/{project}/instances/{instance}/tables/{table}`. + * @param {google.bigtable.admin.v2.Table.View} request.view + * The view to be applied to the returned table's fields. + * Defaults to `SCHEMA_VIEW` if unspecified. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Table]{@link google.bigtable.admin.v2.Table}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.get_table.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_GetTable_async + */ getTable( - request?: protos.google.bigtable.admin.v2.IGetTableRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IGetTableRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IGetTableRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IGetTableRequest | undefined, + {} | undefined + ] + >; getTable( - request: protos.google.bigtable.admin.v2.IGetTableRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IGetTableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetTableRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IGetTableRequest | null | undefined, + {} | null | undefined + > + ): void; getTable( - request: protos.google.bigtable.admin.v2.IGetTableRequest, - callback: Callback< - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IGetTableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetTableRequest, + callback: Callback< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IGetTableRequest | null | undefined, + {} | null | undefined + > + ): void; getTable( - request?: protos.google.bigtable.admin.v2.IGetTableRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IGetTableRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IGetTableRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IGetTableRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IGetTableRequest|undefined, {}|undefined - ]>|void { + protos.google.bigtable.admin.v2.IGetTableRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IGetTableRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IGetTableRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getTable(request, options, callback); } -/** - * Permanently deletes a specified table and all of its data. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the table to be deleted. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.delete_table.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_DeleteTable_async - */ + /** + * Permanently deletes a specified table and all of its data. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the table to be deleted. + * Values are of the form + * `projects/{project}/instances/{instance}/tables/{table}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.delete_table.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_DeleteTable_async + */ deleteTable( - request?: protos.google.bigtable.admin.v2.IDeleteTableRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteTableRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IDeleteTableRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteTableRequest | undefined, + {} | undefined + ] + >; deleteTable( - request: protos.google.bigtable.admin.v2.IDeleteTableRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteTableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteTableRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteTableRequest | null | undefined, + {} | null | undefined + > + ): void; deleteTable( - request: protos.google.bigtable.admin.v2.IDeleteTableRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteTableRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteTableRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteTableRequest | null | undefined, + {} | null | undefined + > + ): void; deleteTable( - request?: protos.google.bigtable.admin.v2.IDeleteTableRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteTableRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IDeleteTableRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteTableRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteTableRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IDeleteTableRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteTableRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteTableRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteTable(request, options, callback); } -/** - * Performs a series of column family modifications on the specified table. - * Either all or none of the modifications will occur before this method - * returns, but data requests received prior to that point may see a table - * where only some modifications have taken effect. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the table whose families should be modified. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param {number[]} request.modifications - * Required. Modifications to be atomically applied to the specified table's - * families. Entries are applied in order, meaning that earlier modifications - * can be masked by later ones (in the case of repeated updates to the same - * family, for example). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Table]{@link google.bigtable.admin.v2.Table}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.modify_column_families.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_ModifyColumnFamilies_async - */ + /** + * Performs a series of column family modifications on the specified table. + * Either all or none of the modifications will occur before this method + * returns, but data requests received prior to that point may see a table + * where only some modifications have taken effect. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the table whose families should be modified. + * Values are of the form + * `projects/{project}/instances/{instance}/tables/{table}`. + * @param {number[]} request.modifications + * Required. Modifications to be atomically applied to the specified table's + * families. Entries are applied in order, meaning that earlier modifications + * can be masked by later ones (in the case of repeated updates to the same + * family, for example). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Table]{@link google.bigtable.admin.v2.Table}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.modify_column_families.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_ModifyColumnFamilies_async + */ modifyColumnFamilies( - request?: protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest | undefined, + {} | undefined + ] + >; modifyColumnFamilies( - request: protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.ITable, + | protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest + | null + | undefined, + {} | null | undefined + > + ): void; modifyColumnFamilies( - request: protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest, - callback: Callback< - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest, + callback: Callback< + protos.google.bigtable.admin.v2.ITable, + | protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest + | null + | undefined, + {} | null | undefined + > + ): void; modifyColumnFamilies( - request?: protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.ITable, - protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.ITable, + | protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IModifyColumnFamiliesRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.modifyColumnFamilies(request, options, callback); } -/** - * Permanently drop/delete a row range from a specified table. The request can - * specify whether to delete all rows in a table, or only those that match a - * particular prefix. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the table on which to drop a range of rows. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param {Buffer} request.rowKeyPrefix - * Delete all rows that start with this row key prefix. Prefix cannot be - * zero length. - * @param {boolean} request.deleteAllDataFromTable - * Delete all rows in the table. Setting this to false is a no-op. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.drop_row_range.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_DropRowRange_async - */ + /** + * Permanently drop/delete a row range from a specified table. The request can + * specify whether to delete all rows in a table, or only those that match a + * particular prefix. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the table on which to drop a range of rows. + * Values are of the form + * `projects/{project}/instances/{instance}/tables/{table}`. + * @param {Buffer} request.rowKeyPrefix + * Delete all rows that start with this row key prefix. Prefix cannot be + * zero length. + * @param {boolean} request.deleteAllDataFromTable + * Delete all rows in the table. Setting this to false is a no-op. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.drop_row_range.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_DropRowRange_async + */ dropRowRange( - request?: protos.google.bigtable.admin.v2.IDropRowRangeRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDropRowRangeRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IDropRowRangeRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDropRowRangeRequest | undefined, + {} | undefined + ] + >; dropRowRange( - request: protos.google.bigtable.admin.v2.IDropRowRangeRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDropRowRangeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDropRowRangeRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDropRowRangeRequest | null | undefined, + {} | null | undefined + > + ): void; dropRowRange( - request: protos.google.bigtable.admin.v2.IDropRowRangeRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDropRowRangeRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDropRowRangeRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDropRowRangeRequest | null | undefined, + {} | null | undefined + > + ): void; dropRowRange( - request?: protos.google.bigtable.admin.v2.IDropRowRangeRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDropRowRangeRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IDropRowRangeRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDropRowRangeRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDropRowRangeRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IDropRowRangeRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDropRowRangeRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDropRowRangeRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.dropRowRange(request, options, callback); } -/** - * Generates a consistency token for a Table, which can be used in - * CheckConsistency to check whether mutations to the table that finished - * before this call started have been replicated. The tokens will be available - * for 90 days. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the Table for which to create a consistency - * token. Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [GenerateConsistencyTokenResponse]{@link google.bigtable.admin.v2.GenerateConsistencyTokenResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.generate_consistency_token.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_GenerateConsistencyToken_async - */ + /** + * Generates a consistency token for a Table, which can be used in + * CheckConsistency to check whether mutations to the table that finished + * before this call started have been replicated. The tokens will be available + * for 90 days. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the Table for which to create a consistency + * token. Values are of the form + * `projects/{project}/instances/{instance}/tables/{table}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [GenerateConsistencyTokenResponse]{@link google.bigtable.admin.v2.GenerateConsistencyTokenResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.generate_consistency_token.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_GenerateConsistencyToken_async + */ generateConsistencyToken( - request?: protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse, - protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse, + ( + | protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest + | undefined + ), + {} | undefined + ] + >; generateConsistencyToken( - request: protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse, - protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse, + | protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest + | null + | undefined, + {} | null | undefined + > + ): void; generateConsistencyToken( - request: protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest, - callback: Callback< - protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse, - protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest, + callback: Callback< + protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse, + | protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest + | null + | undefined, + {} | null | undefined + > + ): void; generateConsistencyToken( - request?: protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse, - protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse, - protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse, - protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse, + | protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse, + ( + | protos.google.bigtable.admin.v2.IGenerateConsistencyTokenRequest + | undefined + ), + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); - return this.innerApiCalls.generateConsistencyToken(request, options, callback); + return this.innerApiCalls.generateConsistencyToken( + request, + options, + callback + ); } -/** - * Checks replication consistency based on a consistency token, that is, if - * replication has caught up based on the conditions specified in the token - * and the check request. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the Table for which to check replication - * consistency. Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param {string} request.consistencyToken - * Required. The token created using GenerateConsistencyToken for the Table. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [CheckConsistencyResponse]{@link google.bigtable.admin.v2.CheckConsistencyResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.check_consistency.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CheckConsistency_async - */ + /** + * Checks replication consistency based on a consistency token, that is, if + * replication has caught up based on the conditions specified in the token + * and the check request. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the Table for which to check replication + * consistency. Values are of the form + * `projects/{project}/instances/{instance}/tables/{table}`. + * @param {string} request.consistencyToken + * Required. The token created using GenerateConsistencyToken for the Table. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [CheckConsistencyResponse]{@link google.bigtable.admin.v2.CheckConsistencyResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.check_consistency.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CheckConsistency_async + */ checkConsistency( - request?: protos.google.bigtable.admin.v2.ICheckConsistencyRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.ICheckConsistencyResponse, - protos.google.bigtable.admin.v2.ICheckConsistencyRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.ICheckConsistencyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.ICheckConsistencyResponse, + protos.google.bigtable.admin.v2.ICheckConsistencyRequest | undefined, + {} | undefined + ] + >; checkConsistency( - request: protos.google.bigtable.admin.v2.ICheckConsistencyRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.ICheckConsistencyResponse, - protos.google.bigtable.admin.v2.ICheckConsistencyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICheckConsistencyRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.ICheckConsistencyResponse, + | protos.google.bigtable.admin.v2.ICheckConsistencyRequest + | null + | undefined, + {} | null | undefined + > + ): void; checkConsistency( - request: protos.google.bigtable.admin.v2.ICheckConsistencyRequest, - callback: Callback< - protos.google.bigtable.admin.v2.ICheckConsistencyResponse, - protos.google.bigtable.admin.v2.ICheckConsistencyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICheckConsistencyRequest, + callback: Callback< + protos.google.bigtable.admin.v2.ICheckConsistencyResponse, + | protos.google.bigtable.admin.v2.ICheckConsistencyRequest + | null + | undefined, + {} | null | undefined + > + ): void; checkConsistency( - request?: protos.google.bigtable.admin.v2.ICheckConsistencyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.ICheckConsistencyResponse, - protos.google.bigtable.admin.v2.ICheckConsistencyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.ICheckConsistencyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.ICheckConsistencyResponse, - protos.google.bigtable.admin.v2.ICheckConsistencyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.ICheckConsistencyResponse, - protos.google.bigtable.admin.v2.ICheckConsistencyRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.ICheckConsistencyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.ICheckConsistencyResponse, + | protos.google.bigtable.admin.v2.ICheckConsistencyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.ICheckConsistencyResponse, + protos.google.bigtable.admin.v2.ICheckConsistencyRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.checkConsistency(request, options, callback); } -/** - * Gets metadata information about the specified snapshot. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the requested snapshot. - * Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Snapshot]{@link google.bigtable.admin.v2.Snapshot}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.get_snapshot.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_GetSnapshot_async - */ + /** + * Gets metadata information about the specified snapshot. + * + * Note: This is a private alpha release of Cloud Bigtable snapshots. This + * feature is not currently available to most Cloud Bigtable customers. This + * feature might be changed in backward-incompatible ways and is not + * recommended for production use. It is not subject to any SLA or deprecation + * policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the requested snapshot. + * Values are of the form + * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Snapshot]{@link google.bigtable.admin.v2.Snapshot}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.get_snapshot.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_GetSnapshot_async + */ getSnapshot( - request?: protos.google.bigtable.admin.v2.IGetSnapshotRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.ISnapshot, - protos.google.bigtable.admin.v2.IGetSnapshotRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IGetSnapshotRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.IGetSnapshotRequest | undefined, + {} | undefined + ] + >; getSnapshot( - request: protos.google.bigtable.admin.v2.IGetSnapshotRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.ISnapshot, - protos.google.bigtable.admin.v2.IGetSnapshotRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetSnapshotRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.IGetSnapshotRequest | null | undefined, + {} | null | undefined + > + ): void; getSnapshot( - request: protos.google.bigtable.admin.v2.IGetSnapshotRequest, - callback: Callback< - protos.google.bigtable.admin.v2.ISnapshot, - protos.google.bigtable.admin.v2.IGetSnapshotRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetSnapshotRequest, + callback: Callback< + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.IGetSnapshotRequest | null | undefined, + {} | null | undefined + > + ): void; getSnapshot( - request?: protos.google.bigtable.admin.v2.IGetSnapshotRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.ISnapshot, - protos.google.bigtable.admin.v2.IGetSnapshotRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IGetSnapshotRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.ISnapshot, - protos.google.bigtable.admin.v2.IGetSnapshotRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.ISnapshot, - protos.google.bigtable.admin.v2.IGetSnapshotRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IGetSnapshotRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.IGetSnapshotRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.IGetSnapshotRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getSnapshot(request, options, callback); } -/** - * Permanently deletes the specified snapshot. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the snapshot to be deleted. - * Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.delete_snapshot.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_DeleteSnapshot_async - */ + /** + * Permanently deletes the specified snapshot. + * + * Note: This is a private alpha release of Cloud Bigtable snapshots. This + * feature is not currently available to most Cloud Bigtable customers. This + * feature might be changed in backward-incompatible ways and is not + * recommended for production use. It is not subject to any SLA or deprecation + * policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the snapshot to be deleted. + * Values are of the form + * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.delete_snapshot.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_DeleteSnapshot_async + */ deleteSnapshot( - request?: protos.google.bigtable.admin.v2.IDeleteSnapshotRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteSnapshotRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IDeleteSnapshotRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteSnapshotRequest | undefined, + {} | undefined + ] + >; deleteSnapshot( - request: protos.google.bigtable.admin.v2.IDeleteSnapshotRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteSnapshotRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteSnapshotRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteSnapshotRequest | null | undefined, + {} | null | undefined + > + ): void; deleteSnapshot( - request: protos.google.bigtable.admin.v2.IDeleteSnapshotRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteSnapshotRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteSnapshotRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteSnapshotRequest | null | undefined, + {} | null | undefined + > + ): void; deleteSnapshot( - request?: protos.google.bigtable.admin.v2.IDeleteSnapshotRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteSnapshotRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IDeleteSnapshotRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteSnapshotRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteSnapshotRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IDeleteSnapshotRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteSnapshotRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteSnapshotRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteSnapshot(request, options, callback); } -/** - * Gets metadata on a pending or completed Cloud Bigtable Backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the backup. - * Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Backup]{@link google.bigtable.admin.v2.Backup}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.get_backup.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_GetBackup_async - */ + /** + * Gets metadata on a pending or completed Cloud Bigtable Backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the backup. + * Values are of the form + * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Backup]{@link google.bigtable.admin.v2.Backup}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.get_backup.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_GetBackup_async + */ getBackup( - request?: protos.google.bigtable.admin.v2.IGetBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IGetBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IGetBackupRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.IGetBackupRequest | undefined, + {} | undefined + ] + >; getBackup( - request: protos.google.bigtable.admin.v2.IGetBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.IGetBackupRequest | null | undefined, + {} | null | undefined + > + ): void; getBackup( - request: protos.google.bigtable.admin.v2.IGetBackupRequest, - callback: Callback< - protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IGetBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IGetBackupRequest, + callback: Callback< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.IGetBackupRequest | null | undefined, + {} | null | undefined + > + ): void; getBackup( - request?: protos.google.bigtable.admin.v2.IGetBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IGetBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IGetBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IGetBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IGetBackupRequest|undefined, {}|undefined - ]>|void { + protos.google.bigtable.admin.v2.IGetBackupRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.IGetBackupRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.IGetBackupRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.getBackup(request, options, callback); } -/** - * Updates a pending or completed Cloud Bigtable Backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {google.bigtable.admin.v2.Backup} request.backup - * Required. The backup to update. `backup.name`, and the fields to be updated - * as specified by `update_mask` are required. Other fields are ignored. - * Update is only supported for the following fields: - * * `backup.expire_time`. - * @param {google.protobuf.FieldMask} request.updateMask - * Required. A mask specifying which fields (e.g. `expire_time`) in the - * Backup resource should be updated. This mask is relative to the Backup - * resource, not to the request message. The field mask must always be - * specified; this prevents any future fields from being erased accidentally - * by clients that do not know about them. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Backup]{@link google.bigtable.admin.v2.Backup}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.update_backup.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_UpdateBackup_async - */ + /** + * Updates a pending or completed Cloud Bigtable Backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {google.bigtable.admin.v2.Backup} request.backup + * Required. The backup to update. `backup.name`, and the fields to be updated + * as specified by `update_mask` are required. Other fields are ignored. + * Update is only supported for the following fields: + * * `backup.expire_time`. + * @param {google.protobuf.FieldMask} request.updateMask + * Required. A mask specifying which fields (e.g. `expire_time`) in the + * Backup resource should be updated. This mask is relative to the Backup + * resource, not to the request message. The field mask must always be + * specified; this prevents any future fields from being erased accidentally + * by clients that do not know about them. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Backup]{@link google.bigtable.admin.v2.Backup}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.update_backup.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_UpdateBackup_async + */ updateBackup( - request?: protos.google.bigtable.admin.v2.IUpdateBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IUpdateBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IUpdateBackupRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.IUpdateBackupRequest | undefined, + {} | undefined + ] + >; updateBackup( - request: protos.google.bigtable.admin.v2.IUpdateBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IUpdateBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.IUpdateBackupRequest | null | undefined, + {} | null | undefined + > + ): void; updateBackup( - request: protos.google.bigtable.admin.v2.IUpdateBackupRequest, - callback: Callback< - protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IUpdateBackupRequest, + callback: Callback< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.IUpdateBackupRequest | null | undefined, + {} | null | undefined + > + ): void; updateBackup( - request?: protos.google.bigtable.admin.v2.IUpdateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IUpdateBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IUpdateBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IUpdateBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.bigtable.admin.v2.IBackup, - protos.google.bigtable.admin.v2.IUpdateBackupRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IUpdateBackupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.IUpdateBackupRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.IUpdateBackupRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'backup.name': request.backup!.name || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + 'backup.name': request.backup!.name || '', + }); this.initialize(); return this.innerApiCalls.updateBackup(request, options, callback); } -/** - * Deletes a pending or completed Cloud Bigtable backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. Name of the backup to delete. - * Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.delete_backup.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_DeleteBackup_async - */ + /** + * Deletes a pending or completed Cloud Bigtable backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the backup to delete. + * Values are of the form + * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Empty]{@link google.protobuf.Empty}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.delete_backup.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_DeleteBackup_async + */ deleteBackup( - request?: protos.google.bigtable.admin.v2.IDeleteBackupRequest, - options?: CallOptions): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteBackupRequest|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IDeleteBackupRequest, + options?: CallOptions + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteBackupRequest | undefined, + {} | undefined + ] + >; deleteBackup( - request: protos.google.bigtable.admin.v2.IDeleteBackupRequest, - options: CallOptions, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteBackupRequest, + options: CallOptions, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteBackupRequest | null | undefined, + {} | null | undefined + > + ): void; deleteBackup( - request: protos.google.bigtable.admin.v2.IDeleteBackupRequest, - callback: Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IDeleteBackupRequest, + callback: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteBackupRequest | null | undefined, + {} | null | undefined + > + ): void; deleteBackup( - request?: protos.google.bigtable.admin.v2.IDeleteBackupRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteBackupRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.bigtable.admin.v2.IDeleteBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteBackupRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.protobuf.IEmpty, - protos.google.bigtable.admin.v2.IDeleteBackupRequest|undefined, {}|undefined - ]>|void { + | protos.google.bigtable.admin.v2.IDeleteBackupRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteBackupRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.protobuf.IEmpty, + protos.google.bigtable.admin.v2.IDeleteBackupRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.deleteBackup(request, options, callback); } -/** - * Gets the access control policy for a Table resource. - * Returns an empty policy if the resource exists but does not have a policy - * set. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.GetPolicyOptions} request.options - * OPTIONAL: A `GetPolicyOptions` object for specifying options to - * `GetIamPolicy`. This field is only used by Cloud IAM. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.get_iam_policy.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_GetIamPolicy_async - */ + /** + * Gets the access control policy for a Table resource. + * Returns an empty policy if the resource exists but does not have a policy + * set. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.GetPolicyOptions} request.options + * OPTIONAL: A `GetPolicyOptions` object for specifying options to + * `GetIamPolicy`. This field is only used by Cloud IAM. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.get_iam_policy.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_GetIamPolicy_async + */ getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.IGetIamPolicyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined + ] + >; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; getIamPolicy( - request: protos.google.iam.v1.IGetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.IGetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; getIamPolicy( - request?: protos.google.iam.v1.IGetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.IGetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.IGetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.IGetIamPolicyRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'resource': request.resource || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + resource: request.resource || '', + }); this.initialize(); return this.innerApiCalls.getIamPolicy(request, options, callback); } -/** - * Sets the access control policy on a Table resource. - * Replaces any existing policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy is being specified. - * See the operation documentation for the appropriate value for this field. - * @param {google.iam.v1.Policy} request.policy - * REQUIRED: The complete policy to be applied to the `resource`. The size of - * the policy is limited to a few 10s of KB. An empty policy is a - * valid policy but certain Cloud Platform services (such as Projects) - * might reject them. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.set_iam_policy.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_SetIamPolicy_async - */ + /** + * Sets the access control policy on a Table resource. + * Replaces any existing policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy is being specified. + * See the operation documentation for the appropriate value for this field. + * @param {google.iam.v1.Policy} request.policy + * REQUIRED: The complete policy to be applied to the `resource`. The size of + * the policy is limited to a few 10s of KB. An empty policy is a + * valid policy but certain Cloud Platform services (such as Projects) + * might reject them. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.set_iam_policy.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_SetIamPolicy_async + */ setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ISetIamPolicyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined + ] + >; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; setIamPolicy( - request: protos.google.iam.v1.ISetIamPolicyRequest, - callback: Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ISetIamPolicyRequest, + callback: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): void; setIamPolicy( - request?: protos.google.iam.v1.ISetIamPolicyRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ISetIamPolicyRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.IPolicy, - protos.google.iam.v1.ISetIamPolicyRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.iam.v1.IPolicy, + protos.google.iam.v1.ISetIamPolicyRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'resource': request.resource || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + resource: request.resource || '', + }); this.initialize(); return this.innerApiCalls.setIamPolicy(request, options, callback); } -/** - * Returns permissions that the caller has on the specified table resource. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.resource - * REQUIRED: The resource for which the policy detail is being requested. - * See the operation documentation for the appropriate value for this field. - * @param {string[]} request.permissions - * The set of permissions to check for the `resource`. Permissions with - * wildcards (such as '*' or 'storage.*') are not allowed. For more - * information see - * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.test_iam_permissions.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_TestIamPermissions_async - */ + /** + * Returns permissions that the caller has on the specified table resource. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.resource + * REQUIRED: The resource for which the policy detail is being requested. + * See the operation documentation for the appropriate value for this field. + * @param {string[]} request.permissions + * The set of permissions to check for the `resource`. Permissions with + * wildcards (such as '*' or 'storage.*') are not allowed. For more + * information see + * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions). + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.test_iam_permissions.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_TestIamPermissions_async + */ testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - options?: CallOptions): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>; + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined + ] + >; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - options: CallOptions, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + options: CallOptions, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ): void; testIamPermissions( - request: protos.google.iam.v1.ITestIamPermissionsRequest, - callback: Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): void; + request: protos.google.iam.v1.ITestIamPermissionsRequest, + callback: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ): void; testIamPermissions( - request?: protos.google.iam.v1.ITestIamPermissionsRequest, - optionsOrCallback?: CallOptions|Callback< - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>, - callback?: Callback< + request?: protos.google.iam.v1.ITestIamPermissionsRequest, + optionsOrCallback?: + | CallOptions + | Callback< protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|null|undefined, - {}|null|undefined>): - Promise<[ - protos.google.iam.v1.ITestIamPermissionsResponse, - protos.google.iam.v1.ITestIamPermissionsRequest|undefined, {}|undefined - ]>|void { + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.iam.v1.ITestIamPermissionsResponse, + protos.google.iam.v1.ITestIamPermissionsRequest | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } options = options || {}; options.otherArgs = options.otherArgs || {}; options.otherArgs.headers = options.otherArgs.headers || {}; - options.otherArgs.headers[ - 'x-goog-request-params' - ] = gax.routingHeader.fromParams({ - 'resource': request.resource || '', - }); + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + resource: request.resource || '', + }); this.initialize(); return this.innerApiCalls.testIamPermissions(request, options, callback); } -/** - * Creates a new table from the specified snapshot. The target table must - * not exist. The snapshot and the table must be in the same instance. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the instance in which to create the table. - * Values are of the form `projects/{project}/instances/{instance}`. - * @param {string} request.tableId - * Required. The name by which the new table should be referred to within the - * parent instance, e.g., `foobar` rather than `{parent}/tables/foobar`. - * @param {string} request.sourceSnapshot - * Required. The unique name of the snapshot from which to restore the table. - * The snapshot and the table must be in the same instance. Values are of the - * form - * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.create_table_from_snapshot.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CreateTableFromSnapshot_async - */ + /** + * Creates a new table from the specified snapshot. The target table must + * not exist. The snapshot and the table must be in the same instance. + * + * Note: This is a private alpha release of Cloud Bigtable snapshots. This + * feature is not currently available to most Cloud Bigtable customers. This + * feature might be changed in backward-incompatible ways and is not + * recommended for production use. It is not subject to any SLA or deprecation + * policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the instance in which to create the table. + * Values are of the form `projects/{project}/instances/{instance}`. + * @param {string} request.tableId + * Required. The name by which the new table should be referred to within the + * parent instance, e.g., `foobar` rather than `{parent}/tables/foobar`. + * @param {string} request.sourceSnapshot + * Required. The unique name of the snapshot from which to restore the table. + * The snapshot and the table must be in the same instance. Values are of the + * form + * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/{snapshot}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.create_table_from_snapshot.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CreateTableFromSnapshot_async + */ createTableFromSnapshot( - request?: protos.google.bigtable.admin.v2.ICreateTableFromSnapshotRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.ICreateTableFromSnapshotRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableFromSnapshotMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; createTableFromSnapshot( - request: protos.google.bigtable.admin.v2.ICreateTableFromSnapshotRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateTableFromSnapshotRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableFromSnapshotMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; createTableFromSnapshot( - request: protos.google.bigtable.admin.v2.ICreateTableFromSnapshotRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateTableFromSnapshotRequest, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableFromSnapshotMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; createTableFromSnapshot( - request?: protos.google.bigtable.admin.v2.ICreateTableFromSnapshotRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.ICreateTableFromSnapshotRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableFromSnapshotMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableFromSnapshotMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableFromSnapshotMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); - return this.innerApiCalls.createTableFromSnapshot(request, options, callback); + return this.innerApiCalls.createTableFromSnapshot( + request, + options, + callback + ); } -/** - * Check the status of the long running operation returned by `createTableFromSnapshot()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.create_table_from_snapshot.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CreateTableFromSnapshot_async - */ - async checkCreateTableFromSnapshotProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `createTableFromSnapshot()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.create_table_from_snapshot.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CreateTableFromSnapshot_async + */ + async checkCreateTableFromSnapshotProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.Table, + protos.google.bigtable.admin.v2.CreateTableFromSnapshotMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createTableFromSnapshot, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.createTableFromSnapshot, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.Table, + protos.google.bigtable.admin.v2.CreateTableFromSnapshotMetadata + >; } -/** - * Restores a specified table which was accidentally deleted. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the table to be restored. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.undelete_table.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_UndeleteTable_async - */ + /** + * Restores a specified table which was accidentally deleted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the table to be restored. + * Values are of the form + * `projects/{project}/instances/{instance}/tables/{table}`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.undelete_table.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_UndeleteTable_async + */ undeleteTable( - request?: protos.google.bigtable.admin.v2.IUndeleteTableRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IUndeleteTableRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IUndeleteTableMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; undeleteTable( - request: protos.google.bigtable.admin.v2.IUndeleteTableRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IUndeleteTableRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IUndeleteTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; undeleteTable( - request: protos.google.bigtable.admin.v2.IUndeleteTableRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IUndeleteTableRequest, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IUndeleteTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; undeleteTable( - request?: protos.google.bigtable.admin.v2.IUndeleteTableRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.IUndeleteTableRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IUndeleteTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IUndeleteTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IUndeleteTableMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.undeleteTable(request, options, callback); } -/** - * Check the status of the long running operation returned by `undeleteTable()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.undelete_table.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_UndeleteTable_async - */ - async checkUndeleteTableProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `undeleteTable()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.undelete_table.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_UndeleteTable_async + */ + async checkUndeleteTableProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.Table, + protos.google.bigtable.admin.v2.UndeleteTableMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.undeleteTable, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.undeleteTable, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.Table, + protos.google.bigtable.admin.v2.UndeleteTableMetadata + >; } -/** - * Creates a new snapshot in the specified cluster from the specified - * source table. The cluster and the table must be in the same instance. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.name - * Required. The unique name of the table to have the snapshot taken. - * Values are of the form - * `projects/{project}/instances/{instance}/tables/{table}`. - * @param {string} request.cluster - * Required. The name of the cluster where the snapshot will be created in. - * Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param {string} request.snapshotId - * Required. The ID by which the new snapshot should be referred to within the - * parent cluster, e.g., `mysnapshot` of the form: - * `{@link -_.a-zA-Z0-9|_a-zA-Z0-9}*` rather than - * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/mysnapshot`. - * @param {google.protobuf.Duration} request.ttl - * The amount of time that the new snapshot can stay active after it is - * created. Once 'ttl' expires, the snapshot will get deleted. The maximum - * amount of time a snapshot can stay active is 7 days. If 'ttl' is not - * specified, the default value of 24 hours will be used. - * @param {string} request.description - * Description of the snapshot. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.snapshot_table.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_SnapshotTable_async - */ + /** + * Creates a new snapshot in the specified cluster from the specified + * source table. The cluster and the table must be in the same instance. + * + * Note: This is a private alpha release of Cloud Bigtable snapshots. This + * feature is not currently available to most Cloud Bigtable customers. This + * feature might be changed in backward-incompatible ways and is not + * recommended for production use. It is not subject to any SLA or deprecation + * policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. The unique name of the table to have the snapshot taken. + * Values are of the form + * `projects/{project}/instances/{instance}/tables/{table}`. + * @param {string} request.cluster + * Required. The name of the cluster where the snapshot will be created in. + * Values are of the form + * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * @param {string} request.snapshotId + * Required. The ID by which the new snapshot should be referred to within the + * parent cluster, e.g., `mysnapshot` of the form: + * `{@link -_.a-zA-Z0-9|_a-zA-Z0-9}*` rather than + * `projects/{project}/instances/{instance}/clusters/{cluster}/snapshots/mysnapshot`. + * @param {google.protobuf.Duration} request.ttl + * The amount of time that the new snapshot can stay active after it is + * created. Once 'ttl' expires, the snapshot will get deleted. The maximum + * amount of time a snapshot can stay active is 7 days. If 'ttl' is not + * specified, the default value of 24 hours will be used. + * @param {string} request.description + * Description of the snapshot. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.snapshot_table.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_SnapshotTable_async + */ snapshotTable( - request?: protos.google.bigtable.admin.v2.ISnapshotTableRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.ISnapshotTableRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.ISnapshotTableMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; snapshotTable( - request: protos.google.bigtable.admin.v2.ISnapshotTableRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ISnapshotTableRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.ISnapshotTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; snapshotTable( - request: protos.google.bigtable.admin.v2.ISnapshotTableRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ISnapshotTableRequest, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.ISnapshotTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; snapshotTable( - request?: protos.google.bigtable.admin.v2.ISnapshotTableRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.ISnapshotTableRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.ISnapshotTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.ISnapshotTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.ISnapshotTableMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); this.initialize(); return this.innerApiCalls.snapshotTable(request, options, callback); } -/** - * Check the status of the long running operation returned by `snapshotTable()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.snapshot_table.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_SnapshotTable_async - */ - async checkSnapshotTableProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `snapshotTable()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.snapshot_table.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_SnapshotTable_async + */ + async checkSnapshotTableProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.Snapshot, + protos.google.bigtable.admin.v2.SnapshotTableMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.snapshotTable, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.snapshotTable, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.Snapshot, + protos.google.bigtable.admin.v2.SnapshotTableMetadata + >; } -/** - * Starts creating a new Cloud Bigtable Backup. The returned backup - * {@link google.longrunning.Operation|long-running operation} can be used to - * track creation of the backup. The - * {@link google.longrunning.Operation.metadata|metadata} field type is - * {@link google.bigtable.admin.v2.CreateBackupMetadata|CreateBackupMetadata}. The - * {@link google.longrunning.Operation.response|response} field type is - * {@link google.bigtable.admin.v2.Backup|Backup}, if successful. Cancelling the - * returned operation will stop the creation and delete the backup. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. This must be one of the clusters in the instance in which this - * table is located. The backup will be stored in this cluster. Values are - * of the form `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param {string} request.backupId - * Required. The id of the backup to be created. The `backup_id` along with - * the parent `parent` are combined as {parent}/backups/{backup_id} to create - * the full backup name, of the form: - * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup_id}`. - * This string must be between 1 and 50 characters in length and match the - * regex {@link -_.a-zA-Z0-9|_a-zA-Z0-9}*. - * @param {google.bigtable.admin.v2.Backup} request.backup - * Required. The backup to create. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.create_backup.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CreateBackup_async - */ + /** + * Starts creating a new Cloud Bigtable Backup. The returned backup + * {@link google.longrunning.Operation|long-running operation} can be used to + * track creation of the backup. The + * {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.bigtable.admin.v2.CreateBackupMetadata|CreateBackupMetadata}. The + * {@link google.longrunning.Operation.response|response} field type is + * {@link google.bigtable.admin.v2.Backup|Backup}, if successful. Cancelling the + * returned operation will stop the creation and delete the backup. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. This must be one of the clusters in the instance in which this + * table is located. The backup will be stored in this cluster. Values are + * of the form `projects/{project}/instances/{instance}/clusters/{cluster}`. + * @param {string} request.backupId + * Required. The id of the backup to be created. The `backup_id` along with + * the parent `parent` are combined as {parent}/backups/{backup_id} to create + * the full backup name, of the form: + * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup_id}`. + * This string must be between 1 and 50 characters in length and match the + * regex {@link -_.a-zA-Z0-9|_a-zA-Z0-9}*. + * @param {google.bigtable.admin.v2.Backup} request.backup + * Required. The backup to create. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.create_backup.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CreateBackup_async + */ createBackup( - request?: protos.google.bigtable.admin.v2.ICreateBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.ICreateBackupRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICreateBackupMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; createBackup( - request: protos.google.bigtable.admin.v2.ICreateBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICreateBackupMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; createBackup( - request: protos.google.bigtable.admin.v2.ICreateBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICreateBackupRequest, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICreateBackupMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; createBackup( - request?: protos.google.bigtable.admin.v2.ICreateBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.ICreateBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICreateBackupMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICreateBackupMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICreateBackupMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.createBackup(request, options, callback); } -/** - * Check the status of the long running operation returned by `createBackup()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.create_backup.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CreateBackup_async - */ - async checkCreateBackupProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `createBackup()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.create_backup.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CreateBackup_async + */ + async checkCreateBackupProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.Backup, + protos.google.bigtable.admin.v2.CreateBackupMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createBackup, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.createBackup, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.Backup, + protos.google.bigtable.admin.v2.CreateBackupMetadata + >; } -/** - * Create a new table by restoring from a completed backup. The new table - * must be in the same project as the instance containing the backup. The - * returned table {@link google.longrunning.Operation|long-running operation} can - * be used to track the progress of the operation, and to cancel it. The - * {@link google.longrunning.Operation.metadata|metadata} field type is - * {@link google.bigtable.admin.RestoreTableMetadata|RestoreTableMetadata}. The - * {@link google.longrunning.Operation.response|response} type is - * {@link google.bigtable.admin.v2.Table|Table}, if successful. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the instance in which to create the restored - * table. This instance must be in the same project as the source backup. - * Values are of the form `projects//instances/`. - * @param {string} request.tableId - * Required. The id of the table to create and restore to. This - * table must not already exist. The `table_id` appended to - * `parent` forms the full table name of the form - * `projects//instances//tables/`. - * @param {string} request.backup - * Name of the backup from which to restore. Values are of the form - * `projects//instances//clusters//backups/`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.restore_table.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_RestoreTable_async - */ + /** + * Create a new table by restoring from a completed backup. The new table + * must be in the same project as the instance containing the backup. The + * returned table {@link google.longrunning.Operation|long-running operation} can + * be used to track the progress of the operation, and to cancel it. The + * {@link google.longrunning.Operation.metadata|metadata} field type is + * {@link google.bigtable.admin.RestoreTableMetadata|RestoreTableMetadata}. The + * {@link google.longrunning.Operation.response|response} type is + * {@link google.bigtable.admin.v2.Table|Table}, if successful. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the instance in which to create the restored + * table. This instance must be in the same project as the source backup. + * Values are of the form `projects//instances/`. + * @param {string} request.tableId + * Required. The id of the table to create and restore to. This + * table must not already exist. The `table_id` appended to + * `parent` forms the full table name of the form + * `projects//instances//tables/`. + * @param {string} request.backup + * Name of the backup from which to restore. Values are of the form + * `projects//instances//clusters//backups/`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.restore_table.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_RestoreTable_async + */ restoreTable( - request?: protos.google.bigtable.admin.v2.IRestoreTableRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.IRestoreTableRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IRestoreTableMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; restoreTable( - request: protos.google.bigtable.admin.v2.IRestoreTableRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IRestoreTableRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IRestoreTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; restoreTable( - request: protos.google.bigtable.admin.v2.IRestoreTableRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.IRestoreTableRequest, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IRestoreTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; restoreTable( - request?: protos.google.bigtable.admin.v2.IRestoreTableRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.IRestoreTableRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IRestoreTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IRestoreTableMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IRestoreTableMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.restoreTable(request, options, callback); } -/** - * Check the status of the long running operation returned by `restoreTable()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.restore_table.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_RestoreTable_async - */ - async checkRestoreTableProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `restoreTable()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.restore_table.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_RestoreTable_async + */ + async checkRestoreTableProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.Table, + protos.google.bigtable.admin.v2.RestoreTableMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.restoreTable, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.restoreTable, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.Table, + protos.google.bigtable.admin.v2.RestoreTableMetadata + >; } -/** - * Copy a Cloud Bigtable backup to a new backup in the destination cluster - * located in the destination instance and project. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The name of the destination cluster that will contain the backup - * copy. The cluster must already exist. Values are of the form: - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * @param {string} request.backupId - * Required. The id of the new backup. The `backup_id` along with `parent` - * are combined as `{parent}/backups/{backup_id}` to create the full backup - * name, of the form: - * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup_id}`. - * This string must be between 1 and 50 characters in length and match the - * regex `{@link -_.a-zA-Z0-9|_a-zA-Z0-9}*`. - * @param {string} request.sourceBackup - * Required. The source backup to be copied from. - * The source backup needs to be in READY state for it to be copied. - * Copying a copied backup is not allowed. - * Once CopyBackup is in progress, the source backup cannot be deleted or - * cleaned up on expiration until CopyBackup is finished. - * Values are of the form: - * `projects//instances//clusters//backups/`. - * @param {google.protobuf.Timestamp} request.expireTime - * Required. Required. The expiration time of the copied backup with - * microsecond granularity that must be at least 6 hours and at most 30 days - * from the time the request is received. Once the `expire_time` has - * passed, Cloud Bigtable will delete the backup and free the resources used - * by the backup. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is an object representing - * a long running operation. Its `promise()` method returns a promise - * you can `await` for. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.copy_backup.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CopyBackup_async - */ + /** + * Copy a Cloud Bigtable backup to a new backup in the destination cluster + * located in the destination instance and project. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The name of the destination cluster that will contain the backup + * copy. The cluster must already exist. Values are of the form: + * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * @param {string} request.backupId + * Required. The id of the new backup. The `backup_id` along with `parent` + * are combined as `{parent}/backups/{backup_id}` to create the full backup + * name, of the form: + * `projects/{project}/instances/{instance}/clusters/{cluster}/backups/{backup_id}`. + * This string must be between 1 and 50 characters in length and match the + * regex `{@link -_.a-zA-Z0-9|_a-zA-Z0-9}*`. + * @param {string} request.sourceBackup + * Required. The source backup to be copied from. + * The source backup needs to be in READY state for it to be copied. + * Copying a copied backup is not allowed. + * Once CopyBackup is in progress, the source backup cannot be deleted or + * cleaned up on expiration until CopyBackup is finished. + * Values are of the form: + * `projects//instances//clusters//backups/`. + * @param {google.protobuf.Timestamp} request.expireTime + * Required. Required. The expiration time of the copied backup with + * microsecond granularity that must be at least 6 hours and at most 30 days + * from the time the request is received. Once the `expire_time` has + * passed, Cloud Bigtable will delete the backup and free the resources used + * by the backup. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.copy_backup.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CopyBackup_async + */ copyBackup( - request?: protos.google.bigtable.admin.v2.ICopyBackupRequest, - options?: CallOptions): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>; + request?: protos.google.bigtable.admin.v2.ICopyBackupRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICopyBackupMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; copyBackup( - request: protos.google.bigtable.admin.v2.ICopyBackupRequest, - options: CallOptions, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICopyBackupRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICopyBackupMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; copyBackup( - request: protos.google.bigtable.admin.v2.ICopyBackupRequest, - callback: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): void; + request: protos.google.bigtable.admin.v2.ICopyBackupRequest, + callback: Callback< + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICopyBackupMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; copyBackup( - request?: protos.google.bigtable.admin.v2.ICopyBackupRequest, - optionsOrCallback?: CallOptions|Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>, - callback?: Callback< - LROperation, - protos.google.longrunning.IOperation|null|undefined, - {}|null|undefined>): - Promise<[ - LROperation, - protos.google.longrunning.IOperation|undefined, {}|undefined - ]>|void { + request?: protos.google.bigtable.admin.v2.ICopyBackupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICopyBackupMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICopyBackupMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICopyBackupMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.copyBackup(request, options, callback); } -/** - * Check the status of the long running operation returned by `copyBackup()`. - * @param {String} name - * The operation name that will be passed. - * @returns {Promise} - The promise which resolves to an object. - * The decoded operation object has result and metadata field to get information from. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.copy_backup.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CopyBackup_async - */ - async checkCopyBackupProgress(name: string): Promise>{ - const request = new operationsProtos.google.longrunning.GetOperationRequest({name}); + /** + * Check the status of the long running operation returned by `copyBackup()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.copy_backup.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_CopyBackup_async + */ + async checkCopyBackupProgress( + name: string + ): Promise< + LROperation< + protos.google.bigtable.admin.v2.Backup, + protos.google.bigtable.admin.v2.CopyBackupMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); const [operation] = await this.operationsClient.getOperation(request); - const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.copyBackup, gax.createDefaultBackoffSettings()); - return decodeOperation as LROperation; + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.copyBackup, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.bigtable.admin.v2.Backup, + protos.google.bigtable.admin.v2.CopyBackupMetadata + >; } - /** - * Lists all tables served from a specified instance. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the instance for which tables should be - * listed. Values are of the form `projects/{project}/instances/{instance}`. - * @param {google.bigtable.admin.v2.Table.View} request.view - * The view to be applied to the returned tables' fields. - * Only NAME_ONLY view (default), REPLICATION_VIEW and ENCRYPTION_VIEW are - * supported. - * @param {number} request.pageSize - * Maximum number of results per page. - * - * A page_size of zero lets the server choose the number of items to return. - * A page_size which is strictly positive will return at most that many items. - * A negative page_size will cause an error. - * - * Following the first request, subsequent paginated calls are not required - * to pass a page_size. If a page_size is set in subsequent calls, it must - * match the page_size given in the first request. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a previous call. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Table]{@link google.bigtable.admin.v2.Table}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listTablesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ + /** + * Lists all tables served from a specified instance. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the instance for which tables should be + * listed. Values are of the form `projects/{project}/instances/{instance}`. + * @param {google.bigtable.admin.v2.Table.View} request.view + * The view to be applied to the returned tables' fields. + * Only NAME_ONLY view (default), REPLICATION_VIEW and ENCRYPTION_VIEW are + * supported. + * @param {number} request.pageSize + * Maximum number of results per page. + * + * A page_size of zero lets the server choose the number of items to return. + * A page_size which is strictly positive will return at most that many items. + * A negative page_size will cause an error. + * + * Following the first request, subsequent paginated calls are not required + * to pass a page_size. If a page_size is set in subsequent calls, it must + * match the page_size given in the first request. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Table]{@link google.bigtable.admin.v2.Table}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listTablesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ listTables( - request?: protos.google.bigtable.admin.v2.IListTablesRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.ITable[], - protos.google.bigtable.admin.v2.IListTablesRequest|null, - protos.google.bigtable.admin.v2.IListTablesResponse - ]>; + request?: protos.google.bigtable.admin.v2.IListTablesRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.ITable[], + protos.google.bigtable.admin.v2.IListTablesRequest | null, + protos.google.bigtable.admin.v2.IListTablesResponse + ] + >; listTables( - request: protos.google.bigtable.admin.v2.IListTablesRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.bigtable.admin.v2.IListTablesRequest, - protos.google.bigtable.admin.v2.IListTablesResponse|null|undefined, - protos.google.bigtable.admin.v2.ITable>): void; + request: protos.google.bigtable.admin.v2.IListTablesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.bigtable.admin.v2.IListTablesRequest, + protos.google.bigtable.admin.v2.IListTablesResponse | null | undefined, + protos.google.bigtable.admin.v2.ITable + > + ): void; listTables( - request: protos.google.bigtable.admin.v2.IListTablesRequest, - callback: PaginationCallback< - protos.google.bigtable.admin.v2.IListTablesRequest, - protos.google.bigtable.admin.v2.IListTablesResponse|null|undefined, - protos.google.bigtable.admin.v2.ITable>): void; + request: protos.google.bigtable.admin.v2.IListTablesRequest, + callback: PaginationCallback< + protos.google.bigtable.admin.v2.IListTablesRequest, + protos.google.bigtable.admin.v2.IListTablesResponse | null | undefined, + protos.google.bigtable.admin.v2.ITable + > + ): void; listTables( - request?: protos.google.bigtable.admin.v2.IListTablesRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.bigtable.admin.v2.IListTablesRequest, - protos.google.bigtable.admin.v2.IListTablesResponse|null|undefined, - protos.google.bigtable.admin.v2.ITable>, - callback?: PaginationCallback< + request?: protos.google.bigtable.admin.v2.IListTablesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.bigtable.admin.v2.IListTablesRequest, - protos.google.bigtable.admin.v2.IListTablesResponse|null|undefined, - protos.google.bigtable.admin.v2.ITable>): - Promise<[ - protos.google.bigtable.admin.v2.ITable[], - protos.google.bigtable.admin.v2.IListTablesRequest|null, - protos.google.bigtable.admin.v2.IListTablesResponse - ]>|void { + | protos.google.bigtable.admin.v2.IListTablesResponse + | null + | undefined, + protos.google.bigtable.admin.v2.ITable + >, + callback?: PaginationCallback< + protos.google.bigtable.admin.v2.IListTablesRequest, + protos.google.bigtable.admin.v2.IListTablesResponse | null | undefined, + protos.google.bigtable.admin.v2.ITable + > + ): Promise< + [ + protos.google.bigtable.admin.v2.ITable[], + protos.google.bigtable.admin.v2.IListTablesRequest | null, + protos.google.bigtable.admin.v2.IListTablesResponse + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listTables(request, options, callback); } -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the instance for which tables should be - * listed. Values are of the form `projects/{project}/instances/{instance}`. - * @param {google.bigtable.admin.v2.Table.View} request.view - * The view to be applied to the returned tables' fields. - * Only NAME_ONLY view (default), REPLICATION_VIEW and ENCRYPTION_VIEW are - * supported. - * @param {number} request.pageSize - * Maximum number of results per page. - * - * A page_size of zero lets the server choose the number of items to return. - * A page_size which is strictly positive will return at most that many items. - * A negative page_size will cause an error. - * - * Following the first request, subsequent paginated calls are not required - * to pass a page_size. If a page_size is set in subsequent calls, it must - * match the page_size given in the first request. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a previous call. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Table]{@link google.bigtable.admin.v2.Table} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listTablesAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the instance for which tables should be + * listed. Values are of the form `projects/{project}/instances/{instance}`. + * @param {google.bigtable.admin.v2.Table.View} request.view + * The view to be applied to the returned tables' fields. + * Only NAME_ONLY view (default), REPLICATION_VIEW and ENCRYPTION_VIEW are + * supported. + * @param {number} request.pageSize + * Maximum number of results per page. + * + * A page_size of zero lets the server choose the number of items to return. + * A page_size which is strictly positive will return at most that many items. + * A negative page_size will cause an error. + * + * Following the first request, subsequent paginated calls are not required + * to pass a page_size. If a page_size is set in subsequent calls, it must + * match the page_size given in the first request. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Table]{@link google.bigtable.admin.v2.Table} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listTablesAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ listTablesStream( - request?: protos.google.bigtable.admin.v2.IListTablesRequest, - options?: CallOptions): - Transform{ + request?: protos.google.bigtable.admin.v2.IListTablesRequest, + options?: CallOptions + ): Transform { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const defaultCallSettings = this._defaults['listTables']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -2371,57 +2994,56 @@ export class BigtableTableAdminClient { ); } -/** - * Equivalent to `listTables`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the instance for which tables should be - * listed. Values are of the form `projects/{project}/instances/{instance}`. - * @param {google.bigtable.admin.v2.Table.View} request.view - * The view to be applied to the returned tables' fields. - * Only NAME_ONLY view (default), REPLICATION_VIEW and ENCRYPTION_VIEW are - * supported. - * @param {number} request.pageSize - * Maximum number of results per page. - * - * A page_size of zero lets the server choose the number of items to return. - * A page_size which is strictly positive will return at most that many items. - * A negative page_size will cause an error. - * - * Following the first request, subsequent paginated calls are not required - * to pass a page_size. If a page_size is set in subsequent calls, it must - * match the page_size given in the first request. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Table]{@link google.bigtable.admin.v2.Table}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.list_tables.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_ListTables_async - */ + /** + * Equivalent to `listTables`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the instance for which tables should be + * listed. Values are of the form `projects/{project}/instances/{instance}`. + * @param {google.bigtable.admin.v2.Table.View} request.view + * The view to be applied to the returned tables' fields. + * Only NAME_ONLY view (default), REPLICATION_VIEW and ENCRYPTION_VIEW are + * supported. + * @param {number} request.pageSize + * Maximum number of results per page. + * + * A page_size of zero lets the server choose the number of items to return. + * A page_size which is strictly positive will return at most that many items. + * A negative page_size will cause an error. + * + * Following the first request, subsequent paginated calls are not required + * to pass a page_size. If a page_size is set in subsequent calls, it must + * match the page_size given in the first request. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Table]{@link google.bigtable.admin.v2.Table}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.list_tables.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_ListTables_async + */ listTablesAsync( - request?: protos.google.bigtable.admin.v2.IListTablesRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.bigtable.admin.v2.IListTablesRequest, + options?: 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const defaultCallSettings = this._defaults['listTables']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -2431,138 +3053,149 @@ export class BigtableTableAdminClient { callSettings ) as AsyncIterable; } - /** - * Lists all snapshots associated with the specified cluster. - * - * Note: This is a private alpha release of Cloud Bigtable snapshots. This - * feature is not currently available to most Cloud Bigtable customers. This - * feature might be changed in backward-incompatible ways and is not - * recommended for production use. It is not subject to any SLA or deprecation - * policy. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the cluster for which snapshots should be - * listed. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * Use `{cluster} = '-'` to list snapshots for all clusters in an instance, - * e.g., `projects/{project}/instances/{instance}/clusters/-`. - * @param {number} request.pageSize - * The maximum number of snapshots to return per page. - * CURRENTLY UNIMPLEMENTED AND IGNORED. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a previous call. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Snapshot]{@link google.bigtable.admin.v2.Snapshot}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listSnapshotsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ + /** + * Lists all snapshots associated with the specified cluster. + * + * Note: This is a private alpha release of Cloud Bigtable snapshots. This + * feature is not currently available to most Cloud Bigtable customers. This + * feature might be changed in backward-incompatible ways and is not + * recommended for production use. It is not subject to any SLA or deprecation + * policy. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the cluster for which snapshots should be + * listed. Values are of the form + * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * Use `{cluster} = '-'` to list snapshots for all clusters in an instance, + * e.g., `projects/{project}/instances/{instance}/clusters/-`. + * @param {number} request.pageSize + * The maximum number of snapshots to return per page. + * CURRENTLY UNIMPLEMENTED AND IGNORED. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Snapshot]{@link google.bigtable.admin.v2.Snapshot}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listSnapshotsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ listSnapshots( - request?: protos.google.bigtable.admin.v2.IListSnapshotsRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.ISnapshot[], - protos.google.bigtable.admin.v2.IListSnapshotsRequest|null, - protos.google.bigtable.admin.v2.IListSnapshotsResponse - ]>; + request?: protos.google.bigtable.admin.v2.IListSnapshotsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.ISnapshot[], + protos.google.bigtable.admin.v2.IListSnapshotsRequest | null, + protos.google.bigtable.admin.v2.IListSnapshotsResponse + ] + >; listSnapshots( - request: protos.google.bigtable.admin.v2.IListSnapshotsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.bigtable.admin.v2.IListSnapshotsRequest, - protos.google.bigtable.admin.v2.IListSnapshotsResponse|null|undefined, - protos.google.bigtable.admin.v2.ISnapshot>): void; + request: protos.google.bigtable.admin.v2.IListSnapshotsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.bigtable.admin.v2.IListSnapshotsRequest, + protos.google.bigtable.admin.v2.IListSnapshotsResponse | null | undefined, + protos.google.bigtable.admin.v2.ISnapshot + > + ): void; listSnapshots( - request: protos.google.bigtable.admin.v2.IListSnapshotsRequest, - callback: PaginationCallback< - protos.google.bigtable.admin.v2.IListSnapshotsRequest, - protos.google.bigtable.admin.v2.IListSnapshotsResponse|null|undefined, - protos.google.bigtable.admin.v2.ISnapshot>): void; + request: protos.google.bigtable.admin.v2.IListSnapshotsRequest, + callback: PaginationCallback< + protos.google.bigtable.admin.v2.IListSnapshotsRequest, + protos.google.bigtable.admin.v2.IListSnapshotsResponse | null | undefined, + protos.google.bigtable.admin.v2.ISnapshot + > + ): void; listSnapshots( - request?: protos.google.bigtable.admin.v2.IListSnapshotsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< - protos.google.bigtable.admin.v2.IListSnapshotsRequest, - protos.google.bigtable.admin.v2.IListSnapshotsResponse|null|undefined, - protos.google.bigtable.admin.v2.ISnapshot>, - callback?: PaginationCallback< + request?: protos.google.bigtable.admin.v2.IListSnapshotsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.bigtable.admin.v2.IListSnapshotsRequest, - protos.google.bigtable.admin.v2.IListSnapshotsResponse|null|undefined, - protos.google.bigtable.admin.v2.ISnapshot>): - Promise<[ - protos.google.bigtable.admin.v2.ISnapshot[], - protos.google.bigtable.admin.v2.IListSnapshotsRequest|null, - protos.google.bigtable.admin.v2.IListSnapshotsResponse - ]>|void { + | protos.google.bigtable.admin.v2.IListSnapshotsResponse + | null + | undefined, + protos.google.bigtable.admin.v2.ISnapshot + >, + callback?: PaginationCallback< + protos.google.bigtable.admin.v2.IListSnapshotsRequest, + protos.google.bigtable.admin.v2.IListSnapshotsResponse | null | undefined, + protos.google.bigtable.admin.v2.ISnapshot + > + ): Promise< + [ + protos.google.bigtable.admin.v2.ISnapshot[], + protos.google.bigtable.admin.v2.IListSnapshotsRequest | null, + protos.google.bigtable.admin.v2.IListSnapshotsResponse + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listSnapshots(request, options, callback); } -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the cluster for which snapshots should be - * listed. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * Use `{cluster} = '-'` to list snapshots for all clusters in an instance, - * e.g., `projects/{project}/instances/{instance}/clusters/-`. - * @param {number} request.pageSize - * The maximum number of snapshots to return per page. - * CURRENTLY UNIMPLEMENTED AND IGNORED. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a previous call. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Snapshot]{@link google.bigtable.admin.v2.Snapshot} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listSnapshotsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the cluster for which snapshots should be + * listed. Values are of the form + * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * Use `{cluster} = '-'` to list snapshots for all clusters in an instance, + * e.g., `projects/{project}/instances/{instance}/clusters/-`. + * @param {number} request.pageSize + * The maximum number of snapshots to return per page. + * CURRENTLY UNIMPLEMENTED AND IGNORED. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a previous call. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Snapshot]{@link google.bigtable.admin.v2.Snapshot} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listSnapshotsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ listSnapshotsStream( - request?: protos.google.bigtable.admin.v2.IListSnapshotsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.bigtable.admin.v2.IListSnapshotsRequest, + options?: CallOptions + ): Transform { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const defaultCallSettings = this._defaults['listSnapshots']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -2573,49 +3206,48 @@ export class BigtableTableAdminClient { ); } -/** - * Equivalent to `listSnapshots`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The unique name of the cluster for which snapshots should be - * listed. Values are of the form - * `projects/{project}/instances/{instance}/clusters/{cluster}`. - * Use `{cluster} = '-'` to list snapshots for all clusters in an instance, - * e.g., `projects/{project}/instances/{instance}/clusters/-`. - * @param {number} request.pageSize - * The maximum number of snapshots to return per page. - * CURRENTLY UNIMPLEMENTED AND IGNORED. - * @param {string} request.pageToken - * The value of `next_page_token` returned by a 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Snapshot]{@link google.bigtable.admin.v2.Snapshot}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.list_snapshots.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_ListSnapshots_async - */ + /** + * Equivalent to `listSnapshots`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique name of the cluster for which snapshots should be + * listed. Values are of the form + * `projects/{project}/instances/{instance}/clusters/{cluster}`. + * Use `{cluster} = '-'` to list snapshots for all clusters in an instance, + * e.g., `projects/{project}/instances/{instance}/clusters/-`. + * @param {number} request.pageSize + * The maximum number of snapshots to return per page. + * CURRENTLY UNIMPLEMENTED AND IGNORED. + * @param {string} request.pageToken + * The value of `next_page_token` returned by a 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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Snapshot]{@link google.bigtable.admin.v2.Snapshot}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.list_snapshots.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_ListSnapshots_async + */ listSnapshotsAsync( - request?: protos.google.bigtable.admin.v2.IListSnapshotsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.bigtable.admin.v2.IListSnapshotsRequest, + options?: 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const defaultCallSettings = this._defaults['listSnapshots']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -2625,249 +3257,260 @@ export class BigtableTableAdminClient { callSettings ) as AsyncIterable; } - /** - * Lists Cloud Bigtable backups. Returns both completed and pending - * backups. - * - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The cluster to list backups from. Values are of the - * form `projects/{project}/instances/{instance}/clusters/{cluster}`. - * Use `{cluster} = '-'` to list backups for all clusters in an instance, - * e.g., `projects/{project}/instances/{instance}/clusters/-`. - * @param {string} request.filter - * A filter expression that filters backups listed in the response. - * The expression must specify the field name, a comparison operator, - * and the value that you want to use for filtering. The value must be a - * string, a number, or a boolean. The comparison operator must be - * <, >, <=, >=, !=, =, or :. Colon ':' represents a HAS operator which is - * roughly synonymous with equality. Filter rules are case insensitive. - * - * The fields eligible for filtering are: - * * `name` - * * `source_table` - * * `state` - * * `start_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `end_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `size_bytes` - * - * To filter on multiple expressions, provide each separate expression within - * parentheses. By default, each expression is an AND expression. However, - * you can include AND, OR, and NOT expressions explicitly. - * - * Some examples of using filters are: - * - * * `name:"exact"` --> The backup's name is the string "exact". - * * `name:howl` --> The backup's name contains the string "howl". - * * `source_table:prod` - * --> The source_table's name contains the string "prod". - * * `state:CREATING` --> The backup is pending creation. - * * `state:READY` --> The backup is fully created and ready for use. - * * `(name:howl) AND (start_time < \"2018-03-28T14:50:00Z\")` - * --> The backup name contains the string "howl" and start_time - * of the backup is before 2018-03-28T14:50:00Z. - * * `size_bytes > 10000000000` --> The backup's size is greater than 10GB - * @param {string} request.orderBy - * An expression for specifying the sort order of the results of the request. - * The string value should specify one or more fields in - * {@link google.bigtable.admin.v2.Backup|Backup}. The full syntax is described at - * https://aip.dev/132#ordering. - * - * Fields supported are: - * * name - * * source_table - * * expire_time - * * start_time - * * end_time - * * size_bytes - * * state - * - * For example, "start_time". The default sorting order is ascending. - * To specify descending order for the field, a suffix " desc" should - * be appended to the field name. For example, "start_time desc". - * Redundant space characters in the syntax are insigificant. - * - * If order_by is empty, results will be sorted by `start_time` in descending - * order starting from the most recently created backup. - * @param {number} request.pageSize - * Number of backups to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.bigtable.admin.v2.ListBackupsResponse.next_page_token|next_page_token} - * from a previous - * {@link google.bigtable.admin.v2.ListBackupsResponse|ListBackupsResponse} to the - * same `parent` and with the same `filter`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Promise} - The promise which resolves to an array. - * The first element of the array is Array of [Backup]{@link google.bigtable.admin.v2.Backup}. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed and will merge results from all the pages into this array. - * Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ + /** + * Lists Cloud Bigtable backups. Returns both completed and pending + * backups. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The cluster to list backups from. Values are of the + * form `projects/{project}/instances/{instance}/clusters/{cluster}`. + * Use `{cluster} = '-'` to list backups for all clusters in an instance, + * e.g., `projects/{project}/instances/{instance}/clusters/-`. + * @param {string} request.filter + * A filter expression that filters backups listed in the response. + * The expression must specify the field name, a comparison operator, + * and the value that you want to use for filtering. The value must be a + * string, a number, or a boolean. The comparison operator must be + * <, >, <=, >=, !=, =, or :. Colon ':' represents a HAS operator which is + * roughly synonymous with equality. Filter rules are case insensitive. + * + * The fields eligible for filtering are: + * * `name` + * * `source_table` + * * `state` + * * `start_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `end_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `size_bytes` + * + * To filter on multiple expressions, provide each separate expression within + * parentheses. By default, each expression is an AND expression. However, + * you can include AND, OR, and NOT expressions explicitly. + * + * Some examples of using filters are: + * + * * `name:"exact"` --> The backup's name is the string "exact". + * * `name:howl` --> The backup's name contains the string "howl". + * * `source_table:prod` + * --> The source_table's name contains the string "prod". + * * `state:CREATING` --> The backup is pending creation. + * * `state:READY` --> The backup is fully created and ready for use. + * * `(name:howl) AND (start_time < \"2018-03-28T14:50:00Z\")` + * --> The backup name contains the string "howl" and start_time + * of the backup is before 2018-03-28T14:50:00Z. + * * `size_bytes > 10000000000` --> The backup's size is greater than 10GB + * @param {string} request.orderBy + * An expression for specifying the sort order of the results of the request. + * The string value should specify one or more fields in + * {@link google.bigtable.admin.v2.Backup|Backup}. The full syntax is described at + * https://aip.dev/132#ordering. + * + * Fields supported are: + * * name + * * source_table + * * expire_time + * * start_time + * * end_time + * * size_bytes + * * state + * + * For example, "start_time". The default sorting order is ascending. + * To specify descending order for the field, a suffix " desc" should + * be appended to the field name. For example, "start_time desc". + * Redundant space characters in the syntax are insigificant. + * + * If order_by is empty, results will be sorted by `start_time` in descending + * order starting from the most recently created backup. + * @param {number} request.pageSize + * Number of backups to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.bigtable.admin.v2.ListBackupsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.bigtable.admin.v2.ListBackupsResponse|ListBackupsResponse} to the + * same `parent` and with the same `filter`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is Array of [Backup]{@link google.bigtable.admin.v2.Backup}. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed and will merge results from all the pages into this array. + * Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ listBackups( - request?: protos.google.bigtable.admin.v2.IListBackupsRequest, - options?: CallOptions): - Promise<[ - protos.google.bigtable.admin.v2.IBackup[], - protos.google.bigtable.admin.v2.IListBackupsRequest|null, - protos.google.bigtable.admin.v2.IListBackupsResponse - ]>; + request?: protos.google.bigtable.admin.v2.IListBackupsRequest, + options?: CallOptions + ): Promise< + [ + protos.google.bigtable.admin.v2.IBackup[], + protos.google.bigtable.admin.v2.IListBackupsRequest | null, + protos.google.bigtable.admin.v2.IListBackupsResponse + ] + >; listBackups( - request: protos.google.bigtable.admin.v2.IListBackupsRequest, - options: CallOptions, - callback: PaginationCallback< - protos.google.bigtable.admin.v2.IListBackupsRequest, - protos.google.bigtable.admin.v2.IListBackupsResponse|null|undefined, - protos.google.bigtable.admin.v2.IBackup>): void; + request: protos.google.bigtable.admin.v2.IListBackupsRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.bigtable.admin.v2.IListBackupsRequest, + protos.google.bigtable.admin.v2.IListBackupsResponse | null | undefined, + protos.google.bigtable.admin.v2.IBackup + > + ): void; listBackups( - request: protos.google.bigtable.admin.v2.IListBackupsRequest, - callback: PaginationCallback< - protos.google.bigtable.admin.v2.IListBackupsRequest, - protos.google.bigtable.admin.v2.IListBackupsResponse|null|undefined, - protos.google.bigtable.admin.v2.IBackup>): void; + request: protos.google.bigtable.admin.v2.IListBackupsRequest, + callback: PaginationCallback< + protos.google.bigtable.admin.v2.IListBackupsRequest, + protos.google.bigtable.admin.v2.IListBackupsResponse | null | undefined, + protos.google.bigtable.admin.v2.IBackup + > + ): void; listBackups( - request?: protos.google.bigtable.admin.v2.IListBackupsRequest, - optionsOrCallback?: CallOptions|PaginationCallback< + request?: protos.google.bigtable.admin.v2.IListBackupsRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< protos.google.bigtable.admin.v2.IListBackupsRequest, - protos.google.bigtable.admin.v2.IListBackupsResponse|null|undefined, - protos.google.bigtable.admin.v2.IBackup>, - callback?: PaginationCallback< - protos.google.bigtable.admin.v2.IListBackupsRequest, - protos.google.bigtable.admin.v2.IListBackupsResponse|null|undefined, - protos.google.bigtable.admin.v2.IBackup>): - Promise<[ - protos.google.bigtable.admin.v2.IBackup[], - protos.google.bigtable.admin.v2.IListBackupsRequest|null, - protos.google.bigtable.admin.v2.IListBackupsResponse - ]>|void { + | protos.google.bigtable.admin.v2.IListBackupsResponse + | null + | undefined, + protos.google.bigtable.admin.v2.IBackup + >, + callback?: PaginationCallback< + protos.google.bigtable.admin.v2.IListBackupsRequest, + protos.google.bigtable.admin.v2.IListBackupsResponse | null | undefined, + protos.google.bigtable.admin.v2.IBackup + > + ): Promise< + [ + protos.google.bigtable.admin.v2.IBackup[], + protos.google.bigtable.admin.v2.IListBackupsRequest | null, + protos.google.bigtable.admin.v2.IListBackupsResponse + ] + > | void { request = request || {}; let options: CallOptions; if (typeof optionsOrCallback === 'function' && callback === undefined) { callback = optionsOrCallback; options = {}; - } - else { + } else { options = optionsOrCallback as CallOptions; } 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); this.initialize(); return this.innerApiCalls.listBackups(request, options, callback); } -/** - * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The cluster to list backups from. Values are of the - * form `projects/{project}/instances/{instance}/clusters/{cluster}`. - * Use `{cluster} = '-'` to list backups for all clusters in an instance, - * e.g., `projects/{project}/instances/{instance}/clusters/-`. - * @param {string} request.filter - * A filter expression that filters backups listed in the response. - * The expression must specify the field name, a comparison operator, - * and the value that you want to use for filtering. The value must be a - * string, a number, or a boolean. The comparison operator must be - * <, >, <=, >=, !=, =, or :. Colon ':' represents a HAS operator which is - * roughly synonymous with equality. Filter rules are case insensitive. - * - * The fields eligible for filtering are: - * * `name` - * * `source_table` - * * `state` - * * `start_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `end_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `size_bytes` - * - * To filter on multiple expressions, provide each separate expression within - * parentheses. By default, each expression is an AND expression. However, - * you can include AND, OR, and NOT expressions explicitly. - * - * Some examples of using filters are: - * - * * `name:"exact"` --> The backup's name is the string "exact". - * * `name:howl` --> The backup's name contains the string "howl". - * * `source_table:prod` - * --> The source_table's name contains the string "prod". - * * `state:CREATING` --> The backup is pending creation. - * * `state:READY` --> The backup is fully created and ready for use. - * * `(name:howl) AND (start_time < \"2018-03-28T14:50:00Z\")` - * --> The backup name contains the string "howl" and start_time - * of the backup is before 2018-03-28T14:50:00Z. - * * `size_bytes > 10000000000` --> The backup's size is greater than 10GB - * @param {string} request.orderBy - * An expression for specifying the sort order of the results of the request. - * The string value should specify one or more fields in - * {@link google.bigtable.admin.v2.Backup|Backup}. The full syntax is described at - * https://aip.dev/132#ordering. - * - * Fields supported are: - * * name - * * source_table - * * expire_time - * * start_time - * * end_time - * * size_bytes - * * state - * - * For example, "start_time". The default sorting order is ascending. - * To specify descending order for the field, a suffix " desc" should - * be appended to the field name. For example, "start_time desc". - * Redundant space characters in the syntax are insigificant. - * - * If order_by is empty, results will be sorted by `start_time` in descending - * order starting from the most recently created backup. - * @param {number} request.pageSize - * Number of backups to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.bigtable.admin.v2.ListBackupsResponse.next_page_token|next_page_token} - * from a previous - * {@link google.bigtable.admin.v2.ListBackupsResponse|ListBackupsResponse} to the - * same `parent` and with the same `filter`. - * @param {object} [options] - * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. - * @returns {Stream} - * An object stream which emits an object representing [Backup]{@link google.bigtable.admin.v2.Backup} on 'data' event. - * The client library will perform auto-pagination by default: it will call the API as many - * times as needed. Note that it can affect your quota. - * We recommend using `listBackupsAsync()` - * method described below for async iteration which you can stop as needed. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - */ + /** + * Equivalent to `method.name.toCamelCase()`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The cluster to list backups from. Values are of the + * form `projects/{project}/instances/{instance}/clusters/{cluster}`. + * Use `{cluster} = '-'` to list backups for all clusters in an instance, + * e.g., `projects/{project}/instances/{instance}/clusters/-`. + * @param {string} request.filter + * A filter expression that filters backups listed in the response. + * The expression must specify the field name, a comparison operator, + * and the value that you want to use for filtering. The value must be a + * string, a number, or a boolean. The comparison operator must be + * <, >, <=, >=, !=, =, or :. Colon ':' represents a HAS operator which is + * roughly synonymous with equality. Filter rules are case insensitive. + * + * The fields eligible for filtering are: + * * `name` + * * `source_table` + * * `state` + * * `start_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `end_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `size_bytes` + * + * To filter on multiple expressions, provide each separate expression within + * parentheses. By default, each expression is an AND expression. However, + * you can include AND, OR, and NOT expressions explicitly. + * + * Some examples of using filters are: + * + * * `name:"exact"` --> The backup's name is the string "exact". + * * `name:howl` --> The backup's name contains the string "howl". + * * `source_table:prod` + * --> The source_table's name contains the string "prod". + * * `state:CREATING` --> The backup is pending creation. + * * `state:READY` --> The backup is fully created and ready for use. + * * `(name:howl) AND (start_time < \"2018-03-28T14:50:00Z\")` + * --> The backup name contains the string "howl" and start_time + * of the backup is before 2018-03-28T14:50:00Z. + * * `size_bytes > 10000000000` --> The backup's size is greater than 10GB + * @param {string} request.orderBy + * An expression for specifying the sort order of the results of the request. + * The string value should specify one or more fields in + * {@link google.bigtable.admin.v2.Backup|Backup}. The full syntax is described at + * https://aip.dev/132#ordering. + * + * Fields supported are: + * * name + * * source_table + * * expire_time + * * start_time + * * end_time + * * size_bytes + * * state + * + * For example, "start_time". The default sorting order is ascending. + * To specify descending order for the field, a suffix " desc" should + * be appended to the field name. For example, "start_time desc". + * Redundant space characters in the syntax are insigificant. + * + * If order_by is empty, results will be sorted by `start_time` in descending + * order starting from the most recently created backup. + * @param {number} request.pageSize + * Number of backups to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.bigtable.admin.v2.ListBackupsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.bigtable.admin.v2.ListBackupsResponse|ListBackupsResponse} to the + * same `parent` and with the same `filter`. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Stream} + * An object stream which emits an object representing [Backup]{@link google.bigtable.admin.v2.Backup} on 'data' event. + * The client library will perform auto-pagination by default: it will call the API as many + * times as needed. Note that it can affect your quota. + * We recommend using `listBackupsAsync()` + * method described below for async iteration which you can stop as needed. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + */ listBackupsStream( - request?: protos.google.bigtable.admin.v2.IListBackupsRequest, - options?: CallOptions): - Transform{ + request?: protos.google.bigtable.admin.v2.IListBackupsRequest, + options?: CallOptions + ): Transform { 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -2878,107 +3521,106 @@ export class BigtableTableAdminClient { ); } -/** - * Equivalent to `listBackups`, but returns an iterable object. - * - * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. - * @param {Object} request - * The request object that will be sent. - * @param {string} request.parent - * Required. The cluster to list backups from. Values are of the - * form `projects/{project}/instances/{instance}/clusters/{cluster}`. - * Use `{cluster} = '-'` to list backups for all clusters in an instance, - * e.g., `projects/{project}/instances/{instance}/clusters/-`. - * @param {string} request.filter - * A filter expression that filters backups listed in the response. - * The expression must specify the field name, a comparison operator, - * and the value that you want to use for filtering. The value must be a - * string, a number, or a boolean. The comparison operator must be - * <, >, <=, >=, !=, =, or :. Colon ':' represents a HAS operator which is - * roughly synonymous with equality. Filter rules are case insensitive. - * - * The fields eligible for filtering are: - * * `name` - * * `source_table` - * * `state` - * * `start_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `end_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) - * * `size_bytes` - * - * To filter on multiple expressions, provide each separate expression within - * parentheses. By default, each expression is an AND expression. However, - * you can include AND, OR, and NOT expressions explicitly. - * - * Some examples of using filters are: - * - * * `name:"exact"` --> The backup's name is the string "exact". - * * `name:howl` --> The backup's name contains the string "howl". - * * `source_table:prod` - * --> The source_table's name contains the string "prod". - * * `state:CREATING` --> The backup is pending creation. - * * `state:READY` --> The backup is fully created and ready for use. - * * `(name:howl) AND (start_time < \"2018-03-28T14:50:00Z\")` - * --> The backup name contains the string "howl" and start_time - * of the backup is before 2018-03-28T14:50:00Z. - * * `size_bytes > 10000000000` --> The backup's size is greater than 10GB - * @param {string} request.orderBy - * An expression for specifying the sort order of the results of the request. - * The string value should specify one or more fields in - * {@link google.bigtable.admin.v2.Backup|Backup}. The full syntax is described at - * https://aip.dev/132#ordering. - * - * Fields supported are: - * * name - * * source_table - * * expire_time - * * start_time - * * end_time - * * size_bytes - * * state - * - * For example, "start_time". The default sorting order is ascending. - * To specify descending order for the field, a suffix " desc" should - * be appended to the field name. For example, "start_time desc". - * Redundant space characters in the syntax are insigificant. - * - * If order_by is empty, results will be sorted by `start_time` in descending - * order starting from the most recently created backup. - * @param {number} request.pageSize - * Number of backups to be returned in the response. If 0 or - * less, defaults to the server's maximum allowed page size. - * @param {string} request.pageToken - * If non-empty, `page_token` should contain a - * {@link google.bigtable.admin.v2.ListBackupsResponse.next_page_token|next_page_token} - * from a previous - * {@link google.bigtable.admin.v2.ListBackupsResponse|ListBackupsResponse} to the - * same `parent` and with the same `filter`. - * @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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). - * When you iterate the returned iterable, each element will be an object representing - * [Backup]{@link google.bigtable.admin.v2.Backup}. The API will be called under the hood as needed, once per the page, - * so you can stop the iteration when you don't need more results. - * Please see the - * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) - * for more details and examples. - * @example include:samples/generated/v2/bigtable_table_admin.list_backups.js - * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_ListBackups_async - */ + /** + * Equivalent to `listBackups`, but returns an iterable object. + * + * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The cluster to list backups from. Values are of the + * form `projects/{project}/instances/{instance}/clusters/{cluster}`. + * Use `{cluster} = '-'` to list backups for all clusters in an instance, + * e.g., `projects/{project}/instances/{instance}/clusters/-`. + * @param {string} request.filter + * A filter expression that filters backups listed in the response. + * The expression must specify the field name, a comparison operator, + * and the value that you want to use for filtering. The value must be a + * string, a number, or a boolean. The comparison operator must be + * <, >, <=, >=, !=, =, or :. Colon ':' represents a HAS operator which is + * roughly synonymous with equality. Filter rules are case insensitive. + * + * The fields eligible for filtering are: + * * `name` + * * `source_table` + * * `state` + * * `start_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `end_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `expire_time` (and values are of the format YYYY-MM-DDTHH:MM:SSZ) + * * `size_bytes` + * + * To filter on multiple expressions, provide each separate expression within + * parentheses. By default, each expression is an AND expression. However, + * you can include AND, OR, and NOT expressions explicitly. + * + * Some examples of using filters are: + * + * * `name:"exact"` --> The backup's name is the string "exact". + * * `name:howl` --> The backup's name contains the string "howl". + * * `source_table:prod` + * --> The source_table's name contains the string "prod". + * * `state:CREATING` --> The backup is pending creation. + * * `state:READY` --> The backup is fully created and ready for use. + * * `(name:howl) AND (start_time < \"2018-03-28T14:50:00Z\")` + * --> The backup name contains the string "howl" and start_time + * of the backup is before 2018-03-28T14:50:00Z. + * * `size_bytes > 10000000000` --> The backup's size is greater than 10GB + * @param {string} request.orderBy + * An expression for specifying the sort order of the results of the request. + * The string value should specify one or more fields in + * {@link google.bigtable.admin.v2.Backup|Backup}. The full syntax is described at + * https://aip.dev/132#ordering. + * + * Fields supported are: + * * name + * * source_table + * * expire_time + * * start_time + * * end_time + * * size_bytes + * * state + * + * For example, "start_time". The default sorting order is ascending. + * To specify descending order for the field, a suffix " desc" should + * be appended to the field name. For example, "start_time desc". + * Redundant space characters in the syntax are insigificant. + * + * If order_by is empty, results will be sorted by `start_time` in descending + * order starting from the most recently created backup. + * @param {number} request.pageSize + * Number of backups to be returned in the response. If 0 or + * less, defaults to the server's maximum allowed page size. + * @param {string} request.pageToken + * If non-empty, `page_token` should contain a + * {@link google.bigtable.admin.v2.ListBackupsResponse.next_page_token|next_page_token} + * from a previous + * {@link google.bigtable.admin.v2.ListBackupsResponse|ListBackupsResponse} to the + * same `parent` and with the same `filter`. + * @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 allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols). + * When you iterate the returned iterable, each element will be an object representing + * [Backup]{@link google.bigtable.admin.v2.Backup}. The API will be called under the hood as needed, once per the page, + * so you can stop the iteration when you don't need more results. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination) + * for more details and examples. + * @example include:samples/generated/v2/bigtable_table_admin.list_backups.js + * region_tag:bigtableadmin_v2_generated_BigtableTableAdmin_ListBackups_async + */ listBackupsAsync( - request?: protos.google.bigtable.admin.v2.IListBackupsRequest, - options?: CallOptions): - AsyncIterable{ + request?: protos.google.bigtable.admin.v2.IListBackupsRequest, + options?: 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.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + parent: request.parent || '', + }); const defaultCallSettings = this._defaults['listBackups']; const callSettings = defaultCallSettings.merge(options); this.initialize(); @@ -2988,7 +3630,7 @@ export class BigtableTableAdminClient { callSettings ) as AsyncIterable; } -/** + /** * Gets information about a location. * * @param {Object} request @@ -3029,7 +3671,7 @@ export class BigtableTableAdminClient { return this.locationsClient.getLocation(request, options, callback); } -/** + /** * Lists information about the supported locations for this service. Returns an iterable object. * * `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand. @@ -3068,7 +3710,7 @@ export class BigtableTableAdminClient { return this.locationsClient.listLocationsAsync(request, options); } -/** + /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. @@ -3184,7 +3826,7 @@ export class BigtableTableAdminClient { * await client.cancelOperation({name: ''}); * ``` */ - cancelOperation( + cancelOperation( request: protos.google.longrunning.CancelOperationRequest, options?: | gax.CallOptions @@ -3257,7 +3899,7 @@ export class BigtableTableAdminClient { * @param {string} app_profile * @returns {string} Resource name string. */ - appProfilePath(project:string,instance:string,appProfile:string) { + appProfilePath(project: string, instance: string, appProfile: string) { return this.pathTemplates.appProfilePathTemplate.render({ project: project, instance: instance, @@ -3273,7 +3915,8 @@ export class BigtableTableAdminClient { * @returns {string} A string representing the project. */ matchProjectFromAppProfileName(appProfileName: string) { - return this.pathTemplates.appProfilePathTemplate.match(appProfileName).project; + return this.pathTemplates.appProfilePathTemplate.match(appProfileName) + .project; } /** @@ -3284,7 +3927,8 @@ export class BigtableTableAdminClient { * @returns {string} A string representing the instance. */ matchInstanceFromAppProfileName(appProfileName: string) { - return this.pathTemplates.appProfilePathTemplate.match(appProfileName).instance; + return this.pathTemplates.appProfilePathTemplate.match(appProfileName) + .instance; } /** @@ -3295,7 +3939,8 @@ export class BigtableTableAdminClient { * @returns {string} A string representing the app_profile. */ matchAppProfileFromAppProfileName(appProfileName: string) { - return this.pathTemplates.appProfilePathTemplate.match(appProfileName).app_profile; + return this.pathTemplates.appProfilePathTemplate.match(appProfileName) + .app_profile; } /** @@ -3307,7 +3952,12 @@ export class BigtableTableAdminClient { * @param {string} backup * @returns {string} Resource name string. */ - backupPath(project:string,instance:string,cluster:string,backup:string) { + backupPath( + project: string, + instance: string, + cluster: string, + backup: string + ) { return this.pathTemplates.backupPathTemplate.render({ project: project, instance: instance, @@ -3368,7 +4018,7 @@ export class BigtableTableAdminClient { * @param {string} cluster * @returns {string} Resource name string. */ - clusterPath(project:string,instance:string,cluster:string) { + clusterPath(project: string, instance: string, cluster: string) { return this.pathTemplates.clusterPathTemplate.render({ project: project, instance: instance, @@ -3418,7 +4068,12 @@ export class BigtableTableAdminClient { * @param {string} hot_tablet * @returns {string} Resource name string. */ - hotTabletPath(project:string,instance:string,cluster:string,hotTablet:string) { + hotTabletPath( + project: string, + instance: string, + cluster: string, + hotTablet: string + ) { return this.pathTemplates.hotTabletPathTemplate.render({ project: project, instance: instance, @@ -3435,7 +4090,8 @@ export class BigtableTableAdminClient { * @returns {string} A string representing the project. */ matchProjectFromHotTabletName(hotTabletName: string) { - return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName).project; + return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName) + .project; } /** @@ -3446,7 +4102,8 @@ export class BigtableTableAdminClient { * @returns {string} A string representing the instance. */ matchInstanceFromHotTabletName(hotTabletName: string) { - return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName).instance; + return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName) + .instance; } /** @@ -3457,7 +4114,8 @@ export class BigtableTableAdminClient { * @returns {string} A string representing the cluster. */ matchClusterFromHotTabletName(hotTabletName: string) { - return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName).cluster; + return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName) + .cluster; } /** @@ -3468,7 +4126,8 @@ export class BigtableTableAdminClient { * @returns {string} A string representing the hot_tablet. */ matchHotTabletFromHotTabletName(hotTabletName: string) { - return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName).hot_tablet; + return this.pathTemplates.hotTabletPathTemplate.match(hotTabletName) + .hot_tablet; } /** @@ -3478,7 +4137,7 @@ export class BigtableTableAdminClient { * @param {string} instance * @returns {string} Resource name string. */ - instancePath(project:string,instance:string) { + instancePath(project: string, instance: string) { return this.pathTemplates.instancePathTemplate.render({ project: project, instance: instance, @@ -3516,7 +4175,12 @@ export class BigtableTableAdminClient { * @param {string} snapshot * @returns {string} Resource name string. */ - snapshotPath(project:string,instance:string,cluster:string,snapshot:string) { + snapshotPath( + project: string, + instance: string, + cluster: string, + snapshot: string + ) { return this.pathTemplates.snapshotPathTemplate.render({ project: project, instance: instance, @@ -3577,7 +4241,7 @@ export class BigtableTableAdminClient { * @param {string} table * @returns {string} Resource name string. */ - tablePath(project:string,instance:string,table:string) { + tablePath(project: string, instance: string, table: string) { return this.pathTemplates.tablePathTemplate.render({ project: project, instance: instance, diff --git a/src/v2/index.ts b/src/v2/index.ts index 28ff835fe..5209e7a0d 100644 --- a/src/v2/index.ts +++ b/src/v2/index.ts @@ -18,3 +18,4 @@ export {BigtableInstanceAdminClient} from './bigtable_instance_admin_client'; export {BigtableTableAdminClient} from './bigtable_table_admin_client'; +export {BigtableClient} from './bigtable_client'; diff --git a/test/gapic_bigtable_instance_admin_v2.ts b/test/gapic_bigtable_instance_admin_v2.ts index 838b3780f..2c07901b8 100644 --- a/test/gapic_bigtable_instance_admin_v2.ts +++ b/test/gapic_bigtable_instance_admin_v2.ts @@ -20,3552 +20,4750 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; +import {describe, it} from 'mocha'; import * as bigtableinstanceadminModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + 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); +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.BigtableInstanceAdminClient', () => { - it('has servicePath', () => { - const servicePath = bigtableinstanceadminModule.v2.BigtableInstanceAdminClient.servicePath; - assert(servicePath); + it('has servicePath', () => { + const servicePath = + bigtableinstanceadminModule.v2.BigtableInstanceAdminClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + bigtableinstanceadminModule.v2.BigtableInstanceAdminClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = + bigtableinstanceadminModule.v2.BigtableInstanceAdminClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.bigtableInstanceAdminStub, undefined); + await client.initialize(); + assert(client.bigtableInstanceAdminStub); + }); + + it('has close method for the initialized client', done => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + assert(client.bigtableInstanceAdminStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.bigtableInstanceAdminStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); + }); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('getInstance', () => { + it('invokes getInstance without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetInstanceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Instance() + ); + client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); + const [response] = await client.getInstance(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('has apiEndpoint', () => { - const apiEndpoint = bigtableinstanceadminModule.v2.BigtableInstanceAdminClient.apiEndpoint; - assert(apiEndpoint); + it('invokes getInstance without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetInstanceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Instance() + ); + client.innerApiCalls.getInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getInstance( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IInstance | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('has port', () => { - const port = bigtableinstanceadminModule.v2.BigtableInstanceAdminClient.port; - assert(port); - assert(typeof port === 'number'); + it('invokes getInstance with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetInstanceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getInstance = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getInstance(request), expectedError); + assert( + (client.innerApiCalls.getInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('should create a client with no option', () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient(); - assert(client); + it('invokes getInstance with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetInstanceRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getInstance(request), expectedError); + }); + }); + + describe('listInstances', () => { + it('invokes listInstances without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListInstancesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListInstancesResponse() + ); + client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); + const [response] = await client.listInstances(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listInstances as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - it('should create a client with gRPC fallback', () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - fallback: true, - }); - assert(client); + it('invokes listInstances without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListInstancesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListInstancesResponse() + ); + client.innerApiCalls.listInstances = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listInstances( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IListInstancesResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listInstances as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - it('has initialize method and supports deferred initialization', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.bigtableInstanceAdminStub, undefined); - await client.initialize(); - assert(client.bigtableInstanceAdminStub); - }); - - it('has close method for the initialized client', done => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.bigtableInstanceAdminStub); - client.close().then(() => { - done(); - }); - }); - - it('has close method for the non-initialized client', done => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.bigtableInstanceAdminStub, undefined); - client.close().then(() => { - done(); - }); - }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); - }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); - }); - - describe('getInstance', () => { - it('invokes getInstance without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetInstanceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Instance()); - client.innerApiCalls.getInstance = stubSimpleCall(expectedResponse); - const [response] = await client.getInstance(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getInstance without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetInstanceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Instance()); - client.innerApiCalls.getInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getInstance( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getInstance with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetInstanceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getInstance(request), expectedError); - assert((client.innerApiCalls.getInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getInstance with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetInstanceRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getInstance(request), expectedError); - }); - }); - - describe('listInstances', () => { - it('invokes listInstances without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListInstancesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.ListInstancesResponse()); - client.innerApiCalls.listInstances = stubSimpleCall(expectedResponse); - const [response] = await client.listInstances(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listInstances as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listInstances without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListInstancesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.ListInstancesResponse()); - client.innerApiCalls.listInstances = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listInstances( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IListInstancesResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listInstances as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listInstances with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListInstancesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listInstances = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listInstances(request), expectedError); - assert((client.innerApiCalls.listInstances as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listInstances with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListInstancesRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.listInstances(request), expectedError); - }); - }); - - describe('updateInstance', () => { - it('invokes updateInstance without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.Instance()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Instance()); - client.innerApiCalls.updateInstance = stubSimpleCall(expectedResponse); - const [response] = await client.updateInstance(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateInstance without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.Instance()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Instance()); - client.innerApiCalls.updateInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateInstance( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IInstance|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateInstance with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.Instance()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateInstance(request), expectedError); - assert((client.innerApiCalls.updateInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateInstance with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.Instance()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateInstance(request), expectedError); - }); - }); - - describe('deleteInstance', () => { - it('invokes deleteInstance without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteInstanceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteInstance = stubSimpleCall(expectedResponse); - const [response] = await client.deleteInstance(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteInstance without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteInstanceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteInstance = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteInstance( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteInstance with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteInstanceRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteInstance = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteInstance(request), expectedError); - assert((client.innerApiCalls.deleteInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteInstance with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteInstanceRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteInstance(request), expectedError); - }); - }); - - describe('getCluster', () => { - it('invokes getCluster without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetClusterRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Cluster()); - client.innerApiCalls.getCluster = stubSimpleCall(expectedResponse); - const [response] = await client.getCluster(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getCluster without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetClusterRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Cluster()); - client.innerApiCalls.getCluster = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getCluster( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.ICluster|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getCluster with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetClusterRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getCluster = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getCluster(request), expectedError); - assert((client.innerApiCalls.getCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getCluster with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetClusterRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getCluster(request), expectedError); - }); - }); - - describe('listClusters', () => { - it('invokes listClusters without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListClustersRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.ListClustersResponse()); - client.innerApiCalls.listClusters = stubSimpleCall(expectedResponse); - const [response] = await client.listClusters(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listClusters as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listClusters without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListClustersRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.ListClustersResponse()); - client.innerApiCalls.listClusters = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listClusters( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IListClustersResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listClusters as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listClusters with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListClustersRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listClusters = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listClusters(request), expectedError); - assert((client.innerApiCalls.listClusters as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listClusters with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListClustersRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.listClusters(request), expectedError); - }); - }); - - describe('deleteCluster', () => { - it('invokes deleteCluster without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteClusterRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteCluster = stubSimpleCall(expectedResponse); - const [response] = await client.deleteCluster(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteCluster without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteClusterRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteCluster = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteCluster( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteCluster with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteClusterRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteCluster = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteCluster(request), expectedError); - assert((client.innerApiCalls.deleteCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteCluster with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteClusterRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteCluster(request), expectedError); - }); - }); - - describe('createAppProfile', () => { - it('invokes createAppProfile without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateAppProfileRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()); - client.innerApiCalls.createAppProfile = stubSimpleCall(expectedResponse); - const [response] = await client.createAppProfile(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createAppProfile without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateAppProfileRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()); - client.innerApiCalls.createAppProfile = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createAppProfile( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IAppProfile|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createAppProfile with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateAppProfileRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createAppProfile = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createAppProfile(request), expectedError); - assert((client.innerApiCalls.createAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createAppProfile with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateAppProfileRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createAppProfile(request), expectedError); - }); - }); - - describe('getAppProfile', () => { - it('invokes getAppProfile without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetAppProfileRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()); - client.innerApiCalls.getAppProfile = stubSimpleCall(expectedResponse); - const [response] = await client.getAppProfile(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getAppProfile without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetAppProfileRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()); - client.innerApiCalls.getAppProfile = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getAppProfile( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IAppProfile|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getAppProfile with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetAppProfileRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getAppProfile = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getAppProfile(request), expectedError); - assert((client.innerApiCalls.getAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getAppProfile with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetAppProfileRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getAppProfile(request), expectedError); - }); - }); - - describe('deleteAppProfile', () => { - it('invokes deleteAppProfile without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteAppProfileRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteAppProfile = stubSimpleCall(expectedResponse); - const [response] = await client.deleteAppProfile(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteAppProfile without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteAppProfileRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteAppProfile = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteAppProfile( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteAppProfile with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteAppProfileRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteAppProfile = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteAppProfile(request), expectedError); - assert((client.innerApiCalls.deleteAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteAppProfile with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteAppProfileRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteAppProfile(request), expectedError); - }); - }); - - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getIamPolicy with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getIamPolicy with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); - }); - - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes setIamPolicy with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes setIamPolicy with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); - }); - - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes testIamPermissions with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes testIamPermissions with closed client', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); - }); - - describe('createInstance', () => { - it('invokes createInstance without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateInstanceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.createInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createInstance without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateInstanceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createInstance with call error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateInstanceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createInstance(request), expectedError); - assert((client.innerApiCalls.createInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createInstance with LRO error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateInstanceRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createInstance(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateInstanceProgress without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateInstanceProgress with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('partialUpdateInstance', () => { - it('invokes partialUpdateInstance without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.PartialUpdateInstanceRequest()); - request.instance = {}; - request.instance.name = ''; - const expectedHeaderRequestParams = "instance.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.partialUpdateInstance = stubLongRunningCall(expectedResponse); - const [operation] = await client.partialUpdateInstance(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.partialUpdateInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes partialUpdateInstance without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.PartialUpdateInstanceRequest()); - request.instance = {}; - request.instance.name = ''; - const expectedHeaderRequestParams = "instance.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.partialUpdateInstance = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.partialUpdateInstance( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.partialUpdateInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes partialUpdateInstance with call error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.PartialUpdateInstanceRequest()); - request.instance = {}; - request.instance.name = ''; - const expectedHeaderRequestParams = "instance.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.partialUpdateInstance = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.partialUpdateInstance(request), expectedError); - assert((client.innerApiCalls.partialUpdateInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes partialUpdateInstance with LRO error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.PartialUpdateInstanceRequest()); - request.instance = {}; - request.instance.name = ''; - const expectedHeaderRequestParams = "instance.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.partialUpdateInstance = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.partialUpdateInstance(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.partialUpdateInstance as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPartialUpdateInstanceProgress without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPartialUpdateInstanceProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPartialUpdateInstanceProgress with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPartialUpdateInstanceProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('createCluster', () => { - it('invokes createCluster without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateClusterRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.createCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createCluster without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateClusterRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createCluster with call error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateClusterRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createCluster(request), expectedError); - assert((client.innerApiCalls.createCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createCluster with LRO error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateClusterRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createCluster(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkCreateClusterProgress without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkCreateClusterProgress with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateCluster', () => { - it('invokes updateCluster without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.Cluster()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCluster without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.Cluster()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateCluster with call error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.Cluster()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateCluster(request), expectedError); - assert((client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateCluster with LRO error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.Cluster()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateCluster(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateClusterProgress without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateClusterProgress with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('partialUpdateCluster', () => { - it('invokes partialUpdateCluster without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.PartialUpdateClusterRequest()); - request.cluster = {}; - request.cluster.name = ''; - const expectedHeaderRequestParams = "cluster.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.partialUpdateCluster = stubLongRunningCall(expectedResponse); - const [operation] = await client.partialUpdateCluster(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.partialUpdateCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes partialUpdateCluster without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.PartialUpdateClusterRequest()); - request.cluster = {}; - request.cluster.name = ''; - const expectedHeaderRequestParams = "cluster.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.partialUpdateCluster = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.partialUpdateCluster( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.partialUpdateCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes partialUpdateCluster with call error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.PartialUpdateClusterRequest()); - request.cluster = {}; - request.cluster.name = ''; - const expectedHeaderRequestParams = "cluster.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.partialUpdateCluster = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.partialUpdateCluster(request), expectedError); - assert((client.innerApiCalls.partialUpdateCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes partialUpdateCluster with LRO error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.PartialUpdateClusterRequest()); - request.cluster = {}; - request.cluster.name = ''; - const expectedHeaderRequestParams = "cluster.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.partialUpdateCluster = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.partialUpdateCluster(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.partialUpdateCluster as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkPartialUpdateClusterProgress without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkPartialUpdateClusterProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkPartialUpdateClusterProgress with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkPartialUpdateClusterProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('updateAppProfile', () => { - it('invokes updateAppProfile without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UpdateAppProfileRequest()); - request.appProfile = {}; - request.appProfile.name = ''; - const expectedHeaderRequestParams = "app_profile.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateAppProfile = stubLongRunningCall(expectedResponse); - const [operation] = await client.updateAppProfile(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateAppProfile without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UpdateAppProfileRequest()); - request.appProfile = {}; - request.appProfile.name = ''; - const expectedHeaderRequestParams = "app_profile.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.updateAppProfile = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateAppProfile( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes updateAppProfile with call error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UpdateAppProfileRequest()); - request.appProfile = {}; - request.appProfile.name = ''; - const expectedHeaderRequestParams = "app_profile.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAppProfile = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.updateAppProfile(request), expectedError); - assert((client.innerApiCalls.updateAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes updateAppProfile with LRO error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UpdateAppProfileRequest()); - request.appProfile = {}; - request.appProfile.name = ''; - const expectedHeaderRequestParams = "app_profile.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateAppProfile = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.updateAppProfile(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.updateAppProfile as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkUpdateAppProfileProgress without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUpdateAppProfileProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); - - it('invokes checkUpdateAppProfileProgress with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); - - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUpdateAppProfileProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - }); - - describe('listAppProfiles', () => { - it('invokes listAppProfiles without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListAppProfilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - ]; - client.innerApiCalls.listAppProfiles = stubSimpleCall(expectedResponse); - const [response] = await client.listAppProfiles(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listAppProfiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listAppProfiles without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListAppProfilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - ]; - client.innerApiCalls.listAppProfiles = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listAppProfiles( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IAppProfile[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listAppProfiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listAppProfiles with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListAppProfilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listAppProfiles = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listAppProfiles(request), expectedError); - assert((client.innerApiCalls.listAppProfiles as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listAppProfilesStream without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListAppProfilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - ]; - client.descriptors.page.listAppProfiles.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listAppProfilesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.bigtable.admin.v2.AppProfile[] = []; - stream.on('data', (response: protos.google.bigtable.admin.v2.AppProfile) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listAppProfiles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAppProfiles, request)); - assert.strictEqual( - (client.descriptors.page.listAppProfiles.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listAppProfilesStream with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListAppProfilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listAppProfiles.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listAppProfilesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.bigtable.admin.v2.AppProfile[] = []; - stream.on('data', (response: protos.google.bigtable.admin.v2.AppProfile) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listAppProfiles.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listAppProfiles, request)); - assert.strictEqual( - (client.descriptors.page.listAppProfiles.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listAppProfiles without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListAppProfilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), - ]; - client.descriptors.page.listAppProfiles.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.bigtable.admin.v2.IAppProfile[] = []; - const iterable = client.listAppProfilesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listInstances with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListInstancesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listInstances = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listInstances(request), expectedError); + assert( + (client.innerApiCalls.listInstances as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listInstances with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListInstancesRequest() + ); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.listInstances(request), expectedError); + }); + }); + + describe('updateInstance', () => { + it('invokes updateInstance without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.Instance() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Instance() + ); + client.innerApiCalls.updateInstance = stubSimpleCall(expectedResponse); + const [response] = await client.updateInstance(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateInstance without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.Instance() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Instance() + ); + client.innerApiCalls.updateInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateInstance( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IInstance | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listAppProfiles.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listAppProfiles.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listAppProfiles with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListAppProfilesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listAppProfiles.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listAppProfilesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.bigtable.admin.v2.IAppProfile[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listAppProfiles.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listAppProfiles.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - - describe('listHotTablets', () => { - it('invokes listHotTablets without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListHotTabletsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - ]; - client.innerApiCalls.listHotTablets = stubSimpleCall(expectedResponse); - const [response] = await client.listHotTablets(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listHotTablets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listHotTablets without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListHotTabletsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - ]; - client.innerApiCalls.listHotTablets = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listHotTablets( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IHotTablet[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listHotTablets as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes listHotTablets with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListHotTabletsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listHotTablets = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listHotTablets(request), expectedError); - assert((client.innerApiCalls.listHotTablets as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listHotTabletsStream without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListHotTabletsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - ]; - client.descriptors.page.listHotTablets.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listHotTabletsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.bigtable.admin.v2.HotTablet[] = []; - stream.on('data', (response: protos.google.bigtable.admin.v2.HotTablet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listHotTablets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHotTablets, request)); - assert.strictEqual( - (client.descriptors.page.listHotTablets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('invokes listHotTabletsStream with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListHotTabletsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listHotTablets.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listHotTabletsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.bigtable.admin.v2.HotTablet[] = []; - stream.on('data', (response: protos.google.bigtable.admin.v2.HotTablet) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listHotTablets.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listHotTablets, request)); - assert.strictEqual( - (client.descriptors.page.listHotTablets.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listHotTablets without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListHotTabletsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), - ]; - client.descriptors.page.listHotTablets.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.bigtable.admin.v2.IHotTablet[] = []; - const iterable = client.listHotTabletsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateInstance with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.Instance() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateInstance = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateInstance(request), expectedError); + assert( + (client.innerApiCalls.updateInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateInstance with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.Instance() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateInstance(request), expectedError); + }); + }); + + describe('deleteInstance', () => { + it('invokes deleteInstance without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteInstanceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteInstance = stubSimpleCall(expectedResponse); + const [response] = await client.deleteInstance(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteInstance without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteInstanceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteInstance = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteInstance( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listHotTablets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listHotTablets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listHotTablets with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListHotTabletsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listHotTablets.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listHotTabletsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.bigtable.admin.v2.IHotTablet[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listHotTablets.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listHotTablets.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteInstance with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteInstanceRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteInstance = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteInstance(request), expectedError); + assert( + (client.innerApiCalls.deleteInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteInstance with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteInstanceRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteInstance(request), expectedError); + }); + }); + + describe('getCluster', () => { + it('invokes getCluster without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetClusterRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Cluster() + ); + client.innerApiCalls.getCluster = stubSimpleCall(expectedResponse); + const [response] = await client.getCluster(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getCluster without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetClusterRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Cluster() + ); + client.innerApiCalls.getCluster = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getCluster( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.ICluster | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); - }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getCluster with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetClusterRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getCluster = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getCluster(request), expectedError); + assert( + (client.innerApiCalls.getCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getCluster with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetClusterRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getCluster(request), expectedError); + }); + }); + + describe('listClusters', () => { + it('invokes listClusters without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListClustersRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListClustersResponse() + ); + client.innerApiCalls.listClusters = stubSimpleCall(expectedResponse); + const [response] = await client.listClusters(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listClusters as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listClusters without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListClustersRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListClustersResponse() + ); + client.innerApiCalls.listClusters = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listClusters( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IListClustersResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - }); - - describe('Path templates', () => { - - describe('appProfile', () => { - const fakePath = "/rendered/path/appProfile"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - app_profile: "appProfileValue", - }; - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.appProfilePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.appProfilePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('appProfilePath', () => { - const result = client.appProfilePath("projectValue", "instanceValue", "appProfileValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.appProfilePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAppProfileName', () => { - const result = client.matchProjectFromAppProfileName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.appProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromAppProfileName', () => { - const result = client.matchInstanceFromAppProfileName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.appProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAppProfileFromAppProfileName', () => { - const result = client.matchAppProfileFromAppProfileName(fakePath); - assert.strictEqual(result, "appProfileValue"); - assert((client.pathTemplates.appProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('backup', () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - cluster: "clusterValue", - backup: "backupValue", - }; - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.backupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPath', () => { - const result = client.backupPath("projectValue", "instanceValue", "clusterValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromBackupName', () => { - const result = client.matchInstanceFromBackupName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClusterFromBackupName', () => { - const result = client.matchClusterFromBackupName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('cluster', () => { - const fakePath = "/rendered/path/cluster"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - cluster: "clusterValue", - }; - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.clusterPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.clusterPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('clusterPath', () => { - const result = client.clusterPath("projectValue", "instanceValue", "clusterValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.clusterPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromClusterName', () => { - const result = client.matchProjectFromClusterName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromClusterName', () => { - const result = client.matchInstanceFromClusterName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClusterFromClusterName', () => { - const result = client.matchClusterFromClusterName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('hotTablet', () => { - const fakePath = "/rendered/path/hotTablet"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - cluster: "clusterValue", - hot_tablet: "hotTabletValue", - }; - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.hotTabletPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hotTabletPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hotTabletPath', () => { - const result = client.hotTabletPath("projectValue", "instanceValue", "clusterValue", "hotTabletValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hotTabletPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHotTabletName', () => { - const result = client.matchProjectFromHotTabletName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hotTabletPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromHotTabletName', () => { - const result = client.matchInstanceFromHotTabletName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.hotTabletPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClusterFromHotTabletName', () => { - const result = client.matchClusterFromHotTabletName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.hotTabletPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHotTabletFromHotTabletName', () => { - const result = client.matchHotTabletFromHotTabletName(fakePath); - assert.strictEqual(result, "hotTabletValue"); - assert((client.pathTemplates.hotTabletPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('instance', () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - }; - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('project', () => { - const fakePath = "/rendered/path/project"; - const expectedParameters = { - project: "projectValue", - }; - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.projectPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.projectPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('projectPath', () => { - const result = client.projectPath("projectValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.projectPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromProjectName', () => { - const result = client.matchProjectFromProjectName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.projectPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('snapshot', () => { - const fakePath = "/rendered/path/snapshot"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - cluster: "clusterValue", - snapshot: "snapshotValue", - }; - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.snapshotPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.snapshotPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('snapshotPath', () => { - const result = client.snapshotPath("projectValue", "instanceValue", "clusterValue", "snapshotValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.snapshotPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSnapshotName', () => { - const result = client.matchProjectFromSnapshotName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromSnapshotName', () => { - const result = client.matchInstanceFromSnapshotName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClusterFromSnapshotName', () => { - const result = client.matchClusterFromSnapshotName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSnapshotFromSnapshotName', () => { - const result = client.matchSnapshotFromSnapshotName(fakePath); - assert.strictEqual(result, "snapshotValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('table', () => { - const fakePath = "/rendered/path/table"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - table: "tableValue", - }; - const client = new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tablePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tablePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tablePath', () => { - const result = client.tablePath("projectValue", "instanceValue", "tableValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tablePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTableName', () => { - const result = client.matchProjectFromTableName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromTableName', () => { - const result = client.matchInstanceFromTableName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.tablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTableFromTableName', () => { - const result = client.matchTableFromTableName(fakePath); - assert.strictEqual(result, "tableValue"); - assert((client.pathTemplates.tablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listClusters as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listClusters with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListClustersRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listClusters = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listClusters(request), expectedError); + assert( + (client.innerApiCalls.listClusters as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listClusters with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListClustersRequest() + ); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.listClusters(request), expectedError); + }); + }); + + describe('deleteCluster', () => { + it('invokes deleteCluster without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteClusterRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteCluster = stubSimpleCall(expectedResponse); + const [response] = await client.deleteCluster(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteCluster without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteClusterRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteCluster = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteCluster( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteCluster with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteClusterRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteCluster = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteCluster(request), expectedError); + assert( + (client.innerApiCalls.deleteCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteCluster with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteClusterRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteCluster(request), expectedError); + }); + }); + + describe('createAppProfile', () => { + it('invokes createAppProfile without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateAppProfileRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.AppProfile() + ); + client.innerApiCalls.createAppProfile = stubSimpleCall(expectedResponse); + const [response] = await client.createAppProfile(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createAppProfile without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateAppProfileRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.AppProfile() + ); + client.innerApiCalls.createAppProfile = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createAppProfile( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IAppProfile | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createAppProfile with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateAppProfileRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createAppProfile = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createAppProfile(request), expectedError); + assert( + (client.innerApiCalls.createAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createAppProfile with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateAppProfileRequest() + ); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createAppProfile(request), expectedError); + }); + }); + + describe('getAppProfile', () => { + it('invokes getAppProfile without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetAppProfileRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.AppProfile() + ); + client.innerApiCalls.getAppProfile = stubSimpleCall(expectedResponse); + const [response] = await client.getAppProfile(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getAppProfile without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetAppProfileRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.AppProfile() + ); + client.innerApiCalls.getAppProfile = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getAppProfile( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IAppProfile | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getAppProfile with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetAppProfileRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getAppProfile = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getAppProfile(request), expectedError); + assert( + (client.innerApiCalls.getAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getAppProfile with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetAppProfileRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getAppProfile(request), expectedError); + }); + }); + + describe('deleteAppProfile', () => { + it('invokes deleteAppProfile without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteAppProfileRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteAppProfile = stubSimpleCall(expectedResponse); + const [response] = await client.deleteAppProfile(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteAppProfile without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteAppProfileRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteAppProfile = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteAppProfile( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes deleteAppProfile with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteAppProfileRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteAppProfile = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteAppProfile(request), expectedError); + assert( + (client.innerApiCalls.deleteAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes deleteAppProfile with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteAppProfileRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteAppProfile(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getIamPolicy without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes getIamPolicy with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert( + (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes getIamPolicy with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes setIamPolicy without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes setIamPolicy with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert( + (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes setIamPolicy with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes testIamPermissions without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.ITestIamPermissionsResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes testIamPermissions with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert( + (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes testIamPermissions with closed client', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createInstance', () => { + it('invokes createInstance without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateInstanceRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createInstance without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateInstanceRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.ICreateInstanceMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.ICreateInstanceMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createInstance with call error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateInstanceRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.createInstance(request), expectedError); + assert( + (client.innerApiCalls.createInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createInstance with LRO error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateInstanceRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createInstance = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.createInstance(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.createInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes checkCreateInstanceProgress without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateInstanceProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateInstanceProgress with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkCreateInstanceProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('partialUpdateInstance', () => { + it('invokes partialUpdateInstance without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.PartialUpdateInstanceRequest() + ); + request.instance = {}; + request.instance.name = ''; + const expectedHeaderRequestParams = 'instance.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.partialUpdateInstance = + stubLongRunningCall(expectedResponse); + const [operation] = await client.partialUpdateInstance(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.partialUpdateInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes partialUpdateInstance without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.PartialUpdateInstanceRequest() + ); + request.instance = {}; + request.instance.name = ''; + const expectedHeaderRequestParams = 'instance.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.partialUpdateInstance = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.partialUpdateInstance( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IUpdateInstanceMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.IInstance, + protos.google.bigtable.admin.v2.IUpdateInstanceMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.partialUpdateInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes partialUpdateInstance with call error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.PartialUpdateInstanceRequest() + ); + request.instance = {}; + request.instance.name = ''; + const expectedHeaderRequestParams = 'instance.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.partialUpdateInstance = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.partialUpdateInstance(request), + expectedError + ); + assert( + (client.innerApiCalls.partialUpdateInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes partialUpdateInstance with LRO error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.PartialUpdateInstanceRequest() + ); + request.instance = {}; + request.instance.name = ''; + const expectedHeaderRequestParams = 'instance.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.partialUpdateInstance = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.partialUpdateInstance(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.partialUpdateInstance as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes checkPartialUpdateInstanceProgress without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPartialUpdateInstanceProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPartialUpdateInstanceProgress with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkPartialUpdateInstanceProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createCluster', () => { + it('invokes createCluster without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateClusterRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createCluster without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateClusterRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.ICreateClusterMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.ICreateClusterMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes createCluster with call error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateClusterRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createCluster = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.createCluster(request), expectedError); + assert( + (client.innerApiCalls.createCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes createCluster with LRO error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateClusterRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createCluster = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.createCluster(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.createCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes checkCreateClusterProgress without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateClusterProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkCreateClusterProgress with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkCreateClusterProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateCluster', () => { + it('invokes updateCluster without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.Cluster() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateCluster without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.Cluster() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IUpdateClusterMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IUpdateClusterMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateCluster with call error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.Cluster() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCluster = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.updateCluster(request), expectedError); + assert( + (client.innerApiCalls.updateCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateCluster with LRO error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.Cluster() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateCluster = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.updateCluster(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.updateCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes checkUpdateClusterProgress without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateClusterProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateClusterProgress with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkUpdateClusterProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('partialUpdateCluster', () => { + it('invokes partialUpdateCluster without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.PartialUpdateClusterRequest() + ); + request.cluster = {}; + request.cluster.name = ''; + const expectedHeaderRequestParams = 'cluster.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.partialUpdateCluster = + stubLongRunningCall(expectedResponse); + const [operation] = await client.partialUpdateCluster(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.partialUpdateCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes partialUpdateCluster without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.PartialUpdateClusterRequest() + ); + request.cluster = {}; + request.cluster.name = ''; + const expectedHeaderRequestParams = 'cluster.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.partialUpdateCluster = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.partialUpdateCluster( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IPartialUpdateClusterMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.ICluster, + protos.google.bigtable.admin.v2.IPartialUpdateClusterMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.partialUpdateCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes partialUpdateCluster with call error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.PartialUpdateClusterRequest() + ); + request.cluster = {}; + request.cluster.name = ''; + const expectedHeaderRequestParams = 'cluster.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.partialUpdateCluster = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.partialUpdateCluster(request), expectedError); + assert( + (client.innerApiCalls.partialUpdateCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes partialUpdateCluster with LRO error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.PartialUpdateClusterRequest() + ); + request.cluster = {}; + request.cluster.name = ''; + const expectedHeaderRequestParams = 'cluster.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.partialUpdateCluster = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.partialUpdateCluster(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.partialUpdateCluster as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes checkPartialUpdateClusterProgress without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkPartialUpdateClusterProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkPartialUpdateClusterProgress with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkPartialUpdateClusterProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('updateAppProfile', () => { + it('invokes updateAppProfile without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UpdateAppProfileRequest() + ); + request.appProfile = {}; + request.appProfile.name = ''; + const expectedHeaderRequestParams = 'app_profile.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateAppProfile = + stubLongRunningCall(expectedResponse); + const [operation] = await client.updateAppProfile(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateAppProfile without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UpdateAppProfileRequest() + ); + request.appProfile = {}; + request.appProfile.name = ''; + const expectedHeaderRequestParams = 'app_profile.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.updateAppProfile = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateAppProfile( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IUpdateAppProfileMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.IAppProfile, + protos.google.bigtable.admin.v2.IUpdateAppProfileMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes updateAppProfile with call error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UpdateAppProfileRequest() + ); + request.appProfile = {}; + request.appProfile.name = ''; + const expectedHeaderRequestParams = 'app_profile.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAppProfile = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.updateAppProfile(request), expectedError); + assert( + (client.innerApiCalls.updateAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes updateAppProfile with LRO error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UpdateAppProfileRequest() + ); + request.appProfile = {}; + request.appProfile.name = ''; + const expectedHeaderRequestParams = 'app_profile.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateAppProfile = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.updateAppProfile(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.updateAppProfile as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes checkUpdateAppProfileProgress without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUpdateAppProfileProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkUpdateAppProfileProgress with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkUpdateAppProfileProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listAppProfiles', () => { + it('invokes listAppProfiles without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListAppProfilesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + ]; + client.innerApiCalls.listAppProfiles = stubSimpleCall(expectedResponse); + const [response] = await client.listAppProfiles(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listAppProfiles as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listAppProfiles without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListAppProfilesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + ]; + client.innerApiCalls.listAppProfiles = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listAppProfiles( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IAppProfile[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listAppProfiles as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listAppProfiles with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListAppProfilesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listAppProfiles = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listAppProfiles(request), expectedError); + assert( + (client.innerApiCalls.listAppProfiles as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listAppProfilesStream without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListAppProfilesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + ]; + client.descriptors.page.listAppProfiles.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listAppProfilesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.bigtable.admin.v2.AppProfile[] = []; + stream.on( + 'data', + (response: protos.google.bigtable.admin.v2.AppProfile) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listAppProfiles.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAppProfiles, request) + ); + assert.strictEqual( + ( + client.descriptors.page.listAppProfiles.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listAppProfilesStream with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListAppProfilesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listAppProfiles.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listAppProfilesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.bigtable.admin.v2.AppProfile[] = []; + stream.on( + 'data', + (response: protos.google.bigtable.admin.v2.AppProfile) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listAppProfiles.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listAppProfiles, request) + ); + assert.strictEqual( + ( + client.descriptors.page.listAppProfiles.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listAppProfiles without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListAppProfilesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + generateSampleMessage(new protos.google.bigtable.admin.v2.AppProfile()), + ]; + client.descriptors.page.listAppProfiles.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.bigtable.admin.v2.IAppProfile[] = []; + const iterable = client.listAppProfilesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listAppProfiles.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert.strictEqual( + ( + client.descriptors.page.listAppProfiles.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listAppProfiles with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListAppProfilesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listAppProfiles.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listAppProfilesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.bigtable.admin.v2.IAppProfile[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listAppProfiles.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert.strictEqual( + ( + client.descriptors.page.listAppProfiles.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listHotTablets', () => { + it('invokes listHotTablets without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListHotTabletsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + ]; + client.innerApiCalls.listHotTablets = stubSimpleCall(expectedResponse); + const [response] = await client.listHotTablets(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listHotTablets as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listHotTablets without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListHotTabletsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + ]; + client.innerApiCalls.listHotTablets = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listHotTablets( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IHotTablet[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listHotTablets as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes listHotTablets with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListHotTabletsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listHotTablets = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listHotTablets(request), expectedError); + assert( + (client.innerApiCalls.listHotTablets as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes listHotTabletsStream without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListHotTabletsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + ]; + client.descriptors.page.listHotTablets.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listHotTabletsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.bigtable.admin.v2.HotTablet[] = []; + stream.on( + 'data', + (response: protos.google.bigtable.admin.v2.HotTablet) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listHotTablets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHotTablets, request) + ); + assert.strictEqual( + ( + client.descriptors.page.listHotTablets.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('invokes listHotTabletsStream with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListHotTabletsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listHotTablets.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listHotTabletsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.bigtable.admin.v2.HotTablet[] = []; + stream.on( + 'data', + (response: protos.google.bigtable.admin.v2.HotTablet) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listHotTablets.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listHotTablets, request) + ); + assert.strictEqual( + ( + client.descriptors.page.listHotTablets.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listHotTablets without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListHotTabletsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + generateSampleMessage(new protos.google.bigtable.admin.v2.HotTablet()), + ]; + client.descriptors.page.listHotTablets.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.bigtable.admin.v2.IHotTablet[] = []; + const iterable = client.listHotTabletsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listHotTablets.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert.strictEqual( + ( + client.descriptors.page.listHotTablets.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + + it('uses async iteration with listHotTablets with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListHotTabletsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listHotTablets.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listHotTabletsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.bigtable.admin.v2.IHotTablet[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listHotTablets.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert.strictEqual( + ( + client.descriptors.page.listHotTablets.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); + }); + it('invokes getLocation with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert.strictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert.strictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + it('invokes getOperation with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes cancelOperation without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); + }); + it('invokes cancelOperation with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('appProfile', () => { + const fakePath = '/rendered/path/appProfile'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + app_profile: 'appProfileValue', + }; + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.appProfilePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.appProfilePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('appProfilePath', () => { + const result = client.appProfilePath( + 'projectValue', + 'instanceValue', + 'appProfileValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.appProfilePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAppProfileName', () => { + const result = client.matchProjectFromAppProfileName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.appProfilePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromAppProfileName', () => { + const result = client.matchInstanceFromAppProfileName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.appProfilePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAppProfileFromAppProfileName', () => { + const result = client.matchAppProfileFromAppProfileName(fakePath); + assert.strictEqual(result, 'appProfileValue'); + assert( + (client.pathTemplates.appProfilePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('backup', () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + cluster: 'clusterValue', + backup: 'backupValue', + }; + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.backupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupPath', () => { + const result = client.backupPath( + 'projectValue', + 'instanceValue', + 'clusterValue', + 'backupValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromBackupName', () => { + const result = client.matchInstanceFromBackupName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchClusterFromBackupName', () => { + const result = client.matchClusterFromBackupName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('cluster', () => { + const fakePath = '/rendered/path/cluster'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + cluster: 'clusterValue', + }; + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.clusterPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.clusterPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('clusterPath', () => { + const result = client.clusterPath( + 'projectValue', + 'instanceValue', + 'clusterValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.clusterPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromClusterName', () => { + const result = client.matchProjectFromClusterName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromClusterName', () => { + const result = client.matchInstanceFromClusterName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchClusterFromClusterName', () => { + const result = client.matchClusterFromClusterName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('hotTablet', () => { + const fakePath = '/rendered/path/hotTablet'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + cluster: 'clusterValue', + hot_tablet: 'hotTabletValue', + }; + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.hotTabletPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hotTabletPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hotTabletPath', () => { + const result = client.hotTabletPath( + 'projectValue', + 'instanceValue', + 'clusterValue', + 'hotTabletValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hotTabletPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromHotTabletName', () => { + const result = client.matchProjectFromHotTabletName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hotTabletPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromHotTabletName', () => { + const result = client.matchInstanceFromHotTabletName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.hotTabletPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchClusterFromHotTabletName', () => { + const result = client.matchClusterFromHotTabletName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.hotTabletPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchHotTabletFromHotTabletName', () => { + const result = client.matchHotTabletFromHotTabletName(fakePath); + assert.strictEqual(result, 'hotTabletValue'); + assert( + (client.pathTemplates.hotTabletPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('instance', () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + }; + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath('projectValue', 'instanceValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('project', () => { + const fakePath = '/rendered/path/project'; + const expectedParameters = { + project: 'projectValue', + }; + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.projectPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.projectPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('projectPath', () => { + const result = client.projectPath('projectValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.projectPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromProjectName', () => { + const result = client.matchProjectFromProjectName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.projectPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('snapshot', () => { + const fakePath = '/rendered/path/snapshot'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + cluster: 'clusterValue', + snapshot: 'snapshotValue', + }; + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.snapshotPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.snapshotPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('snapshotPath', () => { + const result = client.snapshotPath( + 'projectValue', + 'instanceValue', + 'clusterValue', + 'snapshotValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.snapshotPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromSnapshotName', () => { + const result = client.matchProjectFromSnapshotName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromSnapshotName', () => { + const result = client.matchInstanceFromSnapshotName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchClusterFromSnapshotName', () => { + const result = client.matchClusterFromSnapshotName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchSnapshotFromSnapshotName', () => { + const result = client.matchSnapshotFromSnapshotName(fakePath); + assert.strictEqual(result, 'snapshotValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('table', () => { + const fakePath = '/rendered/path/table'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + table: 'tableValue', + }; + const client = + new bigtableinstanceadminModule.v2.BigtableInstanceAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tablePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tablePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tablePath', () => { + const result = client.tablePath( + 'projectValue', + 'instanceValue', + 'tableValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tablePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromTableName', () => { + const result = client.matchProjectFromTableName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromTableName', () => { + const result = client.matchInstanceFromTableName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.tablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchTableFromTableName', () => { + const result = client.matchTableFromTableName(fakePath); + assert.strictEqual(result, 'tableValue'); + assert( + (client.pathTemplates.tablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); }); + }); }); diff --git a/test/gapic_bigtable_table_admin_v2.ts b/test/gapic_bigtable_table_admin_v2.ts index 9ea587fee..d6377a62f 100644 --- a/test/gapic_bigtable_table_admin_v2.ts +++ b/test/gapic_bigtable_table_admin_v2.ts @@ -20,3931 +20,5096 @@ import * as protos from '../protos/protos'; import * as assert from 'assert'; import * as sinon from 'sinon'; import {SinonStub} from 'sinon'; -import { describe, it } from 'mocha'; +import {describe, it} from 'mocha'; import * as bigtabletableadminModule from '../src'; import {PassThrough} from 'stream'; -import {protobuf, LROperation, operationsProtos, LocationProtos} from 'google-gax'; +import { + protobuf, + LROperation, + operationsProtos, + LocationProtos, +} from 'google-gax'; function generateSampleMessage(instance: T) { - const filledObject = (instance.constructor as typeof protobuf.Message) - .toObject(instance as protobuf.Message, {defaults: true}); - return (instance.constructor as typeof protobuf.Message).fromObject(filledObject) as T; + const filledObject = ( + instance.constructor as typeof protobuf.Message + ).toObject(instance as protobuf.Message, {defaults: true}); + return (instance.constructor as typeof protobuf.Message).fromObject( + filledObject + ) as T; } function stubSimpleCall(response?: ResponseType, error?: Error) { - return error ? sinon.stub().rejects(error) : sinon.stub().resolves([response]); + return error + ? sinon.stub().rejects(error) + : sinon.stub().resolves([response]); } -function stubSimpleCallWithCallback(response?: ResponseType, error?: Error) { - return error ? sinon.stub().callsArgWith(2, error) : sinon.stub().callsArgWith(2, null, response); +function stubSimpleCallWithCallback( + response?: ResponseType, + error?: Error +) { + return error + ? sinon.stub().callsArgWith(2, error) + : sinon.stub().callsArgWith(2, null, response); } -function stubLongRunningCall(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().rejects(callError) : sinon.stub().resolves([mockOperation]); +function stubLongRunningCall( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().rejects(callError) + : sinon.stub().resolves([mockOperation]); } -function stubLongRunningCallWithCallback(response?: ResponseType, callError?: Error, lroError?: Error) { - const innerStub = lroError ? sinon.stub().rejects(lroError) : sinon.stub().resolves([response]); - const mockOperation = { - promise: innerStub, - }; - return callError ? sinon.stub().callsArgWith(2, callError) : sinon.stub().callsArgWith(2, null, mockOperation); +function stubLongRunningCallWithCallback( + response?: ResponseType, + callError?: Error, + lroError?: Error +) { + const innerStub = lroError + ? sinon.stub().rejects(lroError) + : sinon.stub().resolves([response]); + const mockOperation = { + promise: innerStub, + }; + return callError + ? sinon.stub().callsArgWith(2, callError) + : sinon.stub().callsArgWith(2, null, mockOperation); } -function stubPageStreamingCall(responses?: ResponseType[], error?: Error) { - const pagingStub = sinon.stub(); - if (responses) { - for (let i = 0; i < responses.length; ++i) { - pagingStub.onCall(i).callsArgWith(2, null, responses[i]); - } +function stubPageStreamingCall( + responses?: ResponseType[], + error?: Error +) { + const pagingStub = sinon.stub(); + if (responses) { + for (let i = 0; i < responses.length; ++i) { + pagingStub.onCall(i).callsArgWith(2, null, responses[i]); } - const transformStub = error ? sinon.stub().callsArgWith(2, error) : pagingStub; - const mockStream = new PassThrough({ - objectMode: true, - transform: transformStub, - }); - // trigger as many responses as needed - if (responses) { - for (let i = 0; i < responses.length; ++i) { - setImmediate(() => { mockStream.write({}); }); - } - setImmediate(() => { mockStream.end(); }); - } else { - setImmediate(() => { mockStream.write({}); }); - setImmediate(() => { mockStream.end(); }); + } + const transformStub = error + ? sinon.stub().callsArgWith(2, error) + : pagingStub; + const mockStream = new PassThrough({ + objectMode: true, + transform: transformStub, + }); + // trigger as many responses as needed + if (responses) { + for (let i = 0; i < responses.length; ++i) { + setImmediate(() => { + mockStream.write({}); + }); } - return sinon.stub().returns(mockStream); + setImmediate(() => { + mockStream.end(); + }); + } else { + setImmediate(() => { + mockStream.write({}); + }); + setImmediate(() => { + mockStream.end(); + }); + } + 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); +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.BigtableTableAdminClient', () => { - it('has servicePath', () => { - const servicePath = bigtabletableadminModule.v2.BigtableTableAdminClient.servicePath; - assert(servicePath); + it('has servicePath', () => { + const servicePath = + bigtabletableadminModule.v2.BigtableTableAdminClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + bigtabletableadminModule.v2.BigtableTableAdminClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = bigtabletableadminModule.v2.BigtableTableAdminClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + fallback: true, }); + assert(client); + }); - it('has apiEndpoint', () => { - const apiEndpoint = bigtabletableadminModule.v2.BigtableTableAdminClient.apiEndpoint; - assert(apiEndpoint); + it('has initialize method and supports deferred initialization', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); - - it('has port', () => { - const port = bigtabletableadminModule.v2.BigtableTableAdminClient.port; - assert(port); - assert(typeof port === 'number'); + assert.strictEqual(client.bigtableTableAdminStub, undefined); + await client.initialize(); + assert(client.bigtableTableAdminStub); + }); + + it('has close method for the initialized client', done => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); - - it('should create a client with no option', () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient(); - assert(client); + client.initialize(); + assert(client.bigtableTableAdminStub); + client.close().then(() => { + done(); }); + }); - it('should create a client with gRPC fallback', () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - fallback: true, - }); - assert(client); + it('has close method for the non-initialized client', done => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); - - it('has initialize method and supports deferred initialization', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.bigtableTableAdminStub, undefined); - await client.initialize(); - assert(client.bigtableTableAdminStub); + assert.strictEqual(client.bigtableTableAdminStub, undefined); + client.close().then(() => { + done(); }); + }); - it('has close method for the initialized client', done => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - assert(client.bigtableTableAdminStub); - client.close().then(() => { - done(); - }); + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); - - it('has close method for the non-initialized client', done => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - assert.strictEqual(client.bigtableTableAdminStub, undefined); - client.close().then(() => { - done(); - }); + client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); + const result = await client.getProjectId(); + assert.strictEqual(result, fakeProjectId); + assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + }); + + it('has getProjectId method with callback', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', }); - - it('has getProjectId method', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().resolves(fakeProjectId); - const result = await client.getProjectId(); - assert.strictEqual(result, fakeProjectId); - assert((client.auth.getProjectId as SinonStub).calledWithExactly()); + client.auth.getProjectId = sinon + .stub() + .callsArgWith(0, null, fakeProjectId); + const promise = new Promise((resolve, reject) => { + client.getProjectId((err?: Error | null, projectId?: string | null) => { + if (err) { + reject(err); + } else { + resolve(projectId); + } + }); }); - - it('has getProjectId method with callback', async () => { - const fakeProjectId = 'fake-project-id'; - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.auth.getProjectId = sinon.stub().callsArgWith(0, null, fakeProjectId); - const promise = new Promise((resolve, reject) => { - client.getProjectId((err?: Error|null, projectId?: string|null) => { - if (err) { - reject(err); - } else { - resolve(projectId); - } - }); - }); - const result = await promise; - assert.strictEqual(result, fakeProjectId); + const result = await promise; + assert.strictEqual(result, fakeProjectId); + }); + + describe('createTable', () => { + it('invokes createTable without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateTableRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Table() + ); + client.innerApiCalls.createTable = stubSimpleCall(expectedResponse); + const [response] = await client.createTable(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('createTable', () => { - it('invokes createTable without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateTableRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Table()); - client.innerApiCalls.createTable = stubSimpleCall(expectedResponse); - const [response] = await client.createTable(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createTable without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateTableRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Table()); - client.innerApiCalls.createTable = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTable( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.ITable|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes createTable with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateTableRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createTable = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.createTable(request), expectedError); - assert((client.innerApiCalls.createTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes createTable with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateTableRequest()); - request.parent = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.createTable(request), expectedError); - }); + it('invokes createTable without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateTableRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Table() + ); + client.innerApiCalls.createTable = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTable( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.ITable | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('getTable', () => { - it('invokes getTable without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Table()); - client.innerApiCalls.getTable = stubSimpleCall(expectedResponse); - const [response] = await client.getTable(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getTable without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Table()); - client.innerApiCalls.getTable = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getTable( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.ITable|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getTable with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getTable = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getTable(request), expectedError); - assert((client.innerApiCalls.getTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getTable with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetTableRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getTable(request), expectedError); - }); + it('invokes createTable with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateTableRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createTable = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createTable(request), expectedError); + assert( + (client.innerApiCalls.createTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('deleteTable', () => { - it('invokes deleteTable without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteTable = stubSimpleCall(expectedResponse); - const [response] = await client.deleteTable(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteTable without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteTable = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteTable( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes deleteTable with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteTable = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteTable(request), expectedError); - assert((client.innerApiCalls.deleteTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes deleteTable with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteTableRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteTable(request), expectedError); - }); + it('invokes createTable with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateTableRequest() + ); + request.parent = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createTable(request), expectedError); }); - - describe('modifyColumnFamilies', () => { - it('invokes modifyColumnFamilies without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ModifyColumnFamiliesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Table()); - client.innerApiCalls.modifyColumnFamilies = stubSimpleCall(expectedResponse); - const [response] = await client.modifyColumnFamilies(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.modifyColumnFamilies as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes modifyColumnFamilies without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ModifyColumnFamiliesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Table()); - client.innerApiCalls.modifyColumnFamilies = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.modifyColumnFamilies( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.ITable|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.modifyColumnFamilies as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes modifyColumnFamilies with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ModifyColumnFamiliesRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.modifyColumnFamilies = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.modifyColumnFamilies(request), expectedError); - assert((client.innerApiCalls.modifyColumnFamilies as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes modifyColumnFamilies with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ModifyColumnFamiliesRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.modifyColumnFamilies(request), expectedError); - }); + }); + + describe('getTable', () => { + it('invokes getTable without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Table() + ); + client.innerApiCalls.getTable = stubSimpleCall(expectedResponse); + const [response] = await client.getTable(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('dropRowRange', () => { - it('invokes dropRowRange without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DropRowRangeRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.dropRowRange = stubSimpleCall(expectedResponse); - const [response] = await client.dropRowRange(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.dropRowRange as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes dropRowRange without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DropRowRangeRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.dropRowRange = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.dropRowRange( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.dropRowRange as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes dropRowRange with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DropRowRangeRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.dropRowRange = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.dropRowRange(request), expectedError); - assert((client.innerApiCalls.dropRowRange as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes dropRowRange with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DropRowRangeRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.dropRowRange(request), expectedError); - }); + it('invokes getTable without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Table() + ); + client.innerApiCalls.getTable = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getTable( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.ITable | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('generateConsistencyToken', () => { - it('invokes generateConsistencyToken without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GenerateConsistencyTokenRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.GenerateConsistencyTokenResponse()); - client.innerApiCalls.generateConsistencyToken = stubSimpleCall(expectedResponse); - const [response] = await client.generateConsistencyToken(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.generateConsistencyToken as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes generateConsistencyToken without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GenerateConsistencyTokenRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.GenerateConsistencyTokenResponse()); - client.innerApiCalls.generateConsistencyToken = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.generateConsistencyToken( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.generateConsistencyToken as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes generateConsistencyToken with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GenerateConsistencyTokenRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.generateConsistencyToken = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.generateConsistencyToken(request), expectedError); - assert((client.innerApiCalls.generateConsistencyToken as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes generateConsistencyToken with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GenerateConsistencyTokenRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.generateConsistencyToken(request), expectedError); - }); + it('invokes getTable with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getTable = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getTable(request), expectedError); + assert( + (client.innerApiCalls.getTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('checkConsistency', () => { - it('invokes checkConsistency without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CheckConsistencyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.CheckConsistencyResponse()); - client.innerApiCalls.checkConsistency = stubSimpleCall(expectedResponse); - const [response] = await client.checkConsistency(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.checkConsistency as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkConsistency without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CheckConsistencyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.CheckConsistencyResponse()); - client.innerApiCalls.checkConsistency = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.checkConsistency( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.ICheckConsistencyResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.checkConsistency as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes checkConsistency with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CheckConsistencyRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.checkConsistency = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkConsistency(request), expectedError); - assert((client.innerApiCalls.checkConsistency as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes checkConsistency with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CheckConsistencyRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.checkConsistency(request), expectedError); - }); + it('invokes getTable with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetTableRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getTable(request), expectedError); }); - - describe('getSnapshot', () => { - it('invokes getSnapshot without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetSnapshotRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()); - client.innerApiCalls.getSnapshot = stubSimpleCall(expectedResponse); - const [response] = await client.getSnapshot(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getSnapshot as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getSnapshot without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetSnapshotRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()); - client.innerApiCalls.getSnapshot = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getSnapshot( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.ISnapshot|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getSnapshot as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); - - it('invokes getSnapshot with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetSnapshotRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getSnapshot = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getSnapshot(request), expectedError); - assert((client.innerApiCalls.getSnapshot as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes getSnapshot with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetSnapshotRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getSnapshot(request), expectedError); - }); + }); + + describe('deleteTable', () => { + it('invokes deleteTable without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteTable = stubSimpleCall(expectedResponse); + const [response] = await client.deleteTable(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('deleteSnapshot', () => { - it('invokes deleteSnapshot without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteSnapshotRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteSnapshot = stubSimpleCall(expectedResponse); - const [response] = await client.deleteSnapshot(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteSnapshot as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes deleteTable without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteTable = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteTable( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes deleteSnapshot without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteSnapshotRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteSnapshot = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteSnapshot( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteSnapshot as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes deleteTable with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteTable = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteTable(request), expectedError); + assert( + (client.innerApiCalls.deleteTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes deleteSnapshot with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteSnapshotRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteSnapshot = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteSnapshot(request), expectedError); - assert((client.innerApiCalls.deleteSnapshot as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes deleteTable with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteTableRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteTable(request), expectedError); + }); + }); + + describe('modifyColumnFamilies', () => { + it('invokes modifyColumnFamilies without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ModifyColumnFamiliesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Table() + ); + client.innerApiCalls.modifyColumnFamilies = + stubSimpleCall(expectedResponse); + const [response] = await client.modifyColumnFamilies(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.modifyColumnFamilies as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes deleteSnapshot with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteSnapshotRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteSnapshot(request), expectedError); - }); + it('invokes modifyColumnFamilies without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ModifyColumnFamiliesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Table() + ); + client.innerApiCalls.modifyColumnFamilies = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.modifyColumnFamilies( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.ITable | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.modifyColumnFamilies as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('getBackup', () => { - it('invokes getBackup without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetBackupRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()); - client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); - const [response] = await client.getBackup(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes modifyColumnFamilies with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ModifyColumnFamiliesRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.modifyColumnFamilies = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.modifyColumnFamilies(request), expectedError); + assert( + (client.innerApiCalls.modifyColumnFamilies as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes getBackup without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetBackupRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()); - client.innerApiCalls.getBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getBackup( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IBackup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes modifyColumnFamilies with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ModifyColumnFamiliesRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.modifyColumnFamilies(request), expectedError); + }); + }); + + describe('dropRowRange', () => { + it('invokes dropRowRange without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DropRowRangeRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.dropRowRange = stubSimpleCall(expectedResponse); + const [response] = await client.dropRowRange(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.dropRowRange as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes getBackup with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetBackupRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getBackup(request), expectedError); - assert((client.innerApiCalls.getBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes dropRowRange without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DropRowRangeRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.dropRowRange = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.dropRowRange( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.dropRowRange as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes getBackup with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.GetBackupRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getBackup(request), expectedError); - }); + it('invokes dropRowRange with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DropRowRangeRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.dropRowRange = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.dropRowRange(request), expectedError); + assert( + (client.innerApiCalls.dropRowRange as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('updateBackup', () => { - it('invokes updateBackup without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UpdateBackupRequest()); - request.backup = {}; - request.backup.name = ''; - const expectedHeaderRequestParams = "backup.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()); - client.innerApiCalls.updateBackup = stubSimpleCall(expectedResponse); - const [response] = await client.updateBackup(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes dropRowRange with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DropRowRangeRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.dropRowRange(request), expectedError); + }); + }); + + describe('generateConsistencyToken', () => { + it('invokes generateConsistencyToken without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GenerateConsistencyTokenRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.GenerateConsistencyTokenResponse() + ); + client.innerApiCalls.generateConsistencyToken = + stubSimpleCall(expectedResponse); + const [response] = await client.generateConsistencyToken(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.generateConsistencyToken as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes updateBackup without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UpdateBackupRequest()); - request.backup = {}; - request.backup.name = ''; - const expectedHeaderRequestParams = "backup.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()); - client.innerApiCalls.updateBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.updateBackup( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IBackup|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes generateConsistencyToken without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GenerateConsistencyTokenRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.GenerateConsistencyTokenResponse() + ); + client.innerApiCalls.generateConsistencyToken = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.generateConsistencyToken( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IGenerateConsistencyTokenResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.generateConsistencyToken as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes updateBackup with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UpdateBackupRequest()); - request.backup = {}; - request.backup.name = ''; - const expectedHeaderRequestParams = "backup.name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.updateBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.updateBackup(request), expectedError); - assert((client.innerApiCalls.updateBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes generateConsistencyToken with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GenerateConsistencyTokenRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.generateConsistencyToken = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.generateConsistencyToken(request), + expectedError + ); + assert( + (client.innerApiCalls.generateConsistencyToken as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes updateBackup with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UpdateBackupRequest()); - request.backup = {}; - request.backup.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.updateBackup(request), expectedError); - }); + it('invokes generateConsistencyToken with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GenerateConsistencyTokenRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects( + client.generateConsistencyToken(request), + expectedError + ); + }); + }); + + describe('checkConsistency', () => { + it('invokes checkConsistency without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CheckConsistencyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.CheckConsistencyResponse() + ); + client.innerApiCalls.checkConsistency = stubSimpleCall(expectedResponse); + const [response] = await client.checkConsistency(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.checkConsistency as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('deleteBackup', () => { - it('invokes deleteBackup without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteBackupRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteBackup = stubSimpleCall(expectedResponse); - const [response] = await client.deleteBackup(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes checkConsistency without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CheckConsistencyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.CheckConsistencyResponse() + ); + client.innerApiCalls.checkConsistency = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.checkConsistency( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.ICheckConsistencyResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.checkConsistency as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes deleteBackup without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteBackupRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.protobuf.Empty()); - client.innerApiCalls.deleteBackup = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.deleteBackup( - request, - (err?: Error|null, result?: protos.google.protobuf.IEmpty|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes checkConsistency with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CheckConsistencyRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.checkConsistency = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkConsistency(request), expectedError); + assert( + (client.innerApiCalls.checkConsistency as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes deleteBackup with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteBackupRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.deleteBackup = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.deleteBackup(request), expectedError); - assert((client.innerApiCalls.deleteBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes checkConsistency with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CheckConsistencyRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.checkConsistency(request), expectedError); + }); + }); + + describe('getSnapshot', () => { + it('invokes getSnapshot without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetSnapshotRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Snapshot() + ); + client.innerApiCalls.getSnapshot = stubSimpleCall(expectedResponse); + const [response] = await client.getSnapshot(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getSnapshot as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes deleteBackup with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.DeleteBackupRequest()); - request.name = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.deleteBackup(request), expectedError); - }); + it('invokes getSnapshot without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetSnapshotRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Snapshot() + ); + client.innerApiCalls.getSnapshot = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getSnapshot( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.ISnapshot | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getSnapshot as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('getIamPolicy', () => { - it('invokes getIamPolicy without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.getIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getSnapshot with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetSnapshotRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getSnapshot = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getSnapshot(request), expectedError); + assert( + (client.innerApiCalls.getSnapshot as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes getIamPolicy without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.getIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes getSnapshot with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetSnapshotRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getSnapshot(request), expectedError); + }); + }); + + describe('deleteSnapshot', () => { + it('invokes deleteSnapshot without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteSnapshotRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSnapshot = stubSimpleCall(expectedResponse); + const [response] = await client.deleteSnapshot(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteSnapshot as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes getIamPolicy with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.getIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getIamPolicy(request), expectedError); - assert((client.innerApiCalls.getIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes deleteSnapshot without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteSnapshotRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteSnapshot = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteSnapshot( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteSnapshot as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes getIamPolicy with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.GetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.getIamPolicy(request), expectedError); - }); + it('invokes deleteSnapshot with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteSnapshotRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteSnapshot = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteSnapshot(request), expectedError); + assert( + (client.innerApiCalls.deleteSnapshot as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('setIamPolicy', () => { - it('invokes setIamPolicy without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); - const [response] = await client.setIamPolicy(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes deleteSnapshot with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteSnapshotRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteSnapshot(request), expectedError); + }); + }); + + describe('getBackup', () => { + it('invokes getBackup without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetBackupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Backup() + ); + client.innerApiCalls.getBackup = stubSimpleCall(expectedResponse); + const [response] = await client.getBackup(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes setIamPolicy without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.Policy()); - client.innerApiCalls.setIamPolicy = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.setIamPolicy( - request, - (err?: Error|null, result?: protos.google.iam.v1.IPolicy|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes getBackup without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetBackupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Backup() + ); + client.innerApiCalls.getBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getBackup( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IBackup | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes setIamPolicy with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.setIamPolicy = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.setIamPolicy(request), expectedError); - assert((client.innerApiCalls.setIamPolicy as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getBackup with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetBackupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getBackup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.getBackup(request), expectedError); + assert( + (client.innerApiCalls.getBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes setIamPolicy with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.SetIamPolicyRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.setIamPolicy(request), expectedError); - }); + it('invokes getBackup with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.GetBackupRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getBackup(request), expectedError); + }); + }); + + describe('updateBackup', () => { + it('invokes updateBackup without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UpdateBackupRequest() + ); + request.backup = {}; + request.backup.name = ''; + const expectedHeaderRequestParams = 'backup.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Backup() + ); + client.innerApiCalls.updateBackup = stubSimpleCall(expectedResponse); + const [response] = await client.updateBackup(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('testIamPermissions', () => { - it('invokes testIamPermissions without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCall(expectedResponse); - const [response] = await client.testIamPermissions(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes updateBackup without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UpdateBackupRequest() + ); + request.backup = {}; + request.backup.name = ''; + const expectedHeaderRequestParams = 'backup.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.bigtable.admin.v2.Backup() + ); + client.innerApiCalls.updateBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.updateBackup( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IBackup | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.updateBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes testIamPermissions without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsResponse()); - client.innerApiCalls.testIamPermissions = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.testIamPermissions( - request, - (err?: Error|null, result?: protos.google.iam.v1.ITestIamPermissionsResponse|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes updateBackup with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UpdateBackupRequest() + ); + request.backup = {}; + request.backup.name = ''; + const expectedHeaderRequestParams = 'backup.name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.updateBackup = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.updateBackup(request), expectedError); + assert( + (client.innerApiCalls.updateBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes testIamPermissions with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedHeaderRequestParams = "resource="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.testIamPermissions = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.testIamPermissions(request), expectedError); - assert((client.innerApiCalls.testIamPermissions as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes updateBackup with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UpdateBackupRequest() + ); + request.backup = {}; + request.backup.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.updateBackup(request), expectedError); + }); + }); + + describe('deleteBackup', () => { + it('invokes deleteBackup without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteBackupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteBackup = stubSimpleCall(expectedResponse); + const [response] = await client.deleteBackup(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes testIamPermissions with closed client', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.iam.v1.TestIamPermissionsRequest()); - request.resource = ''; - const expectedError = new Error('The client has already been closed.'); - client.close(); - await assert.rejects(client.testIamPermissions(request), expectedError); - }); + it('invokes deleteBackup without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteBackupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.innerApiCalls.deleteBackup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteBackup( + request, + ( + err?: Error | null, + result?: protos.google.protobuf.IEmpty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.deleteBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('createTableFromSnapshot', () => { - it('invokes createTableFromSnapshot without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateTableFromSnapshotRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createTableFromSnapshot = stubLongRunningCall(expectedResponse); - const [operation] = await client.createTableFromSnapshot(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createTableFromSnapshot as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes deleteBackup with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteBackupRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteBackup = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.deleteBackup(request), expectedError); + assert( + (client.innerApiCalls.deleteBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes createTableFromSnapshot without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateTableFromSnapshotRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createTableFromSnapshot = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createTableFromSnapshot( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createTableFromSnapshot as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes deleteBackup with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.DeleteBackupRequest() + ); + request.name = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.deleteBackup(request), expectedError); + }); + }); + + describe('getIamPolicy', () => { + it('invokes getIamPolicy without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.getIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes createTableFromSnapshot with call error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateTableFromSnapshotRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createTableFromSnapshot = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createTableFromSnapshot(request), expectedError); - assert((client.innerApiCalls.createTableFromSnapshot as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.getIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes createTableFromSnapshot with LRO error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateTableFromSnapshotRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createTableFromSnapshot = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createTableFromSnapshot(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createTableFromSnapshot as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getIamPolicy with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.getIamPolicy = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.getIamPolicy(request), expectedError); + assert( + (client.innerApiCalls.getIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes checkCreateTableFromSnapshotProgress without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateTableFromSnapshotProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes getIamPolicy with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.GetIamPolicyRequest() + ); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIamPolicy(request), expectedError); + }); + }); + + describe('setIamPolicy', () => { + it('invokes setIamPolicy without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = stubSimpleCall(expectedResponse); + const [response] = await client.setIamPolicy(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes checkCreateTableFromSnapshotProgress with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); + it('invokes setIamPolicy without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.Policy() + ); + client.innerApiCalls.setIamPolicy = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.setIamPolicy( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.IPolicy | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateTableFromSnapshotProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes setIamPolicy with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.setIamPolicy = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.setIamPolicy(request), expectedError); + assert( + (client.innerApiCalls.setIamPolicy as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('undeleteTable', () => { - it('invokes undeleteTable without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UndeleteTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.undeleteTable = stubLongRunningCall(expectedResponse); - const [operation] = await client.undeleteTable(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.undeleteTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes setIamPolicy with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.SetIamPolicyRequest() + ); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.setIamPolicy(request), expectedError); + }); + }); + + describe('testIamPermissions', () => { + it('invokes testIamPermissions without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCall(expectedResponse); + const [response] = await client.testIamPermissions(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes undeleteTable without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UndeleteTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.undeleteTable = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.undeleteTable( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.undeleteTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes testIamPermissions without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsResponse() + ); + client.innerApiCalls.testIamPermissions = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.testIamPermissions( + request, + ( + err?: Error | null, + result?: protos.google.iam.v1.ITestIamPermissionsResponse | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes undeleteTable with call error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UndeleteTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteTable = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.undeleteTable(request), expectedError); - assert((client.innerApiCalls.undeleteTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes testIamPermissions with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedHeaderRequestParams = 'resource='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.testIamPermissions = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.testIamPermissions(request), expectedError); + assert( + (client.innerApiCalls.testIamPermissions as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes undeleteTable with LRO error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.UndeleteTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.undeleteTable = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.undeleteTable(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.undeleteTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes testIamPermissions with closed client', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.iam.v1.TestIamPermissionsRequest() + ); + request.resource = ''; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.testIamPermissions(request), expectedError); + }); + }); + + describe('createTableFromSnapshot', () => { + it('invokes createTableFromSnapshot without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateTableFromSnapshotRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createTableFromSnapshot = + stubLongRunningCall(expectedResponse); + const [operation] = await client.createTableFromSnapshot(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createTableFromSnapshot as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes checkUndeleteTableProgress without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkUndeleteTableProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes createTableFromSnapshot without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateTableFromSnapshotRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createTableFromSnapshot = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createTableFromSnapshot( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableFromSnapshotMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.ICreateTableFromSnapshotMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createTableFromSnapshot as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes checkUndeleteTableProgress with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); + it('invokes createTableFromSnapshot with call error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateTableFromSnapshotRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createTableFromSnapshot = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects( + client.createTableFromSnapshot(request), + expectedError + ); + assert( + (client.innerApiCalls.createTableFromSnapshot as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkUndeleteTableProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createTableFromSnapshot with LRO error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateTableFromSnapshotRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createTableFromSnapshot = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.createTableFromSnapshot(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.createTableFromSnapshot as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('snapshotTable', () => { - it('invokes snapshotTable without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.SnapshotTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.snapshotTable = stubLongRunningCall(expectedResponse); - const [operation] = await client.snapshotTable(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.snapshotTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes checkCreateTableFromSnapshotProgress without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = + await client.checkCreateTableFromSnapshotProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes snapshotTable without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.SnapshotTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.snapshotTable = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.snapshotTable( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.snapshotTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes checkCreateTableFromSnapshotProgress with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkCreateTableFromSnapshotProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('undeleteTable', () => { + it('invokes undeleteTable without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UndeleteTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeleteTable = + stubLongRunningCall(expectedResponse); + const [operation] = await client.undeleteTable(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.undeleteTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes snapshotTable with call error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.SnapshotTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.snapshotTable = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.snapshotTable(request), expectedError); - assert((client.innerApiCalls.snapshotTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes undeleteTable without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UndeleteTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.undeleteTable = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.undeleteTable( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IUndeleteTableMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IUndeleteTableMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.undeleteTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes snapshotTable with LRO error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.SnapshotTableRequest()); - request.name = ''; - const expectedHeaderRequestParams = "name="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.snapshotTable = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.snapshotTable(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.snapshotTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes undeleteTable with call error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UndeleteTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteTable = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.undeleteTable(request), expectedError); + assert( + (client.innerApiCalls.undeleteTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes checkSnapshotTableProgress without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkSnapshotTableProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes undeleteTable with LRO error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.UndeleteTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.undeleteTable = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.undeleteTable(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.undeleteTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes checkSnapshotTableProgress with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkUndeleteTableProgress without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkUndeleteTableProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkSnapshotTableProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkUndeleteTableProgress with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkUndeleteTableProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('snapshotTable', () => { + it('invokes snapshotTable without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.SnapshotTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.snapshotTable = + stubLongRunningCall(expectedResponse); + const [operation] = await client.snapshotTable(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.snapshotTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('createBackup', () => { - it('invokes createBackup without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateBackupRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.createBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes snapshotTable without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.SnapshotTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.snapshotTable = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.snapshotTable( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.ISnapshotTableMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.ISnapshot, + protos.google.bigtable.admin.v2.ISnapshotTableMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.snapshotTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes createBackup without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateBackupRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.createBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.createBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.createBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes snapshotTable with call error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.SnapshotTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.snapshotTable = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.snapshotTable(request), expectedError); + assert( + (client.innerApiCalls.snapshotTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes createBackup with call error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateBackupRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.createBackup(request), expectedError); - assert((client.innerApiCalls.createBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes snapshotTable with LRO error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.SnapshotTableRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.snapshotTable = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.snapshotTable(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.snapshotTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes createBackup with LRO error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CreateBackupRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.createBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.createBackup(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.createBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes checkSnapshotTableProgress without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkSnapshotTableProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCreateBackupProgress without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCreateBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkSnapshotTableProgress with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.checkSnapshotTableProgress(''), + expectedError + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createBackup', () => { + it('invokes createBackup without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateBackupRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.createBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes checkCreateBackupProgress with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); + it('invokes createBackup without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateBackupRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.createBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICreateBackupMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICreateBackupMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.createBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCreateBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes createBackup with call error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateBackupRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.createBackup(request), expectedError); + assert( + (client.innerApiCalls.createBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('restoreTable', () => { - it('invokes restoreTable without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.RestoreTableRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.restoreTable = stubLongRunningCall(expectedResponse); - const [operation] = await client.restoreTable(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.restoreTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes createBackup with LRO error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CreateBackupRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.createBackup = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.createBackup(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.createBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes restoreTable without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.RestoreTableRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.restoreTable = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.restoreTable( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.restoreTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes checkCreateBackupProgress without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCreateBackupProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes restoreTable with call error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.RestoreTableRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreTable = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.restoreTable(request), expectedError); - assert((client.innerApiCalls.restoreTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes checkCreateBackupProgress with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkCreateBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('restoreTable', () => { + it('invokes restoreTable without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.RestoreTableRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.restoreTable = stubLongRunningCall(expectedResponse); + const [operation] = await client.restoreTable(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.restoreTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes restoreTable with LRO error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.RestoreTableRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.restoreTable = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.restoreTable(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.restoreTable as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes restoreTable without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.RestoreTableRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.restoreTable = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.restoreTable( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IRestoreTableMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.ITable, + protos.google.bigtable.admin.v2.IRestoreTableMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.restoreTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes checkRestoreTableProgress without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkRestoreTableProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes restoreTable with call error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.RestoreTableRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreTable = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.restoreTable(request), expectedError); + assert( + (client.innerApiCalls.restoreTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes checkRestoreTableProgress with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); + it('invokes restoreTable with LRO error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.RestoreTableRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.restoreTable = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.restoreTable(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.restoreTable as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkRestoreTableProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes checkRestoreTableProgress without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkRestoreTableProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('copyBackup', () => { - it('invokes copyBackup without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CopyBackupRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.copyBackup = stubLongRunningCall(expectedResponse); - const [operation] = await client.copyBackup(request); - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes checkRestoreTableProgress with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkRestoreTableProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('copyBackup', () => { + it('invokes copyBackup without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CopyBackupRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.copyBackup = stubLongRunningCall(expectedResponse); + const [operation] = await client.copyBackup(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes copyBackup without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CopyBackupRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage(new protos.google.longrunning.Operation()); - client.innerApiCalls.copyBackup = stubLongRunningCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.copyBackup( - request, - (err?: Error|null, - result?: LROperation|null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const operation = await promise as LROperation; - const [response] = await operation.promise(); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes copyBackup without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CopyBackupRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.copyBackup = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.copyBackup( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICopyBackupMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.bigtable.admin.v2.IBackup, + protos.google.bigtable.admin.v2.ICopyBackupMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); - it('invokes copyBackup with call error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CopyBackupRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.copyBackup = stubLongRunningCall(undefined, expectedError); - await assert.rejects(client.copyBackup(request), expectedError); - assert((client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes copyBackup with call error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CopyBackupRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.copyBackup = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.copyBackup(request), expectedError); + assert( + (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes copyBackup with LRO error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.CopyBackupRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.copyBackup = stubLongRunningCall(undefined, undefined, expectedError); - const [operation] = await client.copyBackup(request); - await assert.rejects(operation.promise(), expectedError); - assert((client.innerApiCalls.copyBackup as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes copyBackup with LRO error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.CopyBackupRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.copyBackup = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.copyBackup(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.copyBackup as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes checkCopyBackupProgress without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedResponse = generateSampleMessage(new operationsProtos.google.longrunning.Operation()); - expectedResponse.name = 'test'; - expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; - expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')} - - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const decodedOperation = await client.checkCopyBackupProgress(expectedResponse.name); - assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); - assert(decodedOperation.metadata); - assert((client.operationsClient.getOperation as SinonStub).getCall(0)); - }); + it('invokes checkCopyBackupProgress without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkCopyBackupProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); - it('invokes checkCopyBackupProgress with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const expectedError = new Error('expected'); + it('invokes checkCopyBackupProgress with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkCopyBackupProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listTables', () => { + it('invokes listTables without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListTablesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + ]; + client.innerApiCalls.listTables = stubSimpleCall(expectedResponse); + const [response] = await client.listTables(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listTables as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.checkCopyBackupProgress(''), expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); + it('invokes listTables without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListTablesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + ]; + client.innerApiCalls.listTables = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listTables( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.ITable[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listTables as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('listTables', () => { - it('invokes listTables without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListTablesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - ]; - client.innerApiCalls.listTables = stubSimpleCall(expectedResponse); - const [response] = await client.listTables(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listTables as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes listTables with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListTablesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listTables = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listTables(request), expectedError); + assert( + (client.innerApiCalls.listTables as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes listTables without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListTablesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - ]; - client.innerApiCalls.listTables = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listTables( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.ITable[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listTables as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes listTablesStream without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListTablesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + ]; + client.descriptors.page.listTables.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listTablesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.bigtable.admin.v2.Table[] = []; + stream.on('data', (response: protos.google.bigtable.admin.v2.Table) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listTables.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTables, request) + ); + assert.strictEqual( + (client.descriptors.page.listTables.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes listTables with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListTablesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listTables = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listTables(request), expectedError); - assert((client.innerApiCalls.listTables as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes listTablesStream with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListTablesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listTables.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listTablesStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.bigtable.admin.v2.Table[] = []; + stream.on('data', (response: protos.google.bigtable.admin.v2.Table) => { + responses.push(response); + }); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listTables.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listTables, request) + ); + assert.strictEqual( + (client.descriptors.page.listTables.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes listTablesStream without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListTablesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - ]; - client.descriptors.page.listTables.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listTablesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.bigtable.admin.v2.Table[] = []; - stream.on('data', (response: protos.google.bigtable.admin.v2.Table) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listTables.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTables, request)); - assert.strictEqual( - (client.descriptors.page.listTables.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('uses async iteration with listTables without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListTablesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), + ]; + client.descriptors.page.listTables.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.bigtable.admin.v2.ITable[] = []; + const iterable = client.listTablesAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listTables.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listTables.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes listTablesStream with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListTablesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listTables.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listTablesStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.bigtable.admin.v2.Table[] = []; - stream.on('data', (response: protos.google.bigtable.admin.v2.Table) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listTables.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listTables, request)); - assert.strictEqual( - (client.descriptors.page.listTables.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('uses async iteration with listTables with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListTablesRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listTables.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listTablesAsync(request); + await assert.rejects(async () => { + const responses: protos.google.bigtable.admin.v2.ITable[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listTables.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listTables.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listSnapshots', () => { + it('invokes listSnapshots without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListSnapshotsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + ]; + client.innerApiCalls.listSnapshots = stubSimpleCall(expectedResponse); + const [response] = await client.listSnapshots(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listSnapshots as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('uses async iteration with listTables without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListTablesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Table()), - ]; - client.descriptors.page.listTables.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.bigtable.admin.v2.ITable[] = []; - const iterable = client.listTablesAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listSnapshots without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListSnapshotsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + ]; + client.innerApiCalls.listSnapshots = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listSnapshots( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.ISnapshot[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listTables.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listTables.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listTables with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListTablesRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listTables.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listTablesAsync(request); - await assert.rejects(async () => { - const responses: protos.google.bigtable.admin.v2.ITable[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listTables.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listTables.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listSnapshots as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('listSnapshots', () => { - it('invokes listSnapshots without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListSnapshotsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - ]; - client.innerApiCalls.listSnapshots = stubSimpleCall(expectedResponse); - const [response] = await client.listSnapshots(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listSnapshots as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes listSnapshots with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListSnapshotsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listSnapshots = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listSnapshots(request), expectedError); + assert( + (client.innerApiCalls.listSnapshots as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes listSnapshots without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListSnapshotsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - ]; - client.innerApiCalls.listSnapshots = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listSnapshots( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.ISnapshot[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listSnapshots as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes listSnapshotsStream without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListSnapshotsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + ]; + client.descriptors.page.listSnapshots.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listSnapshotsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.bigtable.admin.v2.Snapshot[] = []; + stream.on( + 'data', + (response: protos.google.bigtable.admin.v2.Snapshot) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listSnapshots.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSnapshots, request) + ); + assert.strictEqual( + ( + client.descriptors.page.listSnapshots.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes listSnapshots with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListSnapshotsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listSnapshots = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listSnapshots(request), expectedError); - assert((client.innerApiCalls.listSnapshots as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes listSnapshotsStream with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListSnapshotsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listSnapshots.createStream = + stubPageStreamingCall(undefined, expectedError); + const stream = client.listSnapshotsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.bigtable.admin.v2.Snapshot[] = []; + stream.on( + 'data', + (response: protos.google.bigtable.admin.v2.Snapshot) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listSnapshots.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listSnapshots, request) + ); + assert.strictEqual( + ( + client.descriptors.page.listSnapshots.createStream as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes listSnapshotsStream without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListSnapshotsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - ]; - client.descriptors.page.listSnapshots.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listSnapshotsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.bigtable.admin.v2.Snapshot[] = []; - stream.on('data', (response: protos.google.bigtable.admin.v2.Snapshot) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listSnapshots.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSnapshots, request)); - assert.strictEqual( - (client.descriptors.page.listSnapshots.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('uses async iteration with listSnapshots without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListSnapshotsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), + ]; + client.descriptors.page.listSnapshots.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.bigtable.admin.v2.ISnapshot[] = []; + const iterable = client.listSnapshotsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.descriptors.page.listSnapshots.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert.strictEqual( + ( + client.descriptors.page.listSnapshots.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes listSnapshotsStream with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListSnapshotsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listSnapshots.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listSnapshotsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.bigtable.admin.v2.Snapshot[] = []; - stream.on('data', (response: protos.google.bigtable.admin.v2.Snapshot) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listSnapshots.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listSnapshots, request)); - assert.strictEqual( - (client.descriptors.page.listSnapshots.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('uses async iteration with listSnapshots with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListSnapshotsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listSnapshots.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listSnapshotsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.bigtable.admin.v2.ISnapshot[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.descriptors.page.listSnapshots.asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert.strictEqual( + ( + client.descriptors.page.listSnapshots.asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + + describe('listBackups', () => { + it('invokes listBackups without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListBackupsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + ]; + client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); + const [response] = await client.listBackups(request); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listBackups as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('uses async iteration with listSnapshots without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListSnapshotsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Snapshot()), - ]; - client.descriptors.page.listSnapshots.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.bigtable.admin.v2.ISnapshot[] = []; - const iterable = client.listSnapshotsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes listBackups without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListBackupsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + ]; + client.innerApiCalls.listBackups = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listBackups( + request, + ( + err?: Error | null, + result?: protos.google.bigtable.admin.v2.IBackup[] | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listSnapshots with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListSnapshotsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listSnapshots.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listSnapshotsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.bigtable.admin.v2.ISnapshot[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listSnapshots.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.listBackups as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); }); - describe('listBackups', () => { - it('invokes listBackups without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListBackupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCall(expectedResponse); - const [response] = await client.listBackups(request); - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listBackups as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - - it('invokes listBackups without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListBackupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - ]; - client.innerApiCalls.listBackups = stubSimpleCallWithCallback(expectedResponse); - const promise = new Promise((resolve, reject) => { - client.listBackups( - request, - (err?: Error|null, result?: protos.google.bigtable.admin.v2.IBackup[]|null) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.innerApiCalls.listBackups as SinonStub) - .getCall(0).calledWith(request, expectedOptions /*, callback defined above */)); - }); + it('invokes listBackups with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListBackupsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.listBackups = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.listBackups(request), expectedError); + assert( + (client.innerApiCalls.listBackups as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); - it('invokes listBackups with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListBackupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.innerApiCalls.listBackups = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.listBackups(request), expectedError); - assert((client.innerApiCalls.listBackups as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes listBackupsStream without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListBackupsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + ]; + client.descriptors.page.listBackups.createStream = + stubPageStreamingCall(expectedResponse); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.bigtable.admin.v2.Backup[] = []; + stream.on( + 'data', + (response: protos.google.bigtable.admin.v2.Backup) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + const responses = await promise; + assert.deepStrictEqual(responses, expectedResponse); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request) + ); + assert.strictEqual( + (client.descriptors.page.listBackups.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes listBackupsStream without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListBackupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - ]; - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(expectedResponse); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.bigtable.admin.v2.Backup[] = []; - stream.on('data', (response: protos.google.bigtable.admin.v2.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - const responses = await promise; - assert.deepStrictEqual(responses, expectedResponse); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert.strictEqual( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('invokes listBackupsStream with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListBackupsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.createStream = stubPageStreamingCall( + undefined, + expectedError + ); + const stream = client.listBackupsStream(request); + const promise = new Promise((resolve, reject) => { + const responses: protos.google.bigtable.admin.v2.Backup[] = []; + stream.on( + 'data', + (response: protos.google.bigtable.admin.v2.Backup) => { + responses.push(response); + } + ); + stream.on('end', () => { + resolve(responses); + }); + stream.on('error', (err: Error) => { + reject(err); + }); + }); + await assert.rejects(promise, expectedError); + assert( + (client.descriptors.page.listBackups.createStream as SinonStub) + .getCall(0) + .calledWith(client.innerApiCalls.listBackups, request) + ); + assert.strictEqual( + (client.descriptors.page.listBackups.createStream as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('invokes listBackupsStream with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListBackupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedError = new Error('expected'); - client.descriptors.page.listBackups.createStream = stubPageStreamingCall(undefined, expectedError); - const stream = client.listBackupsStream(request); - const promise = new Promise((resolve, reject) => { - const responses: protos.google.bigtable.admin.v2.Backup[] = []; - stream.on('data', (response: protos.google.bigtable.admin.v2.Backup) => { - responses.push(response); - }); - stream.on('end', () => { - resolve(responses); - }); - stream.on('error', (err: Error) => { - reject(err); - }); - }); - await assert.rejects(promise, expectedError); - assert((client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).calledWith(client.innerApiCalls.listBackups, request)); - assert.strictEqual( - (client.descriptors.page.listBackups.createStream as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + it('uses async iteration with listBackups without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListBackupsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedResponse = [ + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), + ]; + client.descriptors.page.listBackups.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.bigtable.admin.v2.IBackup[] = []; + const iterable = client.listBackupsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); - it('uses async iteration with listBackups without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListBackupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent="; - const expectedResponse = [ - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - generateSampleMessage(new protos.google.bigtable.admin.v2.Backup()), - ]; - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: protos.google.bigtable.admin.v2.IBackup[] = []; - const iterable = client.listBackupsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('uses async iteration with listBackups with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.bigtable.admin.v2.ListBackupsRequest() + ); + request.parent = ''; + const expectedHeaderRequestParams = 'parent='; + const expectedError = new Error('expected'); + client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall( + undefined, + expectedError + ); + const iterable = client.listBackupsAsync(request); + await assert.rejects(async () => { + const responses: protos.google.bigtable.admin.v2.IBackup[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0 + ).args[1], + request + ); + assert.strictEqual( + (client.descriptors.page.listBackups.asyncIterate as SinonStub).getCall( + 0 + ).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + describe('getLocation', () => { + it('invokes getLocation without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = stubSimpleCall(expectedResponse); + const response = await client.getLocation(request, expectedOptions); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + it('invokes getLocation without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ); + client.locationsClient.getLocation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getLocation( + request, + expectedOptions, + ( + err?: Error | null, + result?: LocationProtos.google.cloud.location.ILocation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - - it('uses async iteration with listBackups with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage(new protos.google.bigtable.admin.v2.ListBackupsRequest()); - request.parent = ''; - const expectedHeaderRequestParams = "parent=";const expectedError = new Error('expected'); - client.descriptors.page.listBackups.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listBackupsAsync(request); - await assert.rejects(async () => { - const responses: protos.google.bigtable.admin.v2.IBackup[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.descriptors.page.listBackups.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.locationsClient.getLocation as SinonStub).getCall(0)); }); - describe('getLocation', () => { - it('invokes getLocation without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = stubSimpleCall(expectedResponse); - const response = await client.getLocation(request, expectedOptions); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); - it('invokes getLocation without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedResponse = generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ); - client.locationsClient.getLocation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.getLocation( - request, - expectedOptions, - ( - err?: Error | null, - result?: LocationProtos.google.cloud.location.ILocation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0)); - }); - it('invokes getLocation with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.GetLocationRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedOptions = { - otherArgs: { - headers: { - 'x-goog-request-params': expectedHeaderRequestParams, - }, - }, - }; - const expectedError = new Error('expected'); - client.locationsClient.getLocation = stubSimpleCall(undefined, expectedError); - await assert.rejects(client.getLocation(request, expectedOptions), expectedError); - assert((client.locationsClient.getLocation as SinonStub) - .getCall(0).calledWith(request, expectedOptions, undefined)); - }); + it('invokes getLocation with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.GetLocationRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.locationsClient.getLocation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects( + client.getLocation(request, expectedOptions), + expectedError + ); + assert( + (client.locationsClient.getLocation as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); }); - describe('listLocationsAsync', () => { - it('uses async iteration with listLocations without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedResponse = [ - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - generateSampleMessage( - new LocationProtos.google.cloud.location.Location() - ), - ]; - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - const iterable = client.listLocationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + }); + describe('listLocationsAsync', () => { + it('uses async iteration with listLocations without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedResponse = [ + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + generateSampleMessage( + new LocationProtos.google.cloud.location.Location() + ), + ]; + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + const iterable = client.listLocationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert.strictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + it('uses async iteration with listLocations with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new LocationProtos.google.cloud.location.ListLocationsRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedError = new Error('expected'); + client.locationsClient.descriptors.page.listLocations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.listLocationsAsync(request); + await assert.rejects(async () => { + const responses: LocationProtos.google.cloud.location.ILocation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + assert.strictEqual( + ( + client.locationsClient.descriptors.page.listLocations + .asyncIterate as SinonStub + ).getCall(0).args[2].otherArgs.headers['x-goog-request-params'], + expectedHeaderRequestParams + ); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const response = await client.getOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes getOperation without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + client.operationsClient.getOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.getOperation( + request, + undefined, + ( + err?: Error | null, + result?: operationsProtos.google.longrunning.Operation | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); - it('uses async iteration with listLocations with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new LocationProtos.google.cloud.location.ListLocationsRequest() - ); - request.name = ''; - const expectedHeaderRequestParams = 'name='; - const expectedError = new Error('expected'); - client.locationsClient.descriptors.page.listLocations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.listLocationsAsync(request); - await assert.rejects(async () => { - const responses: LocationProtos.google.cloud.location.ILocation[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - assert.strictEqual( - (client.locationsClient.descriptors.page.listLocations.asyncIterate as SinonStub) - .getCall(0).args[2].otherArgs.headers['x-goog-request-params'], - expectedHeaderRequestParams - ); - }); + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); }); - describe('getOperation', () => { - it('invokes getOperation without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = stubSimpleCall(expectedResponse); - const response = await client.getOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes getOperation without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new operationsProtos.google.longrunning.Operation() - ); - client.operationsClient.getOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.getOperation( - request, - undefined, - ( - err?: Error | null, - result?: operationsProtos.google.longrunning.Operation | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0)); - }); - it('invokes getOperation with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.GetOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.getOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.getOperation(request)}, expectedError); - assert((client.operationsClient.getOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes getOperation with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.GetOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.getOperation(request); + }, expectedError); + assert( + (client.operationsClient.getOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); }); - describe('cancelOperation', () => { - it('invokes cancelOperation without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = stubSimpleCall(expectedResponse); - const response = await client.cancelOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes cancelOperation without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.cancelOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.cancelOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0)); - }); - it('invokes cancelOperation with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.CancelOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.cancelOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.cancelOperation(request)}, expectedError); - assert((client.operationsClient.cancelOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + }); + describe('cancelOperation', () => { + it('invokes cancelOperation without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = + stubSimpleCall(expectedResponse); + const response = await client.cancelOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); }); - describe('deleteOperation', () => { - it('invokes deleteOperation without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = stubSimpleCall(expectedResponse); - const response = await client.deleteOperation(request); - assert.deepStrictEqual(response, [expectedResponse]); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request) - ); - }); - it('invokes deleteOperation without error using callback', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedResponse = generateSampleMessage( - new protos.google.protobuf.Empty() - ); - client.operationsClient.deleteOperation = sinon.stub().callsArgWith(2, null, expectedResponse); - const promise = new Promise((resolve, reject) => { - client.operationsClient.deleteOperation( - request, - undefined, - ( - err?: Error | null, - result?: protos.google.protobuf.Empty | null - ) => { - if (err) { - reject(err); - } else { - resolve(result); - } - }); - }); - const response = await promise; - assert.deepStrictEqual(response, expectedResponse); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0)); - }); - it('invokes deleteOperation with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.DeleteOperationRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.deleteOperation = stubSimpleCall(undefined, expectedError); - await assert.rejects(async () => {await client.deleteOperation(request)}, expectedError); - assert((client.operationsClient.deleteOperation as SinonStub) - .getCall(0).calledWith(request)); - }); + it('invokes cancelOperation without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.cancelOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.cancelOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.cancelOperation as SinonStub).getCall(0)); }); - describe('listOperationsAsync', () => { - it('uses async iteration with listOperations without error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedResponse = [ - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsResponse() - ), - ]; - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(expectedResponse); - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - const iterable = client.operationsClient.listOperationsAsync(request); - for await (const resource of iterable) { - responses.push(resource!); + it('invokes cancelOperation with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.CancelOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.cancelOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.cancelOperation(request); + }, expectedError); + assert( + (client.operationsClient.cancelOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('deleteOperation', () => { + it('invokes deleteOperation without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = + stubSimpleCall(expectedResponse); + const response = await client.deleteOperation(request); + assert.deepStrictEqual(response, [expectedResponse]); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + it('invokes deleteOperation without error using callback', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedResponse = generateSampleMessage( + new protos.google.protobuf.Empty() + ); + client.operationsClient.deleteOperation = sinon + .stub() + .callsArgWith(2, null, expectedResponse); + const promise = new Promise((resolve, reject) => { + client.operationsClient.deleteOperation( + request, + undefined, + ( + err?: Error | null, + result?: protos.google.protobuf.Empty | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); } - assert.deepStrictEqual(responses, expectedResponse); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); - it('uses async iteration with listOperations with error', async () => { - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - const request = generateSampleMessage( - new operationsProtos.google.longrunning.ListOperationsRequest() - ); - const expectedError = new Error('expected'); - client.operationsClient.descriptor.listOperations.asyncIterate = stubAsyncIterationCall(undefined, expectedError); - const iterable = client.operationsClient.listOperationsAsync(request); - await assert.rejects(async () => { - const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = []; - for await (const resource of iterable) { - responses.push(resource!); - } - }); - assert.deepStrictEqual( - (client.operationsClient.descriptor.listOperations.asyncIterate as SinonStub) - .getCall(0).args[1], request); - }); + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + assert((client.operationsClient.deleteOperation as SinonStub).getCall(0)); + }); + it('invokes deleteOperation with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.DeleteOperationRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.deleteOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(async () => { + await client.deleteOperation(request); + }, expectedError); + assert( + (client.operationsClient.deleteOperation as SinonStub) + .getCall(0) + .calledWith(request) + ); + }); + }); + describe('listOperationsAsync', () => { + it('uses async iteration with listOperations without error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedResponse = [ + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsResponse() + ), + ]; + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + const iterable = client.operationsClient.listOperationsAsync(request); + for await (const resource of iterable) { + responses.push(resource!); + } + assert.deepStrictEqual(responses, expectedResponse); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + it('uses async iteration with listOperations with error', async () => { + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new operationsProtos.google.longrunning.ListOperationsRequest() + ); + const expectedError = new Error('expected'); + client.operationsClient.descriptor.listOperations.asyncIterate = + stubAsyncIterationCall(undefined, expectedError); + const iterable = client.operationsClient.listOperationsAsync(request); + await assert.rejects(async () => { + const responses: operationsProtos.google.longrunning.ListOperationsResponse[] = + []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request + ); + }); + }); + + describe('Path templates', () => { + describe('appProfile', () => { + const fakePath = '/rendered/path/appProfile'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + app_profile: 'appProfileValue', + }; + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.appProfilePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.appProfilePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('appProfilePath', () => { + const result = client.appProfilePath( + 'projectValue', + 'instanceValue', + 'appProfileValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.appProfilePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromAppProfileName', () => { + const result = client.matchProjectFromAppProfileName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.appProfilePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromAppProfileName', () => { + const result = client.matchInstanceFromAppProfileName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.appProfilePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchAppProfileFromAppProfileName', () => { + const result = client.matchAppProfileFromAppProfileName(fakePath); + assert.strictEqual(result, 'appProfileValue'); + assert( + (client.pathTemplates.appProfilePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); }); - describe('Path templates', () => { - - describe('appProfile', () => { - const fakePath = "/rendered/path/appProfile"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - app_profile: "appProfileValue", - }; - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.appProfilePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.appProfilePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('appProfilePath', () => { - const result = client.appProfilePath("projectValue", "instanceValue", "appProfileValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.appProfilePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromAppProfileName', () => { - const result = client.matchProjectFromAppProfileName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.appProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromAppProfileName', () => { - const result = client.matchInstanceFromAppProfileName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.appProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchAppProfileFromAppProfileName', () => { - const result = client.matchAppProfileFromAppProfileName(fakePath); - assert.strictEqual(result, "appProfileValue"); - assert((client.pathTemplates.appProfilePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); - - describe('backup', () => { - const fakePath = "/rendered/path/backup"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - cluster: "clusterValue", - backup: "backupValue", - }; - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.backupPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.backupPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('backupPath', () => { - const result = client.backupPath("projectValue", "instanceValue", "clusterValue", "backupValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.backupPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromBackupName', () => { - const result = client.matchProjectFromBackupName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromBackupName', () => { - const result = client.matchInstanceFromBackupName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClusterFromBackupName', () => { - const result = client.matchClusterFromBackupName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchBackupFromBackupName', () => { - const result = client.matchBackupFromBackupName(fakePath); - assert.strictEqual(result, "backupValue"); - assert((client.pathTemplates.backupPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('backup', () => { + const fakePath = '/rendered/path/backup'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + cluster: 'clusterValue', + backup: 'backupValue', + }; + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.backupPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.backupPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('backupPath', () => { + const result = client.backupPath( + 'projectValue', + 'instanceValue', + 'clusterValue', + 'backupValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.backupPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromBackupName', () => { + const result = client.matchProjectFromBackupName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromBackupName', () => { + const result = client.matchInstanceFromBackupName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchClusterFromBackupName', () => { + const result = client.matchClusterFromBackupName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchBackupFromBackupName', () => { + const result = client.matchBackupFromBackupName(fakePath); + assert.strictEqual(result, 'backupValue'); + assert( + (client.pathTemplates.backupPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); - describe('cluster', () => { - const fakePath = "/rendered/path/cluster"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - cluster: "clusterValue", - }; - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.clusterPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.clusterPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('clusterPath', () => { - const result = client.clusterPath("projectValue", "instanceValue", "clusterValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.clusterPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromClusterName', () => { - const result = client.matchProjectFromClusterName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromClusterName', () => { - const result = client.matchInstanceFromClusterName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClusterFromClusterName', () => { - const result = client.matchClusterFromClusterName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.clusterPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('cluster', () => { + const fakePath = '/rendered/path/cluster'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + cluster: 'clusterValue', + }; + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.clusterPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.clusterPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('clusterPath', () => { + const result = client.clusterPath( + 'projectValue', + 'instanceValue', + 'clusterValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.clusterPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromClusterName', () => { + const result = client.matchProjectFromClusterName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromClusterName', () => { + const result = client.matchInstanceFromClusterName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchClusterFromClusterName', () => { + const result = client.matchClusterFromClusterName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.clusterPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); - describe('hotTablet', () => { - const fakePath = "/rendered/path/hotTablet"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - cluster: "clusterValue", - hot_tablet: "hotTabletValue", - }; - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.hotTabletPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.hotTabletPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('hotTabletPath', () => { - const result = client.hotTabletPath("projectValue", "instanceValue", "clusterValue", "hotTabletValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.hotTabletPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromHotTabletName', () => { - const result = client.matchProjectFromHotTabletName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.hotTabletPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromHotTabletName', () => { - const result = client.matchInstanceFromHotTabletName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.hotTabletPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClusterFromHotTabletName', () => { - const result = client.matchClusterFromHotTabletName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.hotTabletPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchHotTabletFromHotTabletName', () => { - const result = client.matchHotTabletFromHotTabletName(fakePath); - assert.strictEqual(result, "hotTabletValue"); - assert((client.pathTemplates.hotTabletPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('hotTablet', () => { + const fakePath = '/rendered/path/hotTablet'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + cluster: 'clusterValue', + hot_tablet: 'hotTabletValue', + }; + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.hotTabletPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.hotTabletPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('hotTabletPath', () => { + const result = client.hotTabletPath( + 'projectValue', + 'instanceValue', + 'clusterValue', + 'hotTabletValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.hotTabletPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromHotTabletName', () => { + const result = client.matchProjectFromHotTabletName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.hotTabletPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromHotTabletName', () => { + const result = client.matchInstanceFromHotTabletName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.hotTabletPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchClusterFromHotTabletName', () => { + const result = client.matchClusterFromHotTabletName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.hotTabletPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchHotTabletFromHotTabletName', () => { + const result = client.matchHotTabletFromHotTabletName(fakePath); + assert.strictEqual(result, 'hotTabletValue'); + assert( + (client.pathTemplates.hotTabletPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); - describe('instance', () => { - const fakePath = "/rendered/path/instance"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - }; - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.instancePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.instancePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('instancePath', () => { - const result = client.instancePath("projectValue", "instanceValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.instancePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromInstanceName', () => { - const result = client.matchProjectFromInstanceName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromInstanceName', () => { - const result = client.matchInstanceFromInstanceName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.instancePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('instance', () => { + const fakePath = '/rendered/path/instance'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + }; + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.instancePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.instancePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('instancePath', () => { + const result = client.instancePath('projectValue', 'instanceValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.instancePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromInstanceName', () => { + const result = client.matchProjectFromInstanceName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromInstanceName', () => { + const result = client.matchInstanceFromInstanceName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.instancePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); - describe('snapshot', () => { - const fakePath = "/rendered/path/snapshot"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - cluster: "clusterValue", - snapshot: "snapshotValue", - }; - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.snapshotPathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.snapshotPathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('snapshotPath', () => { - const result = client.snapshotPath("projectValue", "instanceValue", "clusterValue", "snapshotValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.snapshotPathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromSnapshotName', () => { - const result = client.matchProjectFromSnapshotName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromSnapshotName', () => { - const result = client.matchInstanceFromSnapshotName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchClusterFromSnapshotName', () => { - const result = client.matchClusterFromSnapshotName(fakePath); - assert.strictEqual(result, "clusterValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchSnapshotFromSnapshotName', () => { - const result = client.matchSnapshotFromSnapshotName(fakePath); - assert.strictEqual(result, "snapshotValue"); - assert((client.pathTemplates.snapshotPathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('snapshot', () => { + const fakePath = '/rendered/path/snapshot'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + cluster: 'clusterValue', + snapshot: 'snapshotValue', + }; + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.snapshotPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.snapshotPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('snapshotPath', () => { + const result = client.snapshotPath( + 'projectValue', + 'instanceValue', + 'clusterValue', + 'snapshotValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.snapshotPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromSnapshotName', () => { + const result = client.matchProjectFromSnapshotName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromSnapshotName', () => { + const result = client.matchInstanceFromSnapshotName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchClusterFromSnapshotName', () => { + const result = client.matchClusterFromSnapshotName(fakePath); + assert.strictEqual(result, 'clusterValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchSnapshotFromSnapshotName', () => { + const result = client.matchSnapshotFromSnapshotName(fakePath); + assert.strictEqual(result, 'snapshotValue'); + assert( + (client.pathTemplates.snapshotPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); - describe('table', () => { - const fakePath = "/rendered/path/table"; - const expectedParameters = { - project: "projectValue", - instance: "instanceValue", - table: "tableValue", - }; - const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ - credentials: {client_email: 'bogus', private_key: 'bogus'}, - projectId: 'bogus', - }); - client.initialize(); - client.pathTemplates.tablePathTemplate.render = - sinon.stub().returns(fakePath); - client.pathTemplates.tablePathTemplate.match = - sinon.stub().returns(expectedParameters); - - it('tablePath', () => { - const result = client.tablePath("projectValue", "instanceValue", "tableValue"); - assert.strictEqual(result, fakePath); - assert((client.pathTemplates.tablePathTemplate.render as SinonStub) - .getCall(-1).calledWith(expectedParameters)); - }); - - it('matchProjectFromTableName', () => { - const result = client.matchProjectFromTableName(fakePath); - assert.strictEqual(result, "projectValue"); - assert((client.pathTemplates.tablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchInstanceFromTableName', () => { - const result = client.matchInstanceFromTableName(fakePath); - assert.strictEqual(result, "instanceValue"); - assert((client.pathTemplates.tablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - - it('matchTableFromTableName', () => { - const result = client.matchTableFromTableName(fakePath); - assert.strictEqual(result, "tableValue"); - assert((client.pathTemplates.tablePathTemplate.match as SinonStub) - .getCall(-1).calledWith(fakePath)); - }); - }); + describe('table', () => { + const fakePath = '/rendered/path/table'; + const expectedParameters = { + project: 'projectValue', + instance: 'instanceValue', + table: 'tableValue', + }; + const client = new bigtabletableadminModule.v2.BigtableTableAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.tablePathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.tablePathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('tablePath', () => { + const result = client.tablePath( + 'projectValue', + 'instanceValue', + 'tableValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.tablePathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromTableName', () => { + const result = client.matchProjectFromTableName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.tablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchInstanceFromTableName', () => { + const result = client.matchInstanceFromTableName(fakePath); + assert.strictEqual(result, 'instanceValue'); + assert( + (client.pathTemplates.tablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchTableFromTableName', () => { + const result = client.matchTableFromTableName(fakePath); + assert.strictEqual(result, 'tableValue'); + assert( + (client.pathTemplates.tablePathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); }); + }); });