Skip to content

Commit a079e35

Browse files
yoshi-automationJustinBeckwith
authored andcommitted
feat: support apiEndpoint override in client constructor (#219)
1 parent 14b1761 commit a079e35

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

packages/google-cloud-bigquery-datatransfer/src/v1/data_transfer_service_client.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,18 @@ class DataTransferServiceClient {
5858
* API remote host.
5959
*/
6060
constructor(opts) {
61+
opts = opts || {};
6162
this._descriptors = {};
6263

64+
const servicePath =
65+
opts.servicePath || opts.apiEndpoint || this.constructor.servicePath;
66+
6367
// Ensure that options include the service address and port.
6468
opts = Object.assign(
6569
{
6670
clientConfig: {},
6771
port: this.constructor.port,
68-
servicePath: this.constructor.servicePath,
72+
servicePath,
6973
},
7074
opts
7175
);
@@ -200,6 +204,14 @@ class DataTransferServiceClient {
200204
return 'bigquerydatatransfer.googleapis.com';
201205
}
202206

207+
/**
208+
* The DNS address for this API service - same as servicePath(),
209+
* exists for compatibility reasons.
210+
*/
211+
static get apiEndpoint() {
212+
return 'bigquerydatatransfer.googleapis.com';
213+
}
214+
203215
/**
204216
* The port for this API service.
205217
*/

packages/google-cloud-bigquery-datatransfer/synth.metadata

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"updateTime": "2019-05-21T11:08:45.880007Z",
2+
"updateTime": "2019-06-05T14:13:40.674076Z",
33
"sources": [
44
{
55
"generator": {
66
"name": "artman",
7-
"version": "0.20.0",
8-
"dockerImage": "googleapis/artman@sha256:3246adac900f4bdbd62920e80de2e5877380e44036b3feae13667ec255ebf5ec"
7+
"version": "0.23.1",
8+
"dockerImage": "googleapis/artman@sha256:9d5cae1454da64ac3a87028f8ef486b04889e351c83bb95e83b8fab3959faed0"
99
}
1010
},
1111
{
1212
"git": {
1313
"name": "googleapis",
1414
"remote": "https://github.com/googleapis/googleapis.git",
15-
"sha": "32a10f69e2c9ce15bba13ab1ff928bacebb25160",
16-
"internalRef": "249058354"
15+
"sha": "47c142a7cecc6efc9f6f8af804b8be55392b795b",
16+
"internalRef": "251635729"
1717
}
1818
},
1919
{

packages/google-cloud-bigquery-datatransfer/test/gapic-v1.js

+23
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,29 @@ const error = new Error();
2323
error.code = FAKE_STATUS_CODE;
2424

2525
describe('DataTransferServiceClient', () => {
26+
it('has servicePath', () => {
27+
const servicePath =
28+
bigqueryDataTransferModule.v1.DataTransferServiceClient.servicePath;
29+
assert(servicePath);
30+
});
31+
32+
it('has apiEndpoint', () => {
33+
const apiEndpoint =
34+
bigqueryDataTransferModule.v1.DataTransferServiceClient.apiEndpoint;
35+
assert(apiEndpoint);
36+
});
37+
38+
it('has port', () => {
39+
const port = bigqueryDataTransferModule.v1.DataTransferServiceClient.port;
40+
assert(port);
41+
assert(typeof port === 'number');
42+
});
43+
44+
it('should create a client with no options', () => {
45+
const client = new bigqueryDataTransferModule.v1.DataTransferServiceClient();
46+
assert(client);
47+
});
48+
2649
describe('getDataSource', () => {
2750
it('invokes getDataSource without error', done => {
2851
const client = new bigqueryDataTransferModule.v1.DataTransferServiceClient(

0 commit comments

Comments
 (0)