Skip to content

Commit

Permalink
feat: support apiEndpoint override in client constructor (#393)
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 5c1ae7b commit 7b3ccf4
Show file tree
Hide file tree
Showing 14 changed files with 277 additions and 13 deletions.
14 changes: 13 additions & 1 deletion packages/google-cloud-vision/src/v1/image_annotator_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ class ImageAnnotatorClient {
* 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 @@ -202,6 +206,14 @@ class ImageAnnotatorClient {
return 'vision.googleapis.com';
}

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

/**
* The port for this API service.
*/
Expand Down
14 changes: 13 additions & 1 deletion packages/google-cloud-vision/src/v1/product_search_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,18 @@ class ProductSearchClient {
* 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 @@ -255,6 +259,14 @@ class ProductSearchClient {
return 'vision.googleapis.com';
}

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

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

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

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

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

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

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

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

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

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

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

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

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

/**
* The port for this API service.
*/
Expand Down
10 changes: 5 additions & 5 deletions packages/google-cloud-vision/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"updateTime": "2019-05-28T23:46:31.467800Z",
"updateTime": "2019-06-05T14:31:18.354995Z",
"sources": [
{
"generator": {
"name": "artman",
"version": "0.21.0",
"dockerImage": "googleapis/artman@sha256:28d4271586772b275cd3bc95cb46bd227a24d3c9048de45dccdb7f3afb0bfba9"
"version": "0.23.1",
"dockerImage": "googleapis/artman@sha256:9d5cae1454da64ac3a87028f8ef486b04889e351c83bb95e83b8fab3959faed0"
}
},
{
"git": {
"name": "googleapis",
"remote": "https://github.com/googleapis/googleapis.git",
"sha": "8f6588f68e1f3fc2f6cbb47d12565f9b81926d42",
"internalRef": "250373427"
"sha": "47c142a7cecc6efc9f6f8af804b8be55392b795b",
"internalRef": "251635729"
}
},
{
Expand Down
42 changes: 42 additions & 0 deletions packages/google-cloud-vision/test/gapic-v1.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('ImageAnnotatorClient', () => {
it('has servicePath', () => {
const servicePath = visionModule.v1.ImageAnnotatorClient.servicePath;
assert(servicePath);
});

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

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

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

describe('batchAnnotateImages', () => {
it('invokes batchAnnotateImages without error', done => {
const client = new visionModule.v1.ImageAnnotatorClient({
Expand Down Expand Up @@ -318,6 +339,27 @@ describe('ImageAnnotatorClient', () => {
});
});
describe('ProductSearchClient', () => {
it('has servicePath', () => {
const servicePath = visionModule.v1.ProductSearchClient.servicePath;
assert(servicePath);
});

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

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

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

describe('createProductSet', () => {
it('invokes createProductSet without error', done => {
const client = new visionModule.v1.ProductSearchClient({
Expand Down
21 changes: 21 additions & 0 deletions packages/google-cloud-vision/test/gapic-v1p1beta1.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('ImageAnnotatorClient', () => {
it('has servicePath', () => {
const servicePath = visionModule.v1p1beta1.ImageAnnotatorClient.servicePath;
assert(servicePath);
});

it('has apiEndpoint', () => {
const apiEndpoint = visionModule.v1p1beta1.ImageAnnotatorClient.apiEndpoint;
assert(apiEndpoint);
});

it('has port', () => {
const port = visionModule.v1p1beta1.ImageAnnotatorClient.port;
assert(port);
assert(typeof port === 'number');
});

it('should create a client with no options', () => {
const client = new visionModule.v1p1beta1.ImageAnnotatorClient();
assert(client);
});

describe('batchAnnotateImages', () => {
it('invokes batchAnnotateImages without error', done => {
const client = new visionModule.v1p1beta1.ImageAnnotatorClient({
Expand Down
Loading

0 comments on commit 7b3ccf4

Please sign in to comment.