Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"babel-core": "^6.7.2",
"babel-loader": "^6.2.4",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.6.0",
"expect.js": "~0.3.1",
"form-data": "^1.0.0-rc3",
Expand Down
25 changes: 25 additions & 0 deletions src/api/task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export default class TaskAPI {
constructor(client) {
this.client = client;
}

run(command, { image, token, timeLimit }) {
const payload = { command };

if (image) {
payload.image = image;
}
if (token) {
payload.token = token;
}
if (timeLimit) {
payload.time_limit = timeLimit;
}

return this.client.request(`tasks/`, 'POST', payload);
}

get(task_id) {
return this.client.request(`tasks/${task_id}/`);
}
}
3 changes: 3 additions & 0 deletions src/client.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import fetch from 'isomorphic-fetch';
import querystring from 'querystring';
import _ from 'lodash';
import 'babel-polyfill';

import DocumentAPI from './api/document';
import FileAPI from './api/file';
import RoleAPI from './api/role';
import SchemaAPI from './api/schema';
import UserAPI from './api/user';
import PolicyAPI from './api/policy';
import TaskAPI from './api/task';

export default class Client {
constructor(project, token) {
Expand All @@ -22,6 +24,7 @@ export default class Client {
this.roles = new RoleAPI(this);
this.files = new FileAPI(this);
this.policy = new PolicyAPI(this);
this.tasks = new TaskAPI(this);
}

url(endpoint) {
Expand Down