Skip to content

Commit

Permalink
feat: support apiEndpoint override in client constructor (#204)
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 0f82965 commit 70c9fe8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ class OsLoginServiceClient {
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 @@ -164,6 +167,14 @@ class OsLoginServiceClient {
return 'oslogin.googleapis.com';
}

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

/**
* The port for this API service.
*/
Expand Down
10 changes: 5 additions & 5 deletions packages/google-cloud-oslogin/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"updateTime": "2019-05-21T11:20:14.671818Z",
"updateTime": "2019-06-04T19:38:15.784953Z",
"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": "32a10f69e2c9ce15bba13ab1ff928bacebb25160",
"internalRef": "249058354"
"sha": "0026f4b890ed9e2388fb0573c0727defa6f5b82e",
"internalRef": "251265049"
}
},
{
Expand Down
16 changes: 16 additions & 0 deletions packages/google-cloud-oslogin/test/gapic-v1beta.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('OsLoginServiceClient', () => {
it('has servicePath', () => {
const servicePath = osLoginModule.v1beta.OsLoginServiceClient.servicePath;
assert(servicePath);
});

it('has apiEndpoint', () => {
const apiEndpoint = osLoginModule.v1beta.OsLoginServiceClient.apiEndpoint;
assert(apiEndpoint);
});

it('has port', () => {
const port = osLoginModule.v1beta.OsLoginServiceClient.port;
assert(port);
assert(typeof port === 'number');
});

describe('deletePosixAccount', () => {
it('invokes deletePosixAccount without error', done => {
const client = new osLoginModule.v1beta.OsLoginServiceClient({
Expand Down

0 comments on commit 70c9fe8

Please sign in to comment.