all files / src/network/remote/ taskflows.js

44% Statements 11/25
50% Branches 12/24
30.77% Functions 4/13
44% Lines 11/25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94                                                                                                                                                                     
'use strict';
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
 
exports.default = function (_ref) {
  var client = _ref.client,
      filterQuery = _ref.filterQuery,
      mustContain = _ref.mustContain,
      busy = _ref.busy;
 
  return {
    // POST /taskflows Create the taskflow
    createTaskflow: function createTaskflow(taskFlowClass) {
      return busy(client._.post('/taskflows', { taskFlowClass: taskFlowClass }));
    },
 
 
    // GET /taskflows/{id} Get a taskflow
    getTaskflow: function getTaskflow(id, path) {
      if (path) {
        return busy(client._.get('/taskflows/' + id + '?path=' + path));
      }
      return busy(client._.get('/taskflows/' + id));
    },
 
 
    // PATCH /taskflows/{id} Update the taskflow
    updateTaskflow: function updateTaskflow(id, params) {
      return busy(client._.patch('/taskflows/' + id, params));
    },
 
 
    // DELETE /taskflows/{id} Delete the taskflow
    deleteTaskflow: function deleteTaskflow(id) {
      return busy(client._.delete('/taskflows/' + id));
    },
 
 
    // GET /taskflows/{id}/log Get log entries for taskflow
    getTaskflowLog: function getTaskflowLog(id) {
      var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
 
      if (offset !== 0) {
        return busy(client._.get('/taskflows/' + id + '/log?offset=' + offset));
      }
      return busy(client._.get('/taskflows/' + id + '/log'));
    },
 
 
    // PUT /taskflows/{id}/start Start the taskflow
    startTaskflow: function startTaskflow(id, cluster) {
      return busy(client._.put('/taskflows/' + id + '/start', cluster));
    },
 
 
    // GET /taskflows/{id}/status Get the taskflow status
    getTaskflowStatus: function getTaskflowStatus(id) {
      return busy(client._.get('/taskflows/' + id + '/status'));
    },
 
 
    // GET /taskflows/{id}/tasks Get all the tasks associated with this taskflow
    getTaskflowTasks: function getTaskflowTasks(id) {
      return busy(client._.get('/taskflows/' + id + '/tasks'));
    },
 
 
    // POST /taskflows/{id}/tasks Create a new task associated with this flow
    createNewTaskForTaskflow: function createNewTaskForTaskflow(id, params) {
      return busy(client._.post('/taskflows/' + id + '/tasks', params));
    },
 
 
    // PUT /taskflows/{id}/terminate Terminate the taskflow
    endTaskflow: function endTaskflow(id) {
      return busy(client._.put('/taskflows/' + id + '/terminate'));
    },
    shareTaskflow: function shareTaskflow(id) {
      var users = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
      var groups = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
 
      return busy(client._.patch('/taskflows/' + id + '/access', { users: users, groups: groups }));
    },
    unshareTaskflow: function unshareTaskflow(id) {
      var users = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
      var groups = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
 
      return busy(client._.patch('/taskflows/' + id + '/access/revoke', { users: users, groups: groups }));
    }
  };
};