Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: add apiEndpoint property to service config #427

Merged
merged 2 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion test/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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() {}

Expand Down