2023-03-15 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2018-04-03 14:16:57 +00:00
|
|
|
import ApplicationSerializer from './application';
|
|
|
|
|
|
|
|
export default ApplicationSerializer.extend({
|
|
|
|
primaryKey: 'name',
|
|
|
|
|
|
|
|
normalizePolicies(payload) {
|
2021-12-17 03:44:29 +00:00
|
|
|
const data = payload.data.keys ? payload.data.keys.map((name) => ({ name })) : payload.data;
|
2018-04-03 14:16:57 +00:00
|
|
|
return data;
|
|
|
|
},
|
|
|
|
|
|
|
|
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
|
|
|
|
const nullResponses = ['deleteRecord'];
|
2022-11-09 23:15:31 +00:00
|
|
|
const normalizedPayload = nullResponses.includes(requestType)
|
2018-04-03 14:16:57 +00:00
|
|
|
? { name: id }
|
|
|
|
: this.normalizePolicies(payload);
|
|
|
|
return this._super(store, primaryModelClass, normalizedPayload, id, requestType);
|
|
|
|
},
|
|
|
|
});
|