From 0da529ed3cf05edeaf12b194e935be39899028fe Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 5 Jun 2019 10:01:30 -0700 Subject: [PATCH] feat: support apiEndpoint override in client constructor (#157) --- src/v1/asset_service_client.js | 14 +++++++++++++- src/v1beta1/asset_service_client.js | 14 +++++++++++++- synth.metadata | 10 +++++----- test/gapic-v1.js | 21 +++++++++++++++++++++ test/gapic-v1beta1.js | 21 +++++++++++++++++++++ 5 files changed, 73 insertions(+), 7 deletions(-) diff --git a/src/v1/asset_service_client.js b/src/v1/asset_service_client.js index 52226896..a2beffdc 100644 --- a/src/v1/asset_service_client.js +++ b/src/v1/asset_service_client.js @@ -56,14 +56,18 @@ class AssetServiceClient { * 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 ); @@ -183,6 +187,14 @@ class AssetServiceClient { return 'cloudasset.googleapis.com'; } + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'cloudasset.googleapis.com'; + } + /** * The port for this API service. */ diff --git a/src/v1beta1/asset_service_client.js b/src/v1beta1/asset_service_client.js index 3a6efbb7..e849eee7 100644 --- a/src/v1beta1/asset_service_client.js +++ b/src/v1beta1/asset_service_client.js @@ -56,14 +56,18 @@ class AssetServiceClient { * 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 ); @@ -183,6 +187,14 @@ class AssetServiceClient { return 'cloudasset.googleapis.com'; } + /** + * The DNS address for this API service - same as servicePath(), + * exists for compatibility reasons. + */ + static get apiEndpoint() { + return 'cloudasset.googleapis.com'; + } + /** * The port for this API service. */ diff --git a/synth.metadata b/synth.metadata index f0fbec7d..9acb54cf 100644 --- a/synth.metadata +++ b/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2019-05-21T11:07:32.789700Z", + "updateTime": "2019-06-05T14:12:31.290419Z", "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": "32a10f69e2c9ce15bba13ab1ff928bacebb25160", - "internalRef": "249058354" + "sha": "47c142a7cecc6efc9f6f8af804b8be55392b795b", + "internalRef": "251635729" } }, { diff --git a/test/gapic-v1.js b/test/gapic-v1.js index 3645085a..1fe67016 100644 --- a/test/gapic-v1.js +++ b/test/gapic-v1.js @@ -23,6 +23,27 @@ const error = new Error(); error.code = FAKE_STATUS_CODE; describe('AssetServiceClient', () => { + it('has servicePath', () => { + const servicePath = assetModule.v1.AssetServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = assetModule.v1.AssetServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = assetModule.v1.AssetServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no options', () => { + const client = new assetModule.v1.AssetServiceClient(); + assert(client); + }); + describe('exportAssets', function() { it('invokes exportAssets without error', done => { const client = new assetModule.v1.AssetServiceClient({ diff --git a/test/gapic-v1beta1.js b/test/gapic-v1beta1.js index 6e3d7f94..c3a67c17 100644 --- a/test/gapic-v1beta1.js +++ b/test/gapic-v1beta1.js @@ -23,6 +23,27 @@ const error = new Error(); error.code = FAKE_STATUS_CODE; describe('AssetServiceClient', () => { + it('has servicePath', () => { + const servicePath = assetModule.v1beta1.AssetServiceClient.servicePath; + assert(servicePath); + }); + + it('has apiEndpoint', () => { + const apiEndpoint = assetModule.v1beta1.AssetServiceClient.apiEndpoint; + assert(apiEndpoint); + }); + + it('has port', () => { + const port = assetModule.v1beta1.AssetServiceClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no options', () => { + const client = new assetModule.v1beta1.AssetServiceClient(); + assert(client); + }); + describe('exportAssets', function() { it('invokes exportAssets without error', done => { const client = new assetModule.v1beta1.AssetServiceClient({