open-vault/ui/app/adapters/auth-config/_base.js
2018-04-03 09:16:57 -05:00

39 lines
1 KiB
JavaScript

import ApplicationAdapter from '../application';
export default ApplicationAdapter.extend({
namespace: '/v1/auth',
pathForType(modelType) {
// we want the last part of the path
const type = modelType.split('/').pop();
if (type === 'identity-whitelist' || type === 'roletag-blacklist') {
return `tidy/${type}`;
}
return type;
},
buildURL(modelName, id, snapshot) {
const backendId = id ? id : snapshot.belongsTo('backend').id;
let url = `${this.get('namespace')}/${backendId}/config`;
// aws has a lot more config endpoints
if (modelName.includes('aws')) {
url = `${url}/${this.pathForType(modelName)}`;
}
return url;
},
createRecord(store, type, snapshot) {
const id = snapshot.belongsTo('backend').id;
return this._super(...arguments).then(() => {
return { id };
});
},
updateRecord(store, type, snapshot) {
const id = snapshot.belongsTo('backend').id;
return this._super(...arguments).then(() => {
return { id };
});
},
});