feat: 🎸 scope policy association api changes (#2086)

scope policy association API changes
This commit is contained in:
Dharini Jeeva authored and GitHub committed 2024-01-12 11:29:19 -08:00
1 parent 1cb3b708a2
commit eefb9eba4f
7 files changed
+164 -6

No files matched your search

+44
View File
@@ -46,4 +46,48 @@ export default class ScopeModel extends GeneratedScopeModel {
set isProject(value) {
if (value) this.type = scopeTypes.project;
}
/**
* Attach policy via the `attach-staorage-policy` method.
* @param {[string]} policyId
* @param {object} options
* @param {object} options.adapterOptions
* @return {Promise}
*/
attachStoragePolicy(policyId, options = { adapterOptions: {} }) {
const defaultAdapterOptions = {
method: 'attach-storage-policy',
policyId,
};
// There is no "deep merge" in ES.
return this.save({
...options,
adapterOptions: {
...defaultAdapterOptions,
...options.adapterOptions,
},
});
}
/**
* Detaches policy via the `detach-storage-policy` method.
* @param {[string]} policyId
* @param {object} options
* @param {object} options.adapterOptions
* @return {Promise}
*/
detachStoragePolicy(policyId, options = { adapterOptions: {} }) {
const defaultAdapterOptions = {
method: 'detach-storage-policy',
policyId,
};
// There is no "deep merge" in ES.
return this.save({
...options,
adapterOptions: {
...defaultAdapterOptions,
...options.adapterOptions,
},
});
}
}