diff options
Diffstat (limited to 'model/client4.go')
-rw-r--r-- | model/client4.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go index f4a247e12..28434c2e5 100644 --- a/model/client4.go +++ b/model/client4.go @@ -254,6 +254,10 @@ func (c *Client4) GetOpenGraphRoute() string { return fmt.Sprintf("/opengraph") } +func (c *Client4) GetJobsRoute() string { + return fmt.Sprintf("/jobs") +} + func (c *Client4) DoApiGet(url string, etag string) (*http.Response, *AppError) { return c.DoApiRequest(http.MethodGet, c.ApiUrl+url, "", etag) } @@ -2638,3 +2642,25 @@ func (c *Client4) OpenGraph(url string) (map[string]string, *Response) { return MapFromJson(r.Body), BuildResponse(r) } } + +// Jobs Section + +// GetJobStatus gets the status of a single job. +func (c *Client4) GetJobStatus(id string) (*JobStatus, *Response) { + if r, err := c.DoApiGet(c.GetJobsRoute()+fmt.Sprintf("/%v/status", id), ""); err != nil { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return JobStatusFromJson(r.Body), BuildResponse(r) + } +} + +// GetJobStatusesByType gets the status of all jobs of a given type, sorted with the job that most recently started first. +func (c *Client4) GetJobStatusesByType(jobType string, page int, perPage int) ([]*JobStatus, *Response) { + if r, err := c.DoApiGet(c.GetJobsRoute()+fmt.Sprintf("/type/%v/statuses?page=%v&per_page=%v", jobType, page, perPage), ""); err != nil { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return JobStatusesFromJson(r.Body), BuildResponse(r) + } +} |