Compare commits
1 Commits
developmen
...
improvemen
Author | SHA1 | Date |
---|---|---|
KillianG | 2a88781134 |
|
@ -130,3 +130,15 @@ this._uid = uid || uuid();
|
|||
### Usage
|
||||
|
||||
Used to set a unique identifier on a bucket
|
||||
|
||||
## Model version 11
|
||||
|
||||
### Properties Added
|
||||
|
||||
```javascript
|
||||
this._tags = tags || null;
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
Used to store bucket tagging
|
||||
|
|
|
@ -60,6 +60,7 @@ class BucketInfo {
|
|||
* @param {boolean} [objectLockEnabled] - true when object lock enabled
|
||||
* @param {object} [objectLockConfiguration] - object lock configuration
|
||||
* @param {object} [notificationConfiguration] - bucket notification configuration
|
||||
* @param {object[]} [tags] - bucket tags
|
||||
*/
|
||||
constructor(name, owner, ownerDisplayName, creationDate,
|
||||
mdBucketModelVersion, acl, transient, deleted,
|
||||
|
@ -67,7 +68,7 @@ class BucketInfo {
|
|||
locationConstraint, websiteConfiguration, cors,
|
||||
replicationConfiguration, lifecycleConfiguration,
|
||||
bucketPolicy, uid, objectLockEnabled, objectLockConfiguration,
|
||||
notificationConfiguration) {
|
||||
notificationConfiguration, tags) {
|
||||
assert.strictEqual(typeof name, 'string');
|
||||
assert.strictEqual(typeof owner, 'string');
|
||||
assert.strictEqual(typeof ownerDisplayName, 'string');
|
||||
|
@ -151,6 +152,9 @@ class BucketInfo {
|
|||
READ: [],
|
||||
READ_ACP: [],
|
||||
};
|
||||
if (tags) {
|
||||
assert(Array.isArray(tags));
|
||||
}
|
||||
|
||||
// IF UPDATING PROPERTIES, INCREMENT MODELVERSION NUMBER ABOVE
|
||||
this._acl = aclInstance;
|
||||
|
@ -173,6 +177,7 @@ class BucketInfo {
|
|||
this._objectLockEnabled = objectLockEnabled || false;
|
||||
this._objectLockConfiguration = objectLockConfiguration || null;
|
||||
this._notificationConfiguration = notificationConfiguration || null;
|
||||
this._tags = tags || null;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
|
@ -201,6 +206,7 @@ class BucketInfo {
|
|||
objectLockEnabled: this._objectLockEnabled,
|
||||
objectLockConfiguration: this._objectLockConfiguration,
|
||||
notificationConfiguration: this._notificationConfiguration,
|
||||
tags: this._tags,
|
||||
};
|
||||
if (this._websiteConfiguration) {
|
||||
bucketInfos.websiteConfiguration =
|
||||
|
@ -223,7 +229,7 @@ class BucketInfo {
|
|||
obj.versioningConfiguration, obj.locationConstraint, websiteConfig,
|
||||
obj.cors, obj.replicationConfiguration, obj.lifecycleConfiguration,
|
||||
obj.bucketPolicy, obj.uid, obj.objectLockEnabled,
|
||||
obj.objectLockConfiguration, obj.notificationConfiguration);
|
||||
obj.objectLockConfiguration, obj.notificationConfiguration, obj.tags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,7 +254,7 @@ class BucketInfo {
|
|||
data._websiteConfiguration, data._cors,
|
||||
data._replicationConfiguration, data._lifecycleConfiguration,
|
||||
data._bucketPolicy, data._uid, data._objectLockEnabled,
|
||||
data._objectLockConfiguration, data._notificationConfiguration);
|
||||
data._objectLockConfiguration, data._notificationConfiguration, data._tags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -649,6 +655,26 @@ class BucketInfo {
|
|||
this._objectLockEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of bucket tags
|
||||
* @return {object[]} - Array of bucket tags as {"key" : "key", "value": "value"}
|
||||
*/
|
||||
getTags() {
|
||||
return this._tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bucket tags
|
||||
* @param {object[]} tags - collection of tags
|
||||
* @param {string[]} tags[].key - key of the tag
|
||||
* @param {string[]} tags[].value - value of the tag
|
||||
* @return {BucketInfo} - bucket info instance
|
||||
*/
|
||||
setTags(tags) {
|
||||
this._tags = tags;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BucketInfo;
|
||||
|
|
|
@ -164,6 +164,21 @@ const testNotificationConfiguration = {
|
|||
],
|
||||
};
|
||||
|
||||
const testBucketTagging = [
|
||||
{
|
||||
key: 'testKey1',
|
||||
value: 'testValue1',
|
||||
},
|
||||
{
|
||||
key: 'testKey2',
|
||||
value: 'testValue2',
|
||||
},
|
||||
{
|
||||
key: 'testKey3',
|
||||
value: 'testValue3',
|
||||
},
|
||||
];
|
||||
|
||||
// create a dummy bucket to test getters and setters
|
||||
Object.keys(acl).forEach(
|
||||
aclObj => describe(`different acl configurations : ${aclObj}`, () => {
|
||||
|
@ -185,7 +200,8 @@ Object.keys(acl).forEach(
|
|||
testUid,
|
||||
testobjectLockEnabled,
|
||||
testObjectLockConfiguration,
|
||||
testNotificationConfiguration);
|
||||
testNotificationConfiguration,
|
||||
testBucketTagging);
|
||||
|
||||
describe('serialize/deSerialize on BucketInfo class', () => {
|
||||
const serialized = dummyBucket.serialize();
|
||||
|
@ -217,6 +233,7 @@ Object.keys(acl).forEach(
|
|||
objectLockConfiguration:
|
||||
dummyBucket._objectLockConfiguration,
|
||||
notificationConfiguration: dummyBucket._notificationConfiguration,
|
||||
tags: dummyBucket._tags,
|
||||
};
|
||||
assert.strictEqual(serialized, JSON.stringify(bucketInfos));
|
||||
done();
|
||||
|
|
Loading…
Reference in New Issue