Skip to content

Commit

Permalink
feat: add support for rpo (turbo replication) metadata field when cre… (
Browse files Browse the repository at this point in the history
#1648)

* feat: add support for rpo (turbo replication) metadata field when creating a bucket

* alphabetize
  • Loading branch information
ddelgrosso1 committed Jan 10, 2022
1 parent 437d400 commit 291e6ef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/storage.ts
Expand Up @@ -118,15 +118,16 @@ export interface CreateBucketRequest {
coldline?: boolean;
cors?: Cors[];
dra?: boolean;
location?: string;
multiRegional?: boolean;
nearline?: boolean;
regional?: boolean;
requesterPays?: boolean;
retentionPolicy?: object;
rpo?: string;
standard?: boolean;
storageClass?: string;
userProject?: string;
location?: string;
versioning?: Versioning;
}

Expand Down Expand Up @@ -739,13 +740,16 @@ export class Storage extends Service {
* @property {Cors[]} [cors=[]] Specify the CORS configuration to use.
* @property {boolean} [dra=false] Specify the storage class as Durable Reduced
* Availability.
* @property {string} [location] Specify the location / region in which to create the bucket.
* @property {boolean} [multiRegional=false] Specify the storage class as
* Multi-Regional.
* @property {boolean} [nearline=false] Specify the storage class as Nearline.
* @property {boolean} [regional=false] Specify the storage class as Regional.
* @property {boolean} [requesterPays=false] **Early Access Testers Only**
* Force the use of the User Project metadata field to assign operational
* costs when an operation is made on a Bucket and its objects.
* @property {string} [rpo] For dual region buckets, controls whether turbo
* replication is enabled (`ASYNC_TURBO`) or disabled (`DEFAULT`).
* @property {boolean} [standard=true] Specify the storage class as Standard.
* @property {string} [storageClass] The new storage class. (`standard`,
* `nearline`, `coldline`, or `archive`).
Expand Down
14 changes: 14 additions & 0 deletions test/index.ts
Expand Up @@ -871,6 +871,20 @@ describe('Storage', () => {
});
});

it('should allow setting rpo', done => {
const location = 'NAM4';
const rpo = 'ASYNC_TURBO';
storage.request = (
reqOpts: DecorateRequestOptions,
callback: Function
) => {
assert.strictEqual(reqOpts.json.location, location);
assert.strictEqual(reqOpts.json.rpo, rpo);
callback();
};
storage.createBucket(BUCKET_NAME, {location, rpo}, done);
});

it('should throw when `storageClass` is set to different value than provided storageClass name', () => {
assert.throws(() => {
storage.createBucket(
Expand Down

0 comments on commit 291e6ef

Please sign in to comment.