Skip to content

Commit

Permalink
feat: support apiEndpoint override in client constructor (#224)
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 bca24ea commit f1843b6
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ class ClusterControllerClient {
* 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 @@ -229,6 +233,14 @@ class ClusterControllerClient {
return 'dataproc.googleapis.com';
}

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

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

/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
*/
static get apiEndpoint() {
return 'dataproc.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 WorkflowTemplateServiceClient {
* 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 @@ -228,6 +232,14 @@ class WorkflowTemplateServiceClient {
return 'dataproc.googleapis.com';
}

/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
*/
static get apiEndpoint() {
return 'dataproc.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 AutoscalingPolicyServiceClient {
* 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 @@ -171,6 +175,14 @@ class AutoscalingPolicyServiceClient {
return 'dataproc.googleapis.com';
}

/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
*/
static get apiEndpoint() {
return 'dataproc.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 ClusterControllerClient {
* 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 @@ -229,6 +233,14 @@ class ClusterControllerClient {
return 'dataproc.googleapis.com';
}

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

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

/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
*/
static get apiEndpoint() {
return 'dataproc.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 WorkflowTemplateServiceClient {
* 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 @@ -228,6 +232,14 @@ class WorkflowTemplateServiceClient {
return 'dataproc.googleapis.com';
}

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

/**
* The port for this API service.
*/
Expand Down
10 changes: 5 additions & 5 deletions packages/google-cloud-dataproc/synth.metadata
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"updateTime": "2019-05-31T15:24:37.161587Z",
"updateTime": "2019-06-05T14:15:26.230261Z",
"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": "152dabdfea620675c2db2f2a74878572324e8fd2",
"internalRef": "250713292"
"sha": "47c142a7cecc6efc9f6f8af804b8be55392b795b",
"internalRef": "251635729"
}
},
{
Expand Down
65 changes: 65 additions & 0 deletions packages/google-cloud-dataproc/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('ClusterControllerClient', () => {
it('has servicePath', () => {
const servicePath = dataprocModule.v1.ClusterControllerClient.servicePath;
assert(servicePath);
});

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

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

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

describe('createCluster', function() {
it('invokes createCluster without error', done => {
const client = new dataprocModule.v1.ClusterControllerClient({
Expand Down Expand Up @@ -573,6 +594,27 @@ describe('ClusterControllerClient', () => {
});
});
describe('JobControllerClient', () => {
it('has servicePath', () => {
const servicePath = dataprocModule.v1.JobControllerClient.servicePath;
assert(servicePath);
});

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

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

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

describe('submitJob', () => {
it('invokes submitJob without error', done => {
const client = new dataprocModule.v1.JobControllerClient({
Expand Down Expand Up @@ -990,6 +1032,29 @@ describe('JobControllerClient', () => {
});
});
describe('WorkflowTemplateServiceClient', () => {
it('has servicePath', () => {
const servicePath =
dataprocModule.v1.WorkflowTemplateServiceClient.servicePath;
assert(servicePath);
});

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

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

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

describe('createWorkflowTemplate', () => {
it('invokes createWorkflowTemplate without error', done => {
const client = new dataprocModule.v1.WorkflowTemplateServiceClient({
Expand Down
Loading

0 comments on commit f1843b6

Please sign in to comment.