Skip to content

Commit

Permalink
feat: support apiEndpoint override in client constructor (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and JustinBeckwith committed Jun 5, 2019
1 parent 2f223c5 commit 85a4794
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
14 changes: 13 additions & 1 deletion packages/google-privacy-dlp/src/v2/dlp_service_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,18 @@ class DlpServiceClient {
* API remote host.
*/
constructor(opts) {
opts = opts || {};
this._descriptors = {};

const servicePath =
opts.servicePath || opts.apiEndpoint || this.constructor.servicePath;

// Ensure that options include the service address and port.
opts = Object.assign(
{
clientConfig: {},
port: this.constructor.port,
servicePath: this.constructor.servicePath,
servicePath,
},
opts
);
Expand Down Expand Up @@ -241,6 +245,14 @@ class DlpServiceClient {
return 'dlp.googleapis.com';
}

/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
*/
static get apiEndpoint() {
return 'dlp.googleapis.com';
}

/**
* The port for this API service.
*/
Expand Down
12 changes: 6 additions & 6 deletions packages/google-privacy-dlp/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"updateTime": "2019-05-28T14:39:35.317121Z",
"updateTime": "2019-06-05T14:17:45.145143Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.21.0",
"dockerImage": "googleapis/artman@sha256:28d4271586772b275cd3bc95cb46bd227a24d3c9048de45dccdb7f3afb0bfba9"
"version": "0.23.1",
"dockerImage": "googleapis/artman@sha256:9d5cae1454da64ac3a87028f8ef486b04889e351c83bb95e83b8fab3959faed0"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "7ca19138ccebe219a67be2245200e821b3e32123",
"internalRef": "249916728"
"sha": "47c142a7cecc6efc9f6f8af804b8be55392b795b",
"internalRef": "251635729"
}
},
{
"template": {
"name": "node_library",
"origin": "synthtool.gcp",
"version": "2019.4.10"
"version": "2019.5.2"
}
}
],
Expand Down
21 changes: 21 additions & 0 deletions packages/google-privacy-dlp/test/gapic-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ const error = new Error();
error.code = FAKE_STATUS_CODE;

describe('DlpServiceClient', () => {
it('has servicePath', () => {
const servicePath = dlpModule.v2.DlpServiceClient.servicePath;
assert(servicePath);
});

it('has apiEndpoint', () => {
const apiEndpoint = dlpModule.v2.DlpServiceClient.apiEndpoint;
assert(apiEndpoint);
});

it('has port', () => {
const port = dlpModule.v2.DlpServiceClient.port;
assert(port);
assert(typeof port === 'number');
});

it('should create a client with no options', () => {
const client = new dlpModule.v2.DlpServiceClient();
assert(client);
});

describe('inspectContent', () => {
it('invokes inspectContent without error', done => {
const client = new dlpModule.v2.DlpServiceClient({
Expand Down

0 comments on commit 85a4794

Please sign in to comment.