mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-28 04:10:44 -04:00
* license: update headers to IBM Corp. * `make proto` * update offset because source file changed Signed-off-by: Ryan Cragun <me@ryan.ec> Co-authored-by: Ryan Cragun <me@ryan.ec>
33 lines
938 B
JavaScript
33 lines
938 B
JavaScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
|
|
import ApplicationSerializer from './application';
|
|
|
|
export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
|
|
attrs: {
|
|
requestEntity: { embedded: 'always' },
|
|
authorizations: { embedded: 'always' },
|
|
},
|
|
|
|
normalizeResponse(store, primaryModelClass, payload) {
|
|
const entity = payload?.data?.request_entity;
|
|
if (Array.isArray(payload.data.authorizations)) {
|
|
for (const authorization of payload.data.authorizations) {
|
|
authorization.id = authorization.entity_id;
|
|
authorization.name = authorization.entity_name;
|
|
}
|
|
}
|
|
|
|
if (entity && Object.keys(entity).length === 0) {
|
|
payload.data.request_entity = null;
|
|
}
|
|
return this._super(...arguments);
|
|
},
|
|
|
|
serialize(snapshot) {
|
|
return { accessor: snapshot.id };
|
|
},
|
|
});
|