From 6705bcd8d7ea177db919b0cf9803bdc1b93c2bd5 Mon Sep 17 00:00:00 2001 From: TristanWright Date: Fri, 26 Feb 2016 15:52:46 -0700 Subject: [PATCH] fix(io): added jobs endpoint --- src/IO/Girder/HpcCloudEndpoints/index.js | 2 + src/IO/Girder/HpcCloudEndpoints/jobs.js | 62 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/IO/Girder/HpcCloudEndpoints/jobs.js diff --git a/src/IO/Girder/HpcCloudEndpoints/index.js b/src/IO/Girder/HpcCloudEndpoints/index.js index 234c50cec4..fb62d0cb43 100644 --- a/src/IO/Girder/HpcCloudEndpoints/index.js +++ b/src/IO/Girder/HpcCloudEndpoints/index.js @@ -1,5 +1,6 @@ import aws from './aws'; import clusters from './clusters'; +import jobs from './jobs'; import projects from './projects'; import simulations from './simulations'; import taskflows from './taskflows'; @@ -7,6 +8,7 @@ import taskflows from './taskflows'; export default [ aws, clusters, + jobs, projects, simulations, taskflows, diff --git a/src/IO/Girder/HpcCloudEndpoints/jobs.js b/src/IO/Girder/HpcCloudEndpoints/jobs.js new file mode 100644 index 0000000000..8435ffb523 --- /dev/null +++ b/src/IO/Girder/HpcCloudEndpoints/jobs.js @@ -0,0 +1,62 @@ +export default function({client, filterQuery, mustContain, busy}) { + return { + // GET /jobs List all jobs for a given user + getJobs(offset, limit){ + if (offset && limit) { + return busy(client._.get(`/jobs?offset=${offset}&limit=${limit}`)); + } else if (offset) { + return busy(client._.get(`/jobs?offset=${offset}`)); + } else if (limit) { + return busy(client._.get(`/jobs?limit=${limit}`)); + } + + return busy(client._.get('/jobs')); + }, + + // POST /jobs Create a new job + createJob(params){ + return busy(client._.post('/jobs', params)); + }, + + // GET /jobs/{id} Get a job + getJob(id){ + return busy(client._.post(`/jobs/${id}`)); + }, + + // PATCH /jobs/{id} Update the job + updateJob(id, params) { + return busy(client._.patch(`/jobs/${id}`, params)); + }, + + // DELETE /jobs/{id} Delete a job + deleteJob(id) { + return busy(client._.delete(`/jobs/${id}`)); + }, + + // GET /jobs/{id}/log Get log entries for job + getJobLog(id, offset){ + if (offset) { + return busy(client._.get(`/jobs/${id}/log?offset=${offset}`)); + } + return busy(client._.get(`/jobs/${id}/log`)); + }, + + // GET /jobs/{id}/output Get output entries for job + getJobOutput(id, path, offset){ + if (offset) { + return busy(client._.get(`/jobs/${id}/output?path=${path}&offset=${offset}`)); + } + return busy(client._.get(`/jobs/${id}/output?path=${path}`)); + }, + + // GET /jobs/{id}/status Get the status of a job + getJobStatus(id){ + return busy(client._.get(`/jobs/${id}/status`)); + }, + + // PUT /jobs/{id}/terminate Terminate a job + terminateJob(id){ + return busy(client._.put(`/jobs/${id}/terminate`)); + }, + }; +}