Files
threshold-ui/addons/api/addon/serializers/scope.js
T
2024-01-12 11:29:19 -08:00

36 lines
848 B
JavaScript

/**
* 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,
};
}
}