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. (#468)

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 4a42c1b commit 3342ca9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/google-container/src/v1/cluster_manager_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const version = require('../../../package.json').version;
export class ClusterManagerClient {
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 @@ -59,6 +60,7 @@ export class ClusterManagerClient {
longrunning: {},
batching: {},
};
warn: (code: string, message: string, warnType?: string) => void;
innerApiCalls: {[name: string]: Function};
clusterManagerStub?: Promise<{[name: string]: Function}>;

Expand Down Expand Up @@ -101,6 +103,9 @@ export class ClusterManagerClient {
const staticMembers = this.constructor as typeof ClusterManagerClient;
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 @@ -171,6 +176,9 @@ export class ClusterManagerClient {
// 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 @@ -199,7 +207,8 @@ export class ClusterManagerClient {
)
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
(this._protos as any).google.container.v1.ClusterManager,
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 @@ -1396,7 +1405,7 @@ export class ClusterManagerClient {
project_id: request.projectId || '',
});
this.initialize();
gax.warn(
this.warn(
'DEP$ClusterManager-$SetLocations',
'SetLocations is deprecated and may be removed in a future version.',
'DeprecationWarning'
Expand Down
6 changes: 6 additions & 0 deletions packages/google-container/test/gapic_cluster_manager_v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1232,6 +1232,7 @@ describe('v1.ClusterManagerClient', () => {
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
const stub = sinon.stub(client, 'warn');
client.initialize();
const request = generateSampleMessage(
new protos.google.container.v1.SetLocationsRequest()
Expand All @@ -1251,6 +1252,7 @@ describe('v1.ClusterManagerClient', () => {
);
client.innerApiCalls.setLocations = stubSimpleCall(expectedResponse);
const [response] = await client.setLocations(request);
assert(stub.calledOnce);
assert.deepStrictEqual(response, expectedResponse);
assert(
(client.innerApiCalls.setLocations as SinonStub)
Expand All @@ -1264,6 +1266,7 @@ describe('v1.ClusterManagerClient', () => {
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
const stub = sinon.stub(client, 'warn');
client.initialize();
const request = generateSampleMessage(
new protos.google.container.v1.SetLocationsRequest()
Expand Down Expand Up @@ -1299,6 +1302,7 @@ describe('v1.ClusterManagerClient', () => {
);
});
const response = await promise;
assert(stub.calledOnce);
assert.deepStrictEqual(response, expectedResponse);
assert(
(client.innerApiCalls.setLocations as SinonStub)
Expand All @@ -1312,6 +1316,7 @@ describe('v1.ClusterManagerClient', () => {
credentials: {client_email: 'bogus', private_key: 'bogus'},
projectId: 'bogus',
});
const stub = sinon.stub(client, 'warn');
client.initialize();
const request = generateSampleMessage(
new protos.google.container.v1.SetLocationsRequest()
Expand All @@ -1332,6 +1337,7 @@ describe('v1.ClusterManagerClient', () => {
expectedError
);
await assert.rejects(client.setLocations(request), expectedError);
assert(stub.calledOnce);
assert(
(client.innerApiCalls.setLocations as SinonStub)
.getCall(0)
Expand Down

0 comments on commit 3342ca9

Please sign in to comment.