feat: 🎸 scope policy association api changes (#2086)
scope policy association API changes
This commit is contained in:
1 parent
1cb3b708a2
commit
eefb9eba4f
7 files changed
+164
-6
No files matched your search
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
import ApplicationSerializer from './application';
|
||||
|
||||
export default class ScopeSerializer extends ApplicationSerializer {
|
||||
// =methods
|
||||
|
||||
serialize(snapshot) {
|
||||
let serialized = super.serialize(...arguments);
|
||||
const policyId = snapshot?.adapterOptions?.policyId;
|
||||
|
||||
if (policyId) {
|
||||
serialized = this.serializeWithStoragePolicy(snapshot, policyId);
|
||||
}
|
||||
|
||||
return serialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a payload containing only version and storage policy id,
|
||||
* rather than existing instances on the model.
|
||||
* @param {Snapshot} snapshot
|
||||
* @param {[string]} hostSetIDs
|
||||
* @return {object}
|
||||
*/
|
||||
serializeWithStoragePolicy(snapshot, policyId) {
|
||||
return {
|
||||
version: snapshot.attr('version'),
|
||||
storage_policy_id: policyId,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user