From 2f3d08f0a48cbfa903a66a7735829b92cfd9348a Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Thu, 23 May 2019 12:06:50 -0700 Subject: [PATCH 1/2] feat: add apiEndpoint property to service config --- src/service.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/service.ts b/src/service.ts index 7e884175..e54299c3 100644 --- a/src/service.ts +++ b/src/service.ts @@ -44,6 +44,12 @@ export interface ServiceConfig { */ baseUrl: string; + /** + * The API Endpoint to use when connecting to the service. + * Example: storage.googleapis.com + */ + apiEndpoint: string; + /** * The scopes required for the request. */ @@ -77,6 +83,7 @@ export class Service { makeAuthenticatedRequest: MakeAuthenticatedRequest; authClient: GoogleAuth; private getCredentials: {}; + readonly apiEndpoint: string; /** * Service is a base class, meant to be inherited from by a "service," like @@ -97,6 +104,7 @@ export class Service { options = options || {}; this.baseUrl = config.baseUrl; + this.apiEndpoint = config.apiEndpoint; this.globalInterceptors = arrify(options.interceptors_!); this.interceptors = []; this.packageJson = config.packageJson; From e3f699fba0a1390a64baced97fb7f9de7370010d Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Thu, 23 May 2019 12:45:00 -0700 Subject: [PATCH 2/2] test --- test/service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/service.ts b/test/service.ts index 4a87aedb..5fa4803e 100644 --- a/test/service.ts +++ b/test/service.ts @@ -16,7 +16,6 @@ import * as assert from 'assert'; import * as extend from 'extend'; -import {GoogleAuth} from 'google-auth-library'; import * as proxyquire from 'proxyquire'; import {Request, RequestResponse} from 'request'; @@ -63,6 +62,7 @@ describe('Service', () => { scopes: [], baseUrl: 'base-url', projectIdRequired: false, + apiEndpoint: 'common.endpoint.local', packageJson: { name: '@google-cloud/service', version: '0.2.0', @@ -139,6 +139,10 @@ describe('Service', () => { assert.strictEqual(service.baseUrl, CONFIG.baseUrl); }); + it('should localize the apiEndpoint', () => { + assert.strictEqual(service.apiEndpoint, CONFIG.apiEndpoint); + }); + it('should localize the getCredentials method', () => { function getCredentials() {}