Compare commits

...

2 Commits

Author SHA1 Message Date
williamlardier b759691160
ARSN-316: support delete capability 2023-03-15 11:21:48 +01:00
williamlardier 31b88cc9e6
ARSN-316: individually update bucket capabilities 2023-03-15 10:19:46 +01:00
2 changed files with 92 additions and 0 deletions

View File

@ -147,6 +147,40 @@ class MetadataWrapper {
}); });
} }
updateBucketCapabilities(bucketName, capabilityName, capability, log, cb) {
log.debug('updating bucket capabilities in metadata');
if (!this.client.putBucketAttributesCapabilities) {
return cb(errors.NotImplemented);
}
return this.client.putBucketAttributesCapabilities(bucketName, capabilityName, capability,
log, err => {
if (err) {
log.debug('error from metadata', { implName: this.implName,
error: err });
return cb(err);
}
log.trace('bucket capabilities updated in metadata');
return cb(err);
});
}
deleteBucketCapabilities(bucketName, capabilityName, log, cb) {
log.debug('deleting bucket capabilities in metadata');
if (!this.client.deleteBucketAttributesCapability) {
return cb(errors.NotImplemented);
}
return this.client.deleteBucketAttributesCapability(bucketName, capabilityName,
log, err => {
if (err) {
log.debug('error from metadata', { implName: this.implName,
error: err });
return cb(err);
}
log.trace('bucket capabilities deleted in metadata');
return cb(err);
});
}
getBucket(bucketName, log, cb) { getBucket(bucketName, log, cb) {
log.debug('getting bucket from metadata'); log.debug('getting bucket from metadata');
this.client.getBucketAttributes(bucketName, log, (err, data) => { this.client.getBucketAttributes(bucketName, log, (err, data) => {

View File

@ -412,6 +412,64 @@ class MongoClientInterface {
}); });
} }
/**
*
* @param {String} bucketName - name of bucket
* @param {String} capabilityName - name of capability
* @param {Object} capability - capability object
* @param {Sbject} log - logger
* @param {Function} cb - callback
* @return {undefined}
*/
putBucketAttributesCapabilities(bucketName, capabilityName, capability, log, cb) {
const m = this.getCollection(METASTORE);
m.update({
_id: bucketName,
}, {
$set: {
_id: bucketName,
[`value.capabilities.${capabilityName}`]: capability,
},
}, {
upsert: true,
}, err => {
if (err) {
log.error(
'putBucketAttributesCapabilities: error putting bucket attributes',
{ error: err.message });
return cb(errors.InternalError);
}
return cb();
});
}
/**
* Delete bucket attributes capability
* @param {String} bucketName - name of bucket
* @param {String} capabilityName - name of capability
* @param {Object} log - logger
* @param {Function} cb - callback
* @return {undefined}
**/
deleteBucketAttributesCapability(bucketName, capabilityName, log, cb) {
const m = this.getCollection(METASTORE);
m.update({
_id: bucketName,
}, {
$unset: {
[`value.capabilities.${capabilityName}`]: '',
},
}, err => {
if (err) {
log.error(
'deleteBucketAttributesCapability: error deleting bucket attributes',
{ error: err.message });
return cb(errors.InternalError);
}
return cb();
});
}
/* /*
* Delete bucket from metastore * Delete bucket from metastore
*/ */