From 67ff0dca1e14e8fc1a604d6c6bd4fabb335163fc Mon Sep 17 00:00:00 2001
From: Yoshi Automation Bot <yoshi-automation@google.com>
Date: Wed, 5 Jun 2019 08:47:26 -0700
Subject: [PATCH] feat: support apiEndpoint override in client constructor
 (#173)

---
 .../src/v1/key_management_service_client.js   | 14 ++++++++++++-
 packages/google-cloud-kms/synth.metadata      | 10 ++++-----
 packages/google-cloud-kms/test/gapic-v1.js    | 21 +++++++++++++++++++
 3 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/packages/google-cloud-kms/src/v1/key_management_service_client.js b/packages/google-cloud-kms/src/v1/key_management_service_client.js
index 76c964d2eee..47db8e565f9 100644
--- a/packages/google-cloud-kms/src/v1/key_management_service_client.js
+++ b/packages/google-cloud-kms/src/v1/key_management_service_client.js
@@ -65,14 +65,18 @@ class KeyManagementServiceClient {
    *     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
     );
@@ -245,6 +249,14 @@ class KeyManagementServiceClient {
     return 'cloudkms.googleapis.com';
   }
 
+  /**
+   * The DNS address for this API service - same as servicePath(),
+   * exists for compatibility reasons.
+   */
+  static get apiEndpoint() {
+    return 'cloudkms.googleapis.com';
+  }
+
   /**
    * The port for this API service.
    */
diff --git a/packages/google-cloud-kms/synth.metadata b/packages/google-cloud-kms/synth.metadata
index e58031f2fb3..cba41d1a46f 100644
--- a/packages/google-cloud-kms/synth.metadata
+++ b/packages/google-cloud-kms/synth.metadata
@@ -1,19 +1,19 @@
 {
-  "updateTime": "2019-05-21T11:17:12.709646Z",
+  "updateTime": "2019-06-05T14:19:24.011735Z",
   "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/packages/google-cloud-kms/test/gapic-v1.js b/packages/google-cloud-kms/test/gapic-v1.js
index ac571ddfba1..0b56c49ea7c 100644
--- a/packages/google-cloud-kms/test/gapic-v1.js
+++ b/packages/google-cloud-kms/test/gapic-v1.js
@@ -23,6 +23,27 @@ const error = new Error();
 error.code = FAKE_STATUS_CODE;
 
 describe('KeyManagementServiceClient', () => {
+  it('has servicePath', () => {
+    const servicePath = kmsModule.v1.KeyManagementServiceClient.servicePath;
+    assert(servicePath);
+  });
+
+  it('has apiEndpoint', () => {
+    const apiEndpoint = kmsModule.v1.KeyManagementServiceClient.apiEndpoint;
+    assert(apiEndpoint);
+  });
+
+  it('has port', () => {
+    const port = kmsModule.v1.KeyManagementServiceClient.port;
+    assert(port);
+    assert(typeof port === 'number');
+  });
+
+  it('should create a client with no options', () => {
+    const client = new kmsModule.v1.KeyManagementServiceClient();
+    assert(client);
+  });
+
   describe('listKeyRings', () => {
     it('invokes listKeyRings without error', done => {
       const client = new kmsModule.v1.KeyManagementServiceClient({