Skip to content

Commit

Permalink
feat: support apiEndpoint override in client constructor (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and JustinBeckwith committed Jun 4, 2019
1 parent af0dc5f commit 0f75d38
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
13 changes: 12 additions & 1 deletion src/v1/datastore_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ class DatastoreClient {
constructor(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 @@ -154,6 +157,14 @@ class DatastoreClient {
return 'datastore.googleapis.com';
}

/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
*/
static get apiEndpoint() {
return 'datastore.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-22T11:11:48.365770Z",
"updateTime": "2019-06-04T19:30:55.849433Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.20.0",
"dockerImage": "googleapis/artman@sha256:3246adac900f4bdbd62920e80de2e5877380e44036b3feae13667ec255ebf5ec"
"version": "0.23.0",
"dockerImage": "googleapis/artman@sha256:846102ebf7ea2239162deea69f64940443b4147f7c2e68d64b332416f74211ba"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "6ea045ad2ed95863557b9856760fa8760d8daee0",
"internalRef": "249345152"
"sha": "0026f4b890ed9e2388fb0573c0727defa6f5b82e",
"internalRef": "251265049"
}
},
{
Expand Down
16 changes: 16 additions & 0 deletions test/gapic-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ const error = new Error();
error.code = FAKE_STATUS_CODE;

describe('DatastoreClient', () => {
it('has servicePath', () => {
const servicePath = datastoreModule.v1.DatastoreClient.servicePath;
assert(servicePath);
});

it('has apiEndpoint', () => {
const apiEndpoint = datastoreModule.v1.DatastoreClient.apiEndpoint;
assert(apiEndpoint);
});

it('has port', () => {
const port = datastoreModule.v1.DatastoreClient.port;
assert(port);
assert(typeof port === 'number');
});

describe('lookup', () => {
it('invokes lookup without error', done => {
const client = new datastoreModule.v1.DatastoreClient({
Expand Down

0 comments on commit 0f75d38

Please sign in to comment.