2018-09-25 16:28:26 +00:00
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import { alias } from '@ember/object/computed';
|
2018-04-03 14:16:57 +00:00
|
|
|
import IdentityModel from './_base';
|
|
|
|
import DS from 'ember-data';
|
2019-10-04 20:15:33 +00:00
|
|
|
import apiPath from 'vault/utils/api-path';
|
|
|
|
import attachCapabilities from 'vault/lib/attach-capabilities';
|
2018-05-24 03:10:21 +00:00
|
|
|
|
2018-04-03 14:16:57 +00:00
|
|
|
const { attr, hasMany } = DS;
|
|
|
|
|
2019-10-04 20:15:33 +00:00
|
|
|
let Model = IdentityModel.extend({
|
2018-09-25 16:28:26 +00:00
|
|
|
formFields: computed(function() {
|
|
|
|
return ['name', 'disabled', 'policies', 'metadata'];
|
|
|
|
}),
|
2018-04-03 14:16:57 +00:00
|
|
|
name: attr('string'),
|
2018-05-24 03:10:21 +00:00
|
|
|
disabled: attr('boolean', {
|
|
|
|
defaultValue: false,
|
|
|
|
label: 'Disable entity',
|
|
|
|
helpText: 'All associated tokens cannot be used, but are not revoked.',
|
|
|
|
}),
|
2018-04-03 14:16:57 +00:00
|
|
|
mergedEntityIds: attr(),
|
2018-05-24 03:10:21 +00:00
|
|
|
metadata: attr({
|
2018-04-03 14:16:57 +00:00
|
|
|
editType: 'kv',
|
|
|
|
}),
|
|
|
|
policies: attr({
|
2018-12-10 16:44:37 +00:00
|
|
|
label: 'Policies',
|
|
|
|
editType: 'searchSelect',
|
|
|
|
fallbackComponent: 'string-list',
|
|
|
|
models: ['policy/acl', 'policy/rgp'],
|
2018-04-03 14:16:57 +00:00
|
|
|
}),
|
|
|
|
creationTime: attr('string', {
|
|
|
|
readOnly: true,
|
|
|
|
}),
|
|
|
|
lastUpdateTime: attr('string', {
|
|
|
|
readOnly: true,
|
|
|
|
}),
|
|
|
|
aliases: hasMany('identity/entity-alias', { async: false, readOnly: true }),
|
|
|
|
groupIds: attr({
|
|
|
|
readOnly: true,
|
|
|
|
}),
|
|
|
|
directGroupIds: attr({
|
|
|
|
readOnly: true,
|
|
|
|
}),
|
|
|
|
inheritedGroupIds: attr({
|
|
|
|
readOnly: true,
|
|
|
|
}),
|
2018-09-25 16:28:26 +00:00
|
|
|
canDelete: alias('updatePath.canDelete'),
|
|
|
|
canEdit: alias('updatePath.canUpdate'),
|
|
|
|
canRead: alias('updatePath.canRead'),
|
|
|
|
canAddAlias: alias('aliasPath.canCreate'),
|
2018-04-03 14:16:57 +00:00
|
|
|
});
|
2019-10-04 20:15:33 +00:00
|
|
|
|
|
|
|
export default attachCapabilities(Model, {
|
2020-09-16 18:57:13 +00:00
|
|
|
updatePath: apiPath`identity/entity/id/${'id'}`,
|
2019-10-04 20:15:33 +00:00
|
|
|
aliasPath: apiPath`identity/entity-alias`,
|
|
|
|
});
|