2018-04-03 14:16:57 +00:00
|
|
|
import DS from 'ember-data';
|
|
|
|
import Ember from 'ember';
|
2018-06-12 21:06:37 +00:00
|
|
|
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 = [
|
|
|
|
'publicKey',
|
|
|
|
'keyId',
|
|
|
|
'validPrincipals',
|
|
|
|
'certType',
|
|
|
|
'criticalOptions',
|
|
|
|
'extension',
|
|
|
|
'ttl',
|
|
|
|
];
|
|
|
|
|
|
|
|
const DISPLAY_FIELDS = ['signedKey', 'leaseId', 'renewable', 'leaseDuration', 'serialNumber'];
|
|
|
|
|
|
|
|
export default DS.Model.extend({
|
|
|
|
role: attr('object', {
|
|
|
|
readOnly: true,
|
|
|
|
}),
|
|
|
|
publicKey: attr('string'),
|
|
|
|
ttl: attr({
|
|
|
|
label: 'TTL',
|
|
|
|
editType: 'ttl',
|
|
|
|
}),
|
|
|
|
validPrincipals: attr('string'),
|
|
|
|
certType: attr('string', {
|
|
|
|
defaultValue: 'user',
|
|
|
|
label: 'Certificate Type',
|
|
|
|
possibleValues: ['user', 'host'],
|
|
|
|
}),
|
|
|
|
keyId: attr('string', {
|
|
|
|
label: 'Key ID',
|
|
|
|
}),
|
|
|
|
criticalOptions: attr('object'),
|
|
|
|
extension: attr('object'),
|
|
|
|
|
|
|
|
leaseId: attr('string', {
|
|
|
|
label: 'Lease ID',
|
|
|
|
}),
|
|
|
|
renewable: attr('boolean'),
|
|
|
|
leaseDuration: attr('number'),
|
|
|
|
serialNumber: attr('string'),
|
|
|
|
signedKey: attr('string'),
|
|
|
|
|
|
|
|
attrs: computed('signedKey', function() {
|
|
|
|
let keys = this.get('signedKey') ? DISPLAY_FIELDS.slice(0) : CREATE_FIELDS.slice(0);
|
2018-06-12 21:06:37 +00:00
|
|
|
return expandAttributeMeta(this, keys);
|
2018-04-03 14:16:57 +00:00
|
|
|
}),
|
|
|
|
});
|