diff --git a/src/v1/language_service_client.ts b/src/v1/language_service_client.ts index e842b0d6..c63adb3f 100644 --- a/src/v1/language_service_client.ts +++ b/src/v1/language_service_client.ts @@ -40,6 +40,7 @@ const version = require('../../../package.json').version; export class LanguageServiceClient { 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: {}; @@ -51,6 +52,7 @@ export class LanguageServiceClient { longrunning: {}, batching: {}, }; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; languageServiceStub?: Promise<{[name: string]: Function}>; @@ -93,6 +95,9 @@ export class LanguageServiceClient { const staticMembers = this.constructor as typeof LanguageServiceClient; 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 = @@ -152,6 +157,9 @@ export class LanguageServiceClient { // 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; } /** @@ -180,7 +188,8 @@ export class LanguageServiceClient { ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.language.v1.LanguageService, - this._opts + this._opts, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides diff --git a/src/v1beta2/language_service_client.ts b/src/v1beta2/language_service_client.ts index 4fc97c86..5206d6a9 100644 --- a/src/v1beta2/language_service_client.ts +++ b/src/v1beta2/language_service_client.ts @@ -40,6 +40,7 @@ const version = require('../../../package.json').version; export class LanguageServiceClient { 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: {}; @@ -51,6 +52,7 @@ export class LanguageServiceClient { longrunning: {}, batching: {}, }; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; languageServiceStub?: Promise<{[name: string]: Function}>; @@ -93,6 +95,9 @@ export class LanguageServiceClient { const staticMembers = this.constructor as typeof LanguageServiceClient; 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 = @@ -152,6 +157,9 @@ export class LanguageServiceClient { // 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; } /** @@ -180,7 +188,8 @@ export class LanguageServiceClient { ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.language.v1beta2.LanguageService, - this._opts + this._opts, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides