Skip to content

Commit

Permalink
feat: support apiEndpoint override in client constructor (#112)
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 d3273bb commit 02b2522
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@ class SecurityCenterClient {
* 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 @@ -257,6 +261,14 @@ class SecurityCenterClient {
return 'securitycenter.googleapis.com';
}

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

/**
* The port for this API service.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@ class SecurityCenterClient {
* 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 @@ -248,6 +252,14 @@ class SecurityCenterClient {
return 'securitycenter.googleapis.com';
}

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

/**
* The port for this API service.
*/
Expand Down
10 changes: 5 additions & 5 deletions packages/google-cloud-securitycenter/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"updateTime": "2019-05-23T20:32:45.718938Z",
"updateTime": "2019-06-05T14:25:08.839987Z",
"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": "6a2f0244d6a07f2683e4a8cec514425bb27cfa03",
"internalRef": "249677018"
"sha": "47c142a7cecc6efc9f6f8af804b8be55392b795b",
"internalRef": "251635729"
}
},
{
Expand Down
23 changes: 23 additions & 0 deletions packages/google-cloud-securitycenter/test/gapic-v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ const error = new Error();
error.code = FAKE_STATUS_CODE;

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

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

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

it('should create a client with no options', () => {
const client = new securityCenterModule.v1.SecurityCenterClient();
assert(client);
});

describe('createSource', () => {
it('invokes createSource without error', done => {
const client = new securityCenterModule.v1.SecurityCenterClient({
Expand Down
23 changes: 23 additions & 0 deletions packages/google-cloud-securitycenter/test/gapic-v1beta1.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@ const error = new Error();
error.code = FAKE_STATUS_CODE;

describe('SecurityCenterClient', () => {
it('has servicePath', () => {
const servicePath =
securityCenterModule.v1beta1.SecurityCenterClient.servicePath;
assert(servicePath);
});

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

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

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

describe('createSource', () => {
it('invokes createSource without error', done => {
const client = new securityCenterModule.v1beta1.SecurityCenterClient({
Expand Down

0 comments on commit 02b2522

Please sign in to comment.