Skip to content

Commit

Permalink
fix: Updating WORKSPACE files to use the newest version of the Typesc…
Browse files Browse the repository at this point in the history
…ript generator. (#477)

Also removing the explicit generator tag for the IAMPolicy mixin for the kms and pubsub APIS as the generator will now read it from the .yaml file.

PiperOrigin-RevId: 385101839

Source-Link: googleapis/googleapis@80f4042

Source-Link: googleapis/googleapis-gen@d3509d2
  • Loading branch information
gcf-owl-bot[bot] authored Jul 16, 2021
1 parent 2988d3c commit 43ad8c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const version = require('../../../package.json').version;
export class DataTransferServiceClient {
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: {};
Expand All @@ -62,6 +63,7 @@ export class DataTransferServiceClient {
longrunning: {},
batching: {},
};
warn: (code: string, message: string, warnType?: string) => void;
innerApiCalls: {[name: string]: Function};
pathTemplates: {[name: string]: gax.PathTemplate};
dataTransferServiceStub?: Promise<{[name: string]: Function}>;
Expand Down Expand Up @@ -105,6 +107,9 @@ export class DataTransferServiceClient {
const staticMembers = this.constructor as typeof DataTransferServiceClient;
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 =
Expand Down Expand Up @@ -219,6 +224,9 @@ export class DataTransferServiceClient {
// 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;
}

/**
Expand Down Expand Up @@ -248,7 +256,8 @@ export class DataTransferServiceClient {
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
(this._protos as any).google.cloud.bigquery.datatransfer.v1
.DataTransferService,
this._opts
this._opts,
this._providedCustomServicePath
) as Promise<{[method: string]: Function}>;

// Iterate over each of the methods that the service provides
Expand Down Expand Up @@ -1018,7 +1027,7 @@ export class DataTransferServiceClient {
parent: request.parent || '',
});
this.initialize();
gax.warn(
this.warn(
'DEP$DataTransferService-$ScheduleTransferRuns',
'ScheduleTransferRuns is deprecated and may be removed in a future version.',
'DeprecationWarning'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ describe('v1.DataTransferServiceClient', () => {
projectId: 'bogus',
}
);
const stub = sinon.stub(client, 'warn');
client.initialize();
const request = generateSampleMessage(
new protos.google.cloud.bigquery.datatransfer.v1.ScheduleTransferRunsRequest()
Expand All @@ -813,6 +814,7 @@ describe('v1.DataTransferServiceClient', () => {
client.innerApiCalls.scheduleTransferRuns =
stubSimpleCall(expectedResponse);
const [response] = await client.scheduleTransferRuns(request);
assert(stub.calledOnce);
assert.deepStrictEqual(response, expectedResponse);
assert(
(client.innerApiCalls.scheduleTransferRuns as SinonStub)
Expand All @@ -828,6 +830,7 @@ describe('v1.DataTransferServiceClient', () => {
projectId: 'bogus',
}
);
const stub = sinon.stub(client, 'warn');
client.initialize();
const request = generateSampleMessage(
new protos.google.cloud.bigquery.datatransfer.v1.ScheduleTransferRunsRequest()
Expand Down Expand Up @@ -862,6 +865,7 @@ describe('v1.DataTransferServiceClient', () => {
);
});
const response = await promise;
assert(stub.calledOnce);
assert.deepStrictEqual(response, expectedResponse);
assert(
(client.innerApiCalls.scheduleTransferRuns as SinonStub)
Expand All @@ -877,6 +881,7 @@ describe('v1.DataTransferServiceClient', () => {
projectId: 'bogus',
}
);
const stub = sinon.stub(client, 'warn');
client.initialize();
const request = generateSampleMessage(
new protos.google.cloud.bigquery.datatransfer.v1.ScheduleTransferRunsRequest()
Expand All @@ -896,6 +901,7 @@ describe('v1.DataTransferServiceClient', () => {
expectedError
);
await assert.rejects(client.scheduleTransferRuns(request), expectedError);
assert(stub.calledOnce);
assert(
(client.innerApiCalls.scheduleTransferRuns as SinonStub)
.getCall(0)
Expand Down

0 comments on commit 43ad8c9

Please sign in to comment.