open-vault/ui/app/adapters/aws-credential.js
Matthew Irish 572fb826be
UI aws engine tweaks (#5294)
* allow passing a path for options so that it can be extracted from the model

* add cred type selector for the aws generate form

* style hint text on generate creds form

* add tests for aws-credential adapter

* allow for the case where we might have zero ttl

* show error for TTL picker if a non-number is entered for the duration part of the TTL

* fix positioning of tooltips

* fix ttl rendering with invalid input for initialValue
2018-09-28 16:45:30 -05:00

32 lines
917 B
JavaScript

import ApplicationAdapter from './application';
export default ApplicationAdapter.extend({
createRecord(store, type, snapshot) {
let ttl = snapshot.attr('ttl');
let roleArn = snapshot.attr('roleArn');
let roleType = snapshot.attr('credentialType');
let method = 'POST';
let options;
let data = {};
if (roleType === 'iam_user') {
method = 'GET';
} else {
if (ttl !== undefined) {
data.ttl = ttl;
}
if (roleType === 'assumed_role' && roleArn) {
data.role_arn = roleArn;
}
options = data.ttl || data.role_arn ? { data } : {};
}
let role = snapshot.attr('role');
let url = `/v1/${role.backend}/creds/${role.name}`;
return this.ajax(url, method, options).then(response => {
response.id = snapshot.id;
response.modelName = type.modelName;
store.pushPayload(type.modelName, response);
});
},
});