diff --git a/packages/google-cloud-tasks/src/v2/cloud_tasks_client.ts b/packages/google-cloud-tasks/src/v2/cloud_tasks_client.ts index 2fc818ed18a..a1ab34d1e2f 100644 --- a/packages/google-cloud-tasks/src/v2/cloud_tasks_client.ts +++ b/packages/google-cloud-tasks/src/v2/cloud_tasks_client.ts @@ -49,6 +49,7 @@ const version = require('../../../package.json').version; export class CloudTasksClient { private _terminated = false; private _opts: ClientOptions; + private _providedCustomServicePath: boolean; private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; @@ -60,6 +61,7 @@ export class CloudTasksClient { longrunning: {}, batching: {}, }; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; cloudTasksStub?: Promise<{[name: string]: Function}>; @@ -103,6 +105,9 @@ export class CloudTasksClient { const staticMembers = this.constructor as typeof CloudTasksClient; 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 = @@ -196,6 +201,9 @@ export class CloudTasksClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; } /** @@ -224,7 +232,8 @@ export class CloudTasksClient { ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.tasks.v2.CloudTasks, - this._opts + this._opts, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides diff --git a/packages/google-cloud-tasks/src/v2beta2/cloud_tasks_client.ts b/packages/google-cloud-tasks/src/v2beta2/cloud_tasks_client.ts index d8dead8f97f..85c97a442d1 100644 --- a/packages/google-cloud-tasks/src/v2beta2/cloud_tasks_client.ts +++ b/packages/google-cloud-tasks/src/v2beta2/cloud_tasks_client.ts @@ -49,6 +49,7 @@ const version = require('../../../package.json').version; export class CloudTasksClient { private _terminated = false; private _opts: ClientOptions; + private _providedCustomServicePath: boolean; private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; @@ -60,6 +61,7 @@ export class CloudTasksClient { longrunning: {}, batching: {}, }; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; cloudTasksStub?: Promise<{[name: string]: Function}>; @@ -103,6 +105,9 @@ export class CloudTasksClient { const staticMembers = this.constructor as typeof CloudTasksClient; 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 = @@ -196,6 +201,9 @@ export class CloudTasksClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; } /** @@ -224,7 +232,8 @@ export class CloudTasksClient { ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.tasks.v2beta2.CloudTasks, - this._opts + this._opts, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides diff --git a/packages/google-cloud-tasks/src/v2beta3/cloud_tasks_client.ts b/packages/google-cloud-tasks/src/v2beta3/cloud_tasks_client.ts index 25dbe986703..e7a2ef98261 100644 --- a/packages/google-cloud-tasks/src/v2beta3/cloud_tasks_client.ts +++ b/packages/google-cloud-tasks/src/v2beta3/cloud_tasks_client.ts @@ -49,6 +49,7 @@ const version = require('../../../package.json').version; export class CloudTasksClient { private _terminated = false; private _opts: ClientOptions; + private _providedCustomServicePath: boolean; private _gaxModule: typeof gax | typeof gax.fallback; private _gaxGrpc: gax.GrpcClient | gax.fallback.GrpcClient; private _protos: {}; @@ -60,6 +61,7 @@ export class CloudTasksClient { longrunning: {}, batching: {}, }; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; cloudTasksStub?: Promise<{[name: string]: Function}>; @@ -103,6 +105,9 @@ export class CloudTasksClient { const staticMembers = this.constructor as typeof CloudTasksClient; 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 = @@ -196,6 +201,9 @@ export class CloudTasksClient { // of calling the API is handled in `google-gax`, with this code // merely providing the destination and request information. this.innerApiCalls = {}; + + // Add a warn function to the client constructor so it can be easily tested. + this.warn = gax.warn; } /** @@ -224,7 +232,8 @@ export class CloudTasksClient { ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.tasks.v2beta3.CloudTasks, - this._opts + this._opts, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides