Skip to content

Commit 0f75d38

Browse files
yoshi-automationJustinBeckwith
authored andcommitted
feat: support apiEndpoint override in client constructor (#422)
1 parent af0dc5f commit 0f75d38

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

src/v1/datastore_client.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,15 @@ class DatastoreClient {
6262
constructor(opts) {
6363
this._descriptors = {};
6464

65+
const servicePath =
66+
opts.servicePath || opts.apiEndpoint || this.constructor.servicePath;
67+
6568
// Ensure that options include the service address and port.
6669
opts = Object.assign(
6770
{
6871
clientConfig: {},
6972
port: this.constructor.port,
70-
servicePath: this.constructor.servicePath,
73+
servicePath,
7174
},
7275
opts
7376
);
@@ -154,6 +157,14 @@ class DatastoreClient {
154157
return 'datastore.googleapis.com';
155158
}
156159

160+
/**
161+
* The DNS address for this API service - same as servicePath(),
162+
* exists for compatibility reasons.
163+
*/
164+
static get apiEndpoint() {
165+
return 'datastore.googleapis.com';
166+
}
167+
157168
/**
158169
* The port for this API service.
159170
*/

synth.metadata

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"updateTime": "2019-05-22T11:11:48.365770Z",
2+
"updateTime": "2019-06-04T19:30:55.849433Z",
33
"sources": [
44
{
55
"generator": {
66
"name": "artman",
7-
"version": "0.20.0",
8-
"dockerImage": "googleapis/artman@sha256:3246adac900f4bdbd62920e80de2e5877380e44036b3feae13667ec255ebf5ec"
7+
"version": "0.23.0",
8+
"dockerImage": "googleapis/artman@sha256:846102ebf7ea2239162deea69f64940443b4147f7c2e68d64b332416f74211ba"
99
}
1010
},
1111
{
1212
"git": {
1313
"name": "googleapis",
1414
"remote": "https://github.com/googleapis/googleapis.git",
15-
"sha": "6ea045ad2ed95863557b9856760fa8760d8daee0",
16-
"internalRef": "249345152"
15+
"sha": "0026f4b890ed9e2388fb0573c0727defa6f5b82e",
16+
"internalRef": "251265049"
1717
}
1818
},
1919
{

test/gapic-v1.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ const error = new Error();
2323
error.code = FAKE_STATUS_CODE;
2424

2525
describe('DatastoreClient', () => {
26+
it('has servicePath', () => {
27+
const servicePath = datastoreModule.v1.DatastoreClient.servicePath;
28+
assert(servicePath);
29+
});
30+
31+
it('has apiEndpoint', () => {
32+
const apiEndpoint = datastoreModule.v1.DatastoreClient.apiEndpoint;
33+
assert(apiEndpoint);
34+
});
35+
36+
it('has port', () => {
37+
const port = datastoreModule.v1.DatastoreClient.port;
38+
assert(port);
39+
assert(typeof port === 'number');
40+
});
41+
2642
describe('lookup', () => {
2743
it('invokes lookup without error', done => {
2844
const client = new datastoreModule.v1.DatastoreClient({

0 commit comments

Comments
 (0)