open-vault/ui/app/models/role-aws.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-04-03 14:16:57 +00:00
import Ember from 'ember';
import DS from 'ember-data';
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;
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);
return expandAttributeMeta(this, keys);
2018-04-03 14:16:57 +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'),
generatePath: lazyCapabilities(apiPath`${'backend'}/creds/${'id'}`, 'backend', 'id'),
2018-04-03 14:16:57 +00:00
canGenerate: computed.alias('generatePath.canUpdate'),
stsPath: lazyCapabilities(apiPath`${'backend'}/sts/${'id'}`, 'backend', 'id'),
2018-04-03 14:16:57 +00:00
canGenerateSTS: computed.alias('stsPath.canUpdate'),
});