Skip to content

Commit

Permalink
fix: default opts to empty object (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshi-automation authored and JustinBeckwith committed Jun 6, 2019
1 parent 7d02ccd commit e27b0b4
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 8 deletions.
14 changes: 13 additions & 1 deletion packages/google-cloud-automl/src/v1beta1/auto_ml_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,18 @@ class AutoMlClient {
* 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 @@ -351,6 +355,14 @@ class AutoMlClient {
return 'automl.googleapis.com';
}

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

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

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

/**
* The port for this API service.
*/
Expand Down
12 changes: 6 additions & 6 deletions packages/google-cloud-automl/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"updateTime": "2019-05-22T22:20:23.138969Z",
"updateTime": "2019-06-05T14:13:08.385399Z",
"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": "f792303254ea54442d03ca470ffb38930bda7806",
"internalRef": "249516437"
"sha": "47c142a7cecc6efc9f6f8af804b8be55392b795b",
"internalRef": "251635729"
}
},
{
"template": {
"name": "node_library",
"origin": "synthtool.gcp",
"version": "2019.4.10"
"version": "2019.5.2"
}
}
],
Expand Down
44 changes: 44 additions & 0 deletions packages/google-cloud-automl/test/gapic-v1beta1.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ const error = new Error();
error.code = FAKE_STATUS_CODE;

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

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

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

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

describe('createDataset', () => {
it('invokes createDataset without error', done => {
const client = new automlModule.v1beta1.AutoMlClient({
Expand Down Expand Up @@ -1988,6 +2009,29 @@ describe('AutoMlClient', () => {
});
});
describe('PredictionServiceClient', () => {
it('has servicePath', () => {
const servicePath =
automlModule.v1beta1.PredictionServiceClient.servicePath;
assert(servicePath);
});

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

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

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

describe('predict', () => {
it('invokes predict without error', done => {
const client = new automlModule.v1beta1.PredictionServiceClient({
Expand Down

0 comments on commit e27b0b4

Please sign in to comment.