2018-09-25 16:28:26 +00:00
|
|
|
import { assign } from '@ember/polyfills';
|
2018-04-03 14:16:57 +00:00
|
|
|
import ApplicationAdapter from './application';
|
|
|
|
|
|
|
|
export default ApplicationAdapter.extend({
|
|
|
|
namespace: 'v1/sys',
|
|
|
|
pathForType(type) {
|
2022-11-09 23:15:31 +00:00
|
|
|
const path = type.replace('policy', 'policies');
|
2018-04-03 14:16:57 +00:00
|
|
|
return path;
|
|
|
|
},
|
|
|
|
|
|
|
|
createOrUpdate(store, type, snapshot) {
|
|
|
|
const serializer = store.serializerFor('policy');
|
|
|
|
const data = serializer.serialize(snapshot);
|
|
|
|
const name = snapshot.attr('name');
|
|
|
|
|
|
|
|
return this.ajax(this.buildURL(type.modelName, name), 'PUT', { data }).then(() => {
|
|
|
|
// doing this to make it like a Vault response - ember data doesn't like 204s if it's not a DELETE
|
|
|
|
return {
|
2022-03-18 23:08:54 +00:00
|
|
|
data: assign({}, this.serialize(snapshot), { id: name }),
|
2018-04-03 14:16:57 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
createRecord() {
|
|
|
|
return this.createOrUpdate(...arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
updateRecord() {
|
|
|
|
return this.createOrUpdate(...arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
query(store, type) {
|
2018-12-10 16:44:37 +00:00
|
|
|
return this.ajax(this.buildURL(type.modelName), 'GET', {
|
|
|
|
data: { list: true },
|
|
|
|
});
|
2018-04-03 14:16:57 +00:00
|
|
|
},
|
|
|
|
});
|