File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5050 "predocs-test" : " npm run docs"
5151 },
5252 "dependencies" : {
53- "@google-cloud/common" : " ^1 .0.0" ,
53+ "@google-cloud/common" : " ^2 .0.0" ,
5454 "@google-cloud/paginator" : " ^1.0.0" ,
5555 "@google-cloud/promisify" : " ^1.0.0" ,
56- "@types/protobufjs" : " ^6.0.0" ,
5756 "arrify" : " ^2.0.0" ,
5857 "compressible" : " ^2.0.12" ,
5958 "concat-stream" : " ^2.0.0" ,
Original file line number Diff line number Diff line change @@ -50,6 +50,11 @@ export interface StorageOptions extends GoogleAuthOptions {
5050 autoRetry ?: boolean ;
5151 maxRetries ?: number ;
5252 promise ?: typeof Promise ;
53+ /**
54+ * The API endpoint of the service used to make requests.
55+ * Defaults to `www.googleapis.com`.
56+ */
57+ apiEndpoint ?: string ;
5358}
5459
5560export interface BucketOptions {
@@ -285,8 +290,10 @@ export class Storage extends Service {
285290 * @param {StorageOptions } [options] Configuration options.
286291 */
287292 constructor ( options : StorageOptions = { } ) {
293+ options . apiEndpoint = options . apiEndpoint || 'www.googleapis.com' ;
288294 const config = {
289- baseUrl : 'https://www.googleapis.com/storage/v1' ,
295+ apiEndpoint : options . apiEndpoint ,
296+ baseUrl : `https://${ options . apiEndpoint } /storage/v1` ,
290297 projectIdRequired : false ,
291298 scopes : [
292299 'https://www.googleapis.com/auth/iam' ,
Original file line number Diff line number Diff line change @@ -134,6 +134,20 @@ describe('Storage', () => {
134134 require ( '../../package.json' )
135135 ) ;
136136 } ) ;
137+
138+ it ( 'should propagate the apiEndpoint option' , ( ) => {
139+ const apiEndpoint = 'some.fake.endpoint' ;
140+ storage = new Storage ( {
141+ projectId : PROJECT_ID ,
142+ apiEndpoint,
143+ } ) ;
144+ const calledWith = storage . calledWith_ [ 0 ] ;
145+ assert . strictEqual (
146+ calledWith . baseUrl ,
147+ `https://${ apiEndpoint } /storage/v1`
148+ ) ;
149+ assert . strictEqual ( calledWith . apiEndpoint , apiEndpoint ) ;
150+ } ) ;
137151 } ) ;
138152
139153 describe ( 'bucket' , ( ) => {
You can’t perform that action at this time.
0 commit comments