Skip to content

Commit

Permalink
feat: support apiEndpoint override in client constructor (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and JustinBeckwith committed Jun 6, 2019
1 parent 1fb1295 commit 308e1aa
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ class PhishingProtectionServiceV1Beta1Client {
* 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 @@ -149,6 +153,14 @@ class PhishingProtectionServiceV1Beta1Client {
return 'phishingprotection.googleapis.com';
}

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

/**
* The port for this API service.
*/
Expand Down
12 changes: 6 additions & 6 deletions packages/google-cloud-phishingprotection/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"updateTime": "2019-05-23T22:05:10.387551Z",
"updateTime": "2019-06-05T14:22:23.222028Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.20.0",
"dockerImage": "googleapis/artman@sha256:3246adac900f4bdbd62920e80de2e5877380e44036b3feae13667ec255ebf5ec"
"version": "0.23.1",
"dockerImage": "googleapis/artman@sha256:9d5cae1454da64ac3a87028f8ef486b04889e351c83bb95e83b8fab3959faed0"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "2e95f389aff85e3be30ec6bb84eb0cfc36826f9f",
"internalRef": "249721027"
"sha": "47c142a7cecc6efc9f6f8af804b8be55392b795b",
"internalRef": "251635729"
}
},
{
"template": {
"name": "node_library",
"origin": "synthtool.gcp",
"version": "2019.4.10"
"version": "2019.5.2"
}
}
],
Expand Down
27 changes: 27 additions & 0 deletions packages/google-cloud-phishingprotection/test/gapic-v1beta1.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,33 @@ const error = new Error();
error.code = FAKE_STATUS_CODE;

describe('PhishingProtectionServiceV1Beta1Client', () => {
it('has servicePath', () => {
const servicePath =
phishingprotectionModule.v1beta1.PhishingProtectionServiceV1Beta1Client
.servicePath;
assert(servicePath);
});

it('has apiEndpoint', () => {
const apiEndpoint =
phishingprotectionModule.v1beta1.PhishingProtectionServiceV1Beta1Client
.apiEndpoint;
assert(apiEndpoint);
});

it('has port', () => {
const port =
phishingprotectionModule.v1beta1.PhishingProtectionServiceV1Beta1Client
.port;
assert(port);
assert(typeof port === 'number');
});

it('should create a client with no options', () => {
const client = new phishingprotectionModule.v1beta1.PhishingProtectionServiceV1Beta1Client();
assert(client);
});

describe('reportPhishing', () => {
it('invokes reportPhishing without error', done => {
const client = new phishingprotectionModule.v1beta1.PhishingProtectionServiceV1Beta1Client(
Expand Down

0 comments on commit 308e1aa

Please sign in to comment.