From f1843b6be238e808b36fc9ebb548251e76705b85 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 5 Jun 2019 09:59:25 -0700 Subject: [PATCH] feat: support apiEndpoint override in client constructor (#224) --- .../src/v1/cluster_controller_client.js | 14 ++- .../src/v1/job_controller_client.js | 14 ++- .../v1/workflow_template_service_client.js | 14 ++- .../autoscaling_policy_service_client.js | 14 ++- .../src/v1beta2/cluster_controller_client.js | 14 ++- .../src/v1beta2/job_controller_client.js | 14 ++- .../workflow_template_service_client.js | 14 ++- packages/google-cloud-dataproc/synth.metadata | 10 +-- .../google-cloud-dataproc/test/gapic-v1.js | 65 ++++++++++++++ .../test/gapic-v1beta2.js | 90 +++++++++++++++++++ 10 files changed, 251 insertions(+), 12 deletions(-) diff --git a/packages/google-cloud-dataproc/src/v1/cluster_controller_client.js b/packages/google-cloud-dataproc/src/v1/cluster_controller_client.js index fc47f5c3b39..1b1117bc384 100644 --- a/packages/google-cloud-dataproc/src/v1/cluster_controller_client.js +++ b/packages/google-cloud-dataproc/src/v1/cluster_controller_client.js @@ -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 ); @@ -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. */ diff --git a/packages/google-cloud-dataproc/src/v1/job_controller_client.js b/packages/google-cloud-dataproc/src/v1/job_controller_client.js index b113981525f..7fbe199b5e8 100644 --- a/packages/google-cloud-dataproc/src/v1/job_controller_client.js +++ b/packages/google-cloud-dataproc/src/v1/job_controller_client.js @@ -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 ); @@ -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. */ diff --git a/packages/google-cloud-dataproc/src/v1/workflow_template_service_client.js b/packages/google-cloud-dataproc/src/v1/workflow_template_service_client.js index bce07c315fe..9564f865383 100644 --- a/packages/google-cloud-dataproc/src/v1/workflow_template_service_client.js +++ b/packages/google-cloud-dataproc/src/v1/workflow_template_service_client.js @@ -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 ); @@ -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. */ diff --git a/packages/google-cloud-dataproc/src/v1beta2/autoscaling_policy_service_client.js b/packages/google-cloud-dataproc/src/v1beta2/autoscaling_policy_service_client.js index 7e290808919..150f8385fee 100644 --- a/packages/google-cloud-dataproc/src/v1beta2/autoscaling_policy_service_client.js +++ b/packages/google-cloud-dataproc/src/v1beta2/autoscaling_policy_service_client.js @@ -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 ); @@ -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. */ diff --git a/packages/google-cloud-dataproc/src/v1beta2/cluster_controller_client.js b/packages/google-cloud-dataproc/src/v1beta2/cluster_controller_client.js index 1f0df316671..9764127c52e 100644 --- a/packages/google-cloud-dataproc/src/v1beta2/cluster_controller_client.js +++ b/packages/google-cloud-dataproc/src/v1beta2/cluster_controller_client.js @@ -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 ); @@ -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. */ diff --git a/packages/google-cloud-dataproc/src/v1beta2/job_controller_client.js b/packages/google-cloud-dataproc/src/v1beta2/job_controller_client.js index ad30df33b7d..62f13a853e9 100644 --- a/packages/google-cloud-dataproc/src/v1beta2/job_controller_client.js +++ b/packages/google-cloud-dataproc/src/v1beta2/job_controller_client.js @@ -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 ); @@ -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. */ diff --git a/packages/google-cloud-dataproc/src/v1beta2/workflow_template_service_client.js b/packages/google-cloud-dataproc/src/v1beta2/workflow_template_service_client.js index 6b3a7e3454d..20dd9d550b2 100644 --- a/packages/google-cloud-dataproc/src/v1beta2/workflow_template_service_client.js +++ b/packages/google-cloud-dataproc/src/v1beta2/workflow_template_service_client.js @@ -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 ); @@ -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. */ diff --git a/packages/google-cloud-dataproc/synth.metadata b/packages/google-cloud-dataproc/synth.metadata index 1565b657b08..7f14f71d761 100644 --- a/packages/google-cloud-dataproc/synth.metadata +++ b/packages/google-cloud-dataproc/synth.metadata @@ -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" } }, { diff --git a/packages/google-cloud-dataproc/test/gapic-v1.js b/packages/google-cloud-dataproc/test/gapic-v1.js index dc7d534c955..9faf3367dbf 100644 --- a/packages/google-cloud-dataproc/test/gapic-v1.js +++ b/packages/google-cloud-dataproc/test/gapic-v1.js @@ -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({ @@ -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({ @@ -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({ diff --git a/packages/google-cloud-dataproc/test/gapic-v1beta2.js b/packages/google-cloud-dataproc/test/gapic-v1beta2.js index 4c3f5047158..148bad66d4d 100644 --- a/packages/google-cloud-dataproc/test/gapic-v1beta2.js +++ b/packages/google-cloud-dataproc/test/gapic-v1beta2.js @@ -23,6 +23,29 @@ const error = new Error(); error.code = FAKE_STATUS_CODE; describe('AutoscalingPolicyServiceClient', () => { + it('has servicePath', () => { + const servicePath = + dataprocModule.v1beta2.AutoscalingPolicyServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + dataprocModule.v1beta2.AutoscalingPolicyServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = dataprocModule.v1beta2.AutoscalingPolicyServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no options', () => { + const client = new dataprocModule.v1beta2.AutoscalingPolicyServiceClient(); + assert(client); + }); + describe('createAutoscalingPolicy', () => { it('invokes createAutoscalingPolicy without error', done => { const client = new dataprocModule.v1beta2.AutoscalingPolicyServiceClient({ @@ -348,6 +371,29 @@ describe('AutoscalingPolicyServiceClient', () => { }); }); describe('ClusterControllerClient', () => { + it('has servicePath', () => { + const servicePath = + dataprocModule.v1beta2.ClusterControllerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + dataprocModule.v1beta2.ClusterControllerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = dataprocModule.v1beta2.ClusterControllerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no options', () => { + const client = new dataprocModule.v1beta2.ClusterControllerClient(); + assert(client); + }); + describe('createCluster', function() { it('invokes createCluster without error', done => { const client = new dataprocModule.v1beta2.ClusterControllerClient({ @@ -898,6 +944,27 @@ describe('ClusterControllerClient', () => { }); }); describe('JobControllerClient', () => { + it('has servicePath', () => { + const servicePath = dataprocModule.v1beta2.JobControllerClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = dataprocModule.v1beta2.JobControllerClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = dataprocModule.v1beta2.JobControllerClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no options', () => { + const client = new dataprocModule.v1beta2.JobControllerClient(); + assert(client); + }); + describe('submitJob', () => { it('invokes submitJob without error', done => { const client = new dataprocModule.v1beta2.JobControllerClient({ @@ -1323,6 +1390,29 @@ describe('JobControllerClient', () => { }); }); describe('WorkflowTemplateServiceClient', () => { + it('has servicePath', () => { + const servicePath = + dataprocModule.v1beta2.WorkflowTemplateServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = + dataprocModule.v1beta2.WorkflowTemplateServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = dataprocModule.v1beta2.WorkflowTemplateServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no options', () => { + const client = new dataprocModule.v1beta2.WorkflowTemplateServiceClient(); + assert(client); + }); + describe('createWorkflowTemplate', () => { it('invokes createWorkflowTemplate without error', done => { const client = new dataprocModule.v1beta2.WorkflowTemplateServiceClient({