2018-04-03 14:16:57 +00:00
|
|
|
import Ember from 'ember';
|
|
|
|
import DS from 'ember-data';
|
2018-06-12 21:06:37 +00:00
|
|
|
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities';
|
|
|
|
import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
|
2018-04-03 14:16:57 +00:00
|
|
|
|
|
|
|
const { attr } = DS;
|
2018-06-12 21:06:37 +00:00
|
|
|
const { computed } = Ember;
|
2018-04-03 14:16:57 +00:00
|
|
|
|
|
|
|
const CREATE_FIELDS = ['name', 'policy', 'arn'];
|
|
|
|
export default DS.Model.extend({
|
|
|
|
backend: attr('string', {
|
|
|
|
readOnly: true,
|
|
|
|
}),
|
|
|
|
name: attr('string', {
|
|
|
|
label: 'Role name',
|
|
|
|
fieldValue: 'id',
|
|
|
|
readOnly: true,
|
|
|
|
}),
|
|
|
|
arn: attr('string', {
|
|
|
|
helpText: '',
|
|
|
|
}),
|
|
|
|
policy: attr('string', {
|
|
|
|
helpText: '',
|
|
|
|
widget: 'json',
|
|
|
|
}),
|
|
|
|
attrs: computed(function() {
|
|
|
|
let keys = CREATE_FIELDS.slice(0);
|
2018-06-12 21:06:37 +00:00
|
|
|
return expandAttributeMeta(this, keys);
|
2018-04-03 14:16:57 +00:00
|
|
|
}),
|
|
|
|
|
2018-06-12 21:06:37 +00:00
|
|
|
updatePath: lazyCapabilities(apiPath`${'backend'}/roles/${'id'}`, 'backend', 'id'),
|
2018-04-03 14:16:57 +00:00
|
|
|
canDelete: computed.alias('updatePath.canDelete'),
|
|
|
|
canEdit: computed.alias('updatePath.canUpdate'),
|
|
|
|
canRead: computed.alias('updatePath.canRead'),
|
|
|
|
|
2018-06-12 21:06:37 +00:00
|
|
|
generatePath: lazyCapabilities(apiPath`${'backend'}/creds/${'id'}`, 'backend', 'id'),
|
2018-04-03 14:16:57 +00:00
|
|
|
canGenerate: computed.alias('generatePath.canUpdate'),
|
|
|
|
|
2018-06-12 21:06:37 +00:00
|
|
|
stsPath: lazyCapabilities(apiPath`${'backend'}/sts/${'id'}`, 'backend', 'id'),
|
2018-04-03 14:16:57 +00:00
|
|
|
canGenerateSTS: computed.alias('stsPath.canUpdate'),
|
|
|
|
});
|