Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
feat: support apiEndpoint override in client constructor (#30)
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 cb797de commit 1192afd
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
14 changes: 13 additions & 1 deletion src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ class RecaptchaEnterpriseServiceV1Beta1Client {
* 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 @@ -155,6 +159,14 @@ class RecaptchaEnterpriseServiceV1Beta1Client {
return 'recaptchaenterprise.googleapis.com';
}

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

/**
* The port for this API service.
*/
Expand Down
10 changes: 5 additions & 5 deletions synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"updateTime": "2019-05-21T11:22:01.138953Z",
"updateTime": "2019-06-05T14:23:52.798433Z",
"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": "32a10f69e2c9ce15bba13ab1ff928bacebb25160",
"internalRef": "249058354"
"sha": "47c142a7cecc6efc9f6f8af804b8be55392b795b",
"internalRef": "251635729"
}
},
{
Expand Down
27 changes: 27 additions & 0 deletions 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('RecaptchaEnterpriseServiceV1Beta1Client', () => {
it('has servicePath', () => {
const servicePath =
recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client
.servicePath;
assert(servicePath);
});

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

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

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

describe('createAssessment', () => {
it('invokes createAssessment without error', done => {
const client = new recaptchaenterpriseModule.v1beta1.RecaptchaEnterpriseServiceV1Beta1Client(
Expand Down

0 comments on commit 1192afd

Please sign in to comment.