# JobTasks API

## Get task [GET /v3/task/:id]
> Get task with id ':id'

### Request
  * Policy: read_tasks
  * Method: GET
  * Headers:
    *  Accept: application/json
  * Params:
    * :id - task id

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json

## Get report [GET /v3/task/:id/report]
> Get report with task id ':id'

### Request
  * Policy: read_tasks
  * Method: GET
  * Headers:
    *  Accept: application/json
  * Params:
    * :id - task id

### Response
**Status: 200**
  * Headers:
    *  Content-Type: text/html

## Get status [GET /v3/task/:id/status]
> Get job status with task id ':id'

### Request
  * Policy: read_tasks
  * Method: GET
  * Headers:
    *  Accept: application/json
  * Params:
    * :id - task id

### Response
**Status: 200**
  * Headers:
    *  Content-Type: text/plain

## Get all tasks [GET /v3/tasks]
> Get all tasks

### Request
  * Policy: read_tasks
  * Method: GET
  * Headers:
    *  Accept: application/json
  * Params:
    * project - project id
    * environment - environment id
    * category - category name
    * type - job type
    * created_by - user id
    * date_from - date from filter (long)
    * date_to - date to filter (long)
    * sort - sort order
    * status - job status
    * server_id - server id

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
[
  {
    "id": "task id",
    "file": "report file name",
    "project": "project id",
    "environment": "environment id",
    "category": "category name",
    "created_by": "user",
    "type": job_type,
    "server_id": "server_id",
    "host": "server host",
    "stack": "stack name",
    "subtasks": [],
    "job_result_code": status
  }
]
```

## Get latest tasks [GET /v3/tasks/latest]
> Get latest tasks

### Request
  * Policy: read_tasks
  * Method: GET
  * Headers:
    *  Accept: application/json
  * Params:
    * project - project id
    * environment - environment id
    * category - category name
    * type - job type
    * created_by - user id
    * date_from - date from filter (long)
    * date_to - date to filter (long)
    * sort - sort order
    * status - job status
    * server_id - server id

### Response
**Status: 200**
  * Headers:
    *  Content-Type: application/json
  * Body:
```json
[
  {
    "id": "task id",
    "file": "report file name",
    "project": "project id",
    "environment": "environment id",
    "category": "category name",
    "created_by": "user",
    "type": job_type,
    "server_id": "server_id",
    "host": "server host",
    "stack": "stack name",
    "subtasks": [],
    "job_result_code": status
  }
]
```
