@@ -184,11 +184,18 @@ Storage.prototype.bucket = function(name) {
184
184
* Create a bucket.
185
185
*
186
186
* @resource [Buckets: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/insert}
187
+ * @resource [Durable Reduced Availability]{@link https://cloud.google.com/storage/docs/durable-reduced-availability}
188
+ * @resource [Nearline]{@link https://cloud.google.com/storage/docs/nearline}
189
+ * @resource [Storage Classes]{@link https://cloud.google.com/storage/docs/storage-classes}
187
190
*
188
191
* @throws {Error } If a name is not provided.
189
192
*
190
193
* @param {string } name - Name of the bucket to create.
191
194
* @param {object= } metadata - Metadata to set for the bucket.
195
+ * @param {boolean= } metadata.dra - Specify the storage class as
196
+ * [Durable Reduced Availability](https://goo.gl/26lthK).
197
+ * @param {boolean= } metadata.nearline - Specify the storage class as
198
+ * [Nearline](https://goo.gl/sN5wNh).
192
199
* @param {function } callback - The callback function.
193
200
* @param {?error } callback.err - An error returned while making this request
194
201
* @param {module:storage/bucket } callback.bucket - The newly created Bucket.
@@ -209,7 +216,7 @@ Storage.prototype.bucket = function(name) {
209
216
* //-
210
217
* var metadata = {
211
218
* location: 'US-CENTRAL1',
212
- * storageClass: 'DURABLE_REDUCED_AVAILABILITY'
219
+ * dra: true
213
220
* };
214
221
*
215
222
* gcs.createBucket('new-bucket', metadata, callback);
@@ -240,6 +247,17 @@ Storage.prototype.createBucket = function(name, metadata, callback) {
240
247
var body = extend ( metadata , {
241
248
name : name
242
249
} ) ;
250
+ var storageClasses = {
251
+ dra : 'DURABLE_REDUCED_AVAILABILITY' ,
252
+ nearline : 'NEARLINE'
253
+ } ;
254
+
255
+ Object . keys ( storageClasses ) . forEach ( function ( storageClass ) {
256
+ if ( body [ storageClass ] ) {
257
+ body . storageClass = storageClasses [ storageClass ] ;
258
+ delete body [ storageClass ] ;
259
+ }
260
+ } ) ;
243
261
244
262
this . makeReq_ ( 'POST' , '' , query , body , function ( err , resp ) {
245
263
if ( err ) {
0 commit comments