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; 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() {}