TaskLogs retrieves logs from the task app.
(ctx context.Context, user string, id uuid.UUID)
| 404 | |
| 405 | // TaskLogs retrieves logs from the task app. |
| 406 | func (c *Client) TaskLogs(ctx context.Context, user string, id uuid.UUID) (TaskLogsResponse, error) { |
| 407 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/tasks/%s/%s/logs", user, id.String()), nil) |
| 408 | if err != nil { |
| 409 | return TaskLogsResponse{}, err |
| 410 | } |
| 411 | defer res.Body.Close() |
| 412 | |
| 413 | if res.StatusCode != http.StatusOK { |
| 414 | return TaskLogsResponse{}, ReadBodyAsError(res) |
| 415 | } |
| 416 | |
| 417 | var logs TaskLogsResponse |
| 418 | if err := json.NewDecoder(res.Body).Decode(&logs); err != nil { |
| 419 | return TaskLogsResponse{}, xerrors.Errorf("decoding task logs response: %w", err) |
| 420 | } |
| 421 | |
| 422 | return logs, nil |
| 423 | } |