open-nomad/ui/app/adapters/allocation.js
2019-05-21 09:24:17 -07:00

22 lines
628 B
JavaScript

import Watchable from './watchable';
import addToPath from 'nomad-ui/utils/add-to-path';
export default Watchable.extend({
stop: adapterAction('/stop'),
restart(allocation, taskName) {
const prefix = `${this.host || '/'}${this.urlPrefix()}`;
const url = `${prefix}/client/allocation/${allocation.id}/restart`;
return this.ajax(url, 'PUT', {
data: taskName && { TaskName: taskName },
});
},
});
function adapterAction(path, verb = 'POST') {
return function(allocation) {
const url = addToPath(this.urlForFindRecord(allocation.id, 'allocation'), path);
return this.ajax(url, verb);
};
}