Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support apiEndpoint override in client constructor #422

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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