2023-03-15 16:00:52 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*/
|
|
|
|
|
2018-08-28 00:54:30 +00:00
|
|
|
import ApplicationSerializer from './application';
|
2023-02-10 19:31:47 +00:00
|
|
|
|
2018-08-28 00:54:30 +00:00
|
|
|
export default ApplicationSerializer.extend({
|
2023-02-10 19:31:47 +00:00
|
|
|
primaryKey: 'name',
|
|
|
|
|
2018-04-03 14:16:57 +00:00
|
|
|
extractLazyPaginatedData(payload) {
|
2022-11-09 23:15:31 +00:00
|
|
|
return payload.data.keys.map((key) => {
|
|
|
|
const model = {
|
2023-02-10 19:31:47 +00:00
|
|
|
name: key,
|
2018-04-03 14:16:57 +00:00
|
|
|
};
|
|
|
|
if (payload.backend) {
|
|
|
|
model.backend = payload.backend;
|
|
|
|
}
|
|
|
|
return model;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-08-28 00:54:30 +00:00
|
|
|
normalizeItems() {
|
2022-11-09 23:15:31 +00:00
|
|
|
const normalized = this._super(...arguments);
|
2018-08-28 00:54:30 +00:00
|
|
|
// most roles will only have one in this array,
|
|
|
|
// we'll default to the first, and keep the array on the
|
|
|
|
// model and show a warning if there's more than one so that
|
|
|
|
// they don't inadvertently save
|
|
|
|
if (normalized.credential_types) {
|
|
|
|
normalized.credential_type = normalized.credential_types[0];
|
2018-04-03 14:16:57 +00:00
|
|
|
}
|
2018-08-28 00:54:30 +00:00
|
|
|
return normalized;
|
2018-04-03 14:16:57 +00:00
|
|
|
},
|
|
|
|
});
|