2018-09-25 16:28:26 +00:00
|
|
|
import { computed } from '@ember/object';
|
2018-10-18 04:07:32 +00:00
|
|
|
import { alias } from '@ember/object/computed';
|
2018-04-03 14:16:57 +00:00
|
|
|
import DS from 'ember-data';
|
2018-10-17 03:10:41 +00:00
|
|
|
import KeyMixin from 'vault/mixins/key-mixin';
|
2018-04-03 14:16:57 +00:00
|
|
|
const { attr } = DS;
|
2018-10-18 04:07:32 +00:00
|
|
|
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities';
|
2018-04-03 14:16:57 +00:00
|
|
|
|
|
|
|
export default DS.Model.extend(KeyMixin, {
|
|
|
|
auth: attr('string'),
|
|
|
|
lease_duration: attr('number'),
|
|
|
|
lease_id: attr('string'),
|
|
|
|
renewable: attr('boolean'),
|
|
|
|
|
|
|
|
secretData: attr('object'),
|
|
|
|
|
|
|
|
dataAsJSONString: computed('secretData', function() {
|
|
|
|
return JSON.stringify(this.get('secretData'), null, 2);
|
|
|
|
}),
|
|
|
|
|
|
|
|
isAdvancedFormat: computed('secretData', function() {
|
|
|
|
const data = this.get('secretData');
|
|
|
|
return Object.keys(data).some(key => typeof data[key] !== 'string');
|
|
|
|
}),
|
|
|
|
|
|
|
|
helpText: attr('string'),
|
2018-10-17 03:10:41 +00:00
|
|
|
// TODO this needs to be a relationship like `engine` on kv-v2
|
2018-04-03 14:16:57 +00:00
|
|
|
backend: attr('string'),
|
2018-10-18 04:07:32 +00:00
|
|
|
secretPath: lazyCapabilities(apiPath`${'backend'}/${'id'}`, 'backend', 'id'),
|
|
|
|
canEdit: alias('secretPath.canUpdate'),
|
|
|
|
canDelete: alias('secretPath.canUpdate'),
|
|
|
|
canRead: alias('secretPath.canRead'),
|
2018-04-03 14:16:57 +00:00
|
|
|
});
|