diff --git a/packages/google-cloud-billing-budgets/src/v1/budget_service_client.ts b/packages/google-cloud-billing-budgets/src/v1/budget_service_client.ts index 3a15d396117..795eac4ded7 100644 --- a/packages/google-cloud-billing-budgets/src/v1/budget_service_client.ts +++ b/packages/google-cloud-billing-budgets/src/v1/budget_service_client.ts @@ -49,6 +49,7 @@ const version = require('../../../package.json').version; export class BudgetServiceClient { 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 BudgetServiceClient { longrunning: {}, batching: {}, }; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; budgetServiceStub?: Promise<{[name: string]: Function}>; @@ -103,6 +105,9 @@ export class BudgetServiceClient { const staticMembers = this.constructor as typeof BudgetServiceClient; 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 = @@ -185,6 +190,9 @@ export class BudgetServiceClient { // 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; } /** @@ -213,7 +221,8 @@ export class BudgetServiceClient { ) : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.billing.budgets.v1.BudgetService, - 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-billing-budgets/src/v1beta1/budget_service_client.ts b/packages/google-cloud-billing-budgets/src/v1beta1/budget_service_client.ts index d90f3c96f83..09b7c3ed067 100644 --- a/packages/google-cloud-billing-budgets/src/v1beta1/budget_service_client.ts +++ b/packages/google-cloud-billing-budgets/src/v1beta1/budget_service_client.ts @@ -49,6 +49,7 @@ const version = require('../../../package.json').version; export class BudgetServiceClient { 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 BudgetServiceClient { longrunning: {}, batching: {}, }; + warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: {[name: string]: Function}; pathTemplates: {[name: string]: gax.PathTemplate}; budgetServiceStub?: Promise<{[name: string]: Function}>; @@ -103,6 +105,9 @@ export class BudgetServiceClient { const staticMembers = this.constructor as typeof BudgetServiceClient; 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 = @@ -185,6 +190,9 @@ export class BudgetServiceClient { // 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; } /** @@ -214,7 +222,8 @@ export class BudgetServiceClient { : // eslint-disable-next-line @typescript-eslint/no-explicit-any (this._protos as any).google.cloud.billing.budgets.v1beta1 .BudgetService, - this._opts + this._opts, + this._providedCustomServicePath ) as Promise<{[method: string]: Function}>; // Iterate over each of the methods that the service provides