File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 50
50
"predocs-test" : " npm run docs"
51
51
},
52
52
"dependencies" : {
53
- "@google-cloud/common" : " ^1 .0.0" ,
53
+ "@google-cloud/common" : " ^2 .0.0" ,
54
54
"@google-cloud/paginator" : " ^1.0.0" ,
55
55
"@google-cloud/promisify" : " ^1.0.0" ,
56
- "@types/protobufjs" : " ^6.0.0" ,
57
56
"arrify" : " ^2.0.0" ,
58
57
"compressible" : " ^2.0.12" ,
59
58
"concat-stream" : " ^2.0.0" ,
Original file line number Diff line number Diff line change @@ -50,6 +50,11 @@ export interface StorageOptions extends GoogleAuthOptions {
50
50
autoRetry ?: boolean ;
51
51
maxRetries ?: number ;
52
52
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 ;
53
58
}
54
59
55
60
export interface BucketOptions {
@@ -285,8 +290,10 @@ export class Storage extends Service {
285
290
* @param {StorageOptions } [options] Configuration options.
286
291
*/
287
292
constructor ( options : StorageOptions = { } ) {
293
+ options . apiEndpoint = options . apiEndpoint || 'www.googleapis.com' ;
288
294
const config = {
289
- baseUrl : 'https://www.googleapis.com/storage/v1' ,
295
+ apiEndpoint : options . apiEndpoint ,
296
+ baseUrl : `https://${ options . apiEndpoint } /storage/v1` ,
290
297
projectIdRequired : false ,
291
298
scopes : [
292
299
'https://www.googleapis.com/auth/iam' ,
Original file line number Diff line number Diff line change @@ -134,6 +134,20 @@ describe('Storage', () => {
134
134
require ( '../../package.json' )
135
135
) ;
136
136
} ) ;
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
+ } ) ;
137
151
} ) ;
138
152
139
153
describe ( 'bucket' , ( ) => {
You can’t perform that action at this time.
0 commit comments