<commit_before>
# Common api information

Common information about all exposed API endpoints.

## Date format
Dates are formatted with [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) standard.

## OPTIONS method support
Each endpoint supports OPTIONS HTTP method.

          Allow: GET,POST,OPTIONS

## Cross-origin resource sharing

CORS and none-CORS requests are supported. Details [wikipedia](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing#Simple_example).

Allows `location` header exposure.

# Group Device

## Authorization

Incoming requests must set `Authorization` header and include device token
obtained from the API. The header shall look like this:

```
Authorization: Bearer <token>
# example
Authorization: Bearer <KEY>

```

## List updates for device [GET /api/0.0.1/device/update]
List next update to be installed on the device.

+ Request

    + Headers

        Authorization: Bearer <token>

+ Response 200 (application/json)
    Next update for the device.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "id": "/",
                "type": "object",
                "properties": {
                    "image": {
                        "id": "image",
                        "type": "object",
                        "properties": {
                            "uri": {
                                "id": "uri",
                                "type": "string"
                            },
                            "checksum": {
                                "id": "checksum",
                                "type": "string"
                            },
                            "id": {
                                "id": "id",
                                "type": "string"
                            },
                            "expire": {
                                "id": "expire",
                                "type": "string"
                            },
                            "yocto_id": {
                                "id": "yocto_id",
                                "type": "string"
                            }
                        },
                        "required": [
                            "uri",
                            "id",
                            "yocto_id"
                        ]
                    },
                    "id": {
                        "id": "id",
                        "type": "string"
                    }
                },
                "required": [
                    "image",
                    "id"
                ]
            }

    + Body

            {
                "image": {
                    "uri": "https://aws.my_update_bucket.com/yocto_image123",
                    "checksum": "cc436f982bc60a8255fe1926a450db5f195a19ad",
                    "id": "f81d4fae-7dec-11d0-a765-00a0c91e6bf6",
                    "expire": "2016-03-11T13:03:17.063493443Z",
                    "yocto_id": "core-image-full-cmdline-20160330201408"
                },
                "id": "w81s4fae-7dec-11d0-a765-00a0c91e6bf6"
            }

+ Response 204
    No updates for the device are available.

    + Body

+ Response 400 (application/json)
    Invalid request.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 404 (application/json)
    Resource not found.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }


## Report deployment status [PUT /api/0.1.0/device/deployments/{deployment_id}/status]

Allows to update the status of deployment on a particular device. Final status
of the deployment is required to be set to indicate end of the installation
process: success or failure. Reporting of intermediate steps such as installing,
downloading, rebooting is optionall.

+ Parameters

    + deployment_id: `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` (string,required) - Deplyoment ID

+ Request (application/json)

    + Headers

        Authorization: Bearer <token>

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "status": {
                        "type": "string",
                        "enum": [
                            "installing",
                            "downloading",
                            "rebooting",
                            "success",
                            "failure"
                        ]
                    }
                },
                "required": [
                    "status"
                ]
            }

    + Body

            {
                "status": "success"
            }

+ Response 204
    Deployment status updated. No body

+ Response 400 (application/json)
    Invalid request.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 404 (application/json)
    Resource not found.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

# Group Deployment

## Lookup deployments [GET /api/0.0.1/deployments{?name}]
Lookup deployments in the system, including active and history.

+ Parameters
    + name: `<NAME>` (string, optional) - Deployment name (TODO: To be implemented)

+ Response 200 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "created": {
                            "id": "created",
                            "type": "string"
                        },
                        "name": {
                            "id": "name",
                            "type": "string"
                        },
                        "artifact_name": {
                            "id": "artifact_name",
                            "type": "string"
                        },
                        "id": {
                            "id": "id",
                            "type": "string"
                        },
                        "finished": {
                            "id": "finished",
                            "type": "string"
                        }
                    },
                    "required": [
                        "created",
                        "name",
                        "artifact_name",
                        "id"
                    ]
                }
            }

    + Body

            [
                {
                    "created": "2016-02-11T13:03:17.063493443Z",
                    "name": "production",
                    "artifact_name": "Application 0.0.1",
                    "id": "00a0c91e6-7dec-11d0-a765-f81d4faebf6",
                    "finished": "2016-03-11T13:03:17.063493443Z"
                }
            ]

+ Response 400 (application/json)
    Invalid request

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

## Deploy software [POST /api/0.0.1/deployments]
Deploy software to specified devices. Image is auto assigned to the device from all available images based on artifact name and device type.
NOTE: Because of lack of inventory system, service assumes hardcoded device type for each device: "TestDevice"

+ Request (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": ¸{
                    "name": {
                        "id": "name",
                        "type": "string"
                    },
                    "artifact_name": {
                        "id": "artifact_name",
                        "type": "string"
                    },
                    "devices": {
                        "id": "devices",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "required": [
                    "name",
                    "artifact_name",
                    "devices"
                ]
            }

    + Body

            {
                "name": "Monthly update: January",
                "artifact_name": "MySecretApp v2",
                "devices": [
                    "00a0c91e6-7dec-11d0-a765-f81d4faebf6",
                    "50b0c91e6-1drc-51d0-a165-g81d4faebry"
                ]
            }

+ Response 201 (application/json)
    + Headers

            Location: /api/0.0.1/deployments/{id}

+ Response 400 (application/json)
    Bad request. The request could not be understood by the server due to malformed syntax.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
                }

+ Response 404 (application/json)
    Resource not found

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

## Manage deployment [/api/0.0.1/deployments/{id}]
Manage specific deployment.

### Status [GET]
Check status for specified deployment

+ Parameters
    + id (string,required) - Deployment identifier

+ Response 200 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "created": {
                        "id": "created",
                        "type": "string"
                    },
                    "name": {
                        "id": "name",
                        "type": "string",
                    },
                    "artifact_name": {
                        "id": "artifact_name",
                        "type": "string"
                    },
                    "id": {
                        "id": "id",
                        "type": "string"
                    },
                    "finished": {
                        "id": "finished",
                        "type": "string"
                    }
                },
                "required": [
                    "created",
                    "name",
                    "artifact_name",
                    "id"
                ]
            }

    + Body

            {
                "created": "2016-02-11T13:03:17.063493443Z",
                "name": "production",
                "artifact_name": "Application 0.0.1",
                "id": "00a0c91e6-7dec-11d0-a765-f81d4faebf6",
                "finished": "2016-03-11T13:03:17.063493443Z"
            }

+ Response 404 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

### Cancel [DELETE]
Cancel deployment.
TODO: To be implemented

+ Parameters
    + id: `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` (string,required) - Deployment identifier

+ Response 204

+ Response 404 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

### Statistics [GET /api/0.0.1/deployments/{deployment_id}/statistics]
Statistics for the deployment.
TODO: To be implemented & statuses may change

+ Parameters
    + deployment_id: `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` (string,required) - Deployment identifier

+ Response 200 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "success": {
                        "id": "success",
                        "type": "integer",
                        "description": "Number of successful deployments"
                    },
                    "pending": {
                        "id": "pending",
                        "type": "integer",
                        "description": "Number of pending deployments"
                    },
                    "downloading": {
                        "id": "downloading",
                        "type": "integer",
                        "description": "Number of deployments being downloaded"
                    },
                    "rebooting": {
                        "id": "rebooting",
                        "type": "integer",
                        "description": "Number of deployments devices are rebooting into "
                    },
                    "installing": {
                        "id": "downloading",
                        "type": "integer",
                        "description": "Number of deployments being installed"
                    },
                    "failure": {
                        "id": "failure",
                        "type": "integer",
                        "description": "Number of failed deployments."
                    },
                    "noimage": {
                        "id": "noimage",
                        "type": "integer",
                        "description": "Do not have apropriate image for the device model."
                    }

                },
                "required": [
                    "success",
                    "pending",
                    "failure",
                    "noimage"
                    "downloading",
                    "installing",
                    "rebooting"
                ]
            }

    + Body

            {
                "success": 3,
                "pending": 1,
                "failure": 0,
                "downloading": 1,
                "installing": 2,
                "rebooting": 3
                "noimage:" 0
            }

+ Response 404 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

### List devices [GET /api/0.0.1/deployments/{deployment_id}/devices]
Device statuses for the deployment.
TODO: To be implemented

+ Parameters
    + deployment_id: `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` (string,required) - Deployment identifier

+ Response 200 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "id": "/",
                "type": "array",
                "items": {
                    "id": "0",
                    "type": "object",
                    "properties": {
                        "id": {
                            "id": "id",
                            "type": "string"
                        },
                        "finished": {
                            "id": "finished",
                            "type": "string"
                        },
                        "status": {
                            "id": "status",
                            "type": "string",
                            "enum": [
                                "inprogress",
                                "pending",
                                "success",
                                "failure",
                                "noimage"
                            ]
                        },
                        "started": {
                            "id": "started",
                            "type": "string"
                        },
                        "device_type": {
                            "id": "device_type",
                            "type": "string"
                        },
                        "artifact_id": {
                            "id": "artifact_id",
                            "type": "string"
                        }
                    },
                    "required": [
                        "id",
                        "status",
                        "device_type"
                    ]
                }
            }

    + Body

            [
                {
                    "id": "00a0c91e6-7dec-11d0-a765-f81d4faebf6",
                    "finished": "2016-03-11T13:03:17.063493443Z",
                    "status": "pending",
                    "started": "2016-02-11T13:03:17.063493443Z",
                    "device_type": "Raspberry Pi 3",
                    "artifact_id": "60a0c91e6-7dec-11d0-a765-f81d4faebf6"
                }
            ]

+ Response 404 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.
<commit_msg>minor doc update<commit_after>
# Common api information

Common information about all exposed API endpoints.

## Date format
Dates are formatted with [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) standard.

## OPTIONS method support
Each endpoint supports OPTIONS HTTP method.

          Allow: GET,POST,OPTIONS

## Cross-origin resource sharing

CORS and none-CORS requests are supported. Details [wikipedia](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing#Simple_example).

Allows `location` header exposure.

# Group Device

## Authorization

Incoming requests must set `Authorization` header and include device token
obtained from the API. The header shall look like this:

```
Authorization: Bearer <token>
# example
Authorization: Bearer <KEY>

```

## List updates for device [GET /api/0.0.1/device/update]
List next update to be installed on the device.

+ Request

    + Headers

        Authorization: Bearer <token>

+ Response 200 (application/json)
    Next update for the device.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "id": "/",
                "type": "object",
                "properties": {
                    "image": {
                        "id": "image",
                        "type": "object",
                        "properties": {
                            "uri": {
                                "id": "uri",
                                "type": "string"
                            },
                            "checksum": {
                                "id": "checksum",
                                "type": "string"
                            },
                            "id": {
                                "id": "id",
                                "type": "string"
                            },
                            "expire": {
                                "id": "expire",
                                "type": "string"
                            },
                            "yocto_id": {
                                "id": "yocto_id",
                                "type": "string"
                            }
                        },
                        "required": [
                            "uri",
                            "id",
                            "yocto_id"
                        ]
                    },
                    "id": {
                        "id": "id",
                        "type": "string"
                    }
                },
                "required": [
                    "image",
                    "id"
                ]
            }

    + Body

            {
                "image": {
                    "uri": "https://aws.my_update_bucket.com/yocto_image123",
                    "checksum": "cc436f982bc60a8255fe1926a450db5f195a19ad",
                    "id": "f81d4fae-7dec-11d0-a765-00a0c91e6bf6",
                    "expire": "2016-03-11T13:03:17.063493443Z",
                    "yocto_id": "core-image-full-cmdline-20160330201408"
                },
                "id": "w81s4fae-7dec-11d0-a765-00a0c91e6bf6"
            }

+ Response 204
    No updates for the device are available.

    + Body

+ Response 400 (application/json)
    Invalid request.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 404 (application/json)
    Resource not found.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }


## Report deployment status [PUT /api/0.1.0/device/deployments/{deployment_id}/status]

Allows to update the status of deployment on a particular device. Final status
of the deployment is required to be set to indicate end of the installation
process: success or failure. Reporting of intermediate steps such as installing,
downloading, rebooting is optionall.

+ Parameters

    + deployment_id: `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` (string,required) - Deplyoment ID

+ Request (application/json)

    + Headers

        Authorization: Bearer <token>

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "status": {
                        "type": "string",
                        "enum": [
                            "installing",
                            "downloading",
                            "rebooting",
                            "success",
                            "failure"
                        ]
                    }
                },
                "required": [
                    "status"
                ]
            }

    + Body

            {
                "status": "success"
            }

+ Response 204
    Deployment status updated. No body

+ Response 400 (application/json)
    Invalid request.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 404 (application/json)
    Resource not found.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

# Group Deployment

## Lookup deployments [GET /api/0.0.1/deployments{?name}]
Lookup deployments in the system, including active and history.

+ Parameters
    + name: `<NAME>` (string, optional) - Deployment name (TODO: To be implemented)

+ Response 200 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "array",
                "items": {
                    "type": "object",
                    "properties": {
                        "created": {
                            "id": "created",
                            "type": "string"
                        },
                        "name": {
                            "id": "name",
                            "type": "string"
                        },
                        "artifact_name": {
                            "id": "artifact_name",
                            "type": "string"
                        },
                        "id": {
                            "id": "id",
                            "type": "string"
                        },
                        "finished": {
                            "id": "finished",
                            "type": "string"
                        }
                    },
                    "required": [
                        "created",
                        "name",
                        "artifact_name",
                        "id"
                    ]
                }
            }

    + Body

            [
                {
                    "created": "2016-02-11T13:03:17.063493443Z",
                    "name": "production",
                    "artifact_name": "Application 0.0.1",
                    "id": "00a0c91e6-7dec-11d0-a765-f81d4faebf6",
                    "finished": "2016-03-11T13:03:17.063493443Z"
                }
            ]

+ Response 400 (application/json)
    Invalid request

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

## Deploy software [POST /api/0.0.1/deployments]
Deploy software to specified devices. Image is auto assigned to the device from all available images based on artifact name and device type.
NOTE: Because of lack of inventory system, service assumes hardcoded device type for each device: "TestDevice"

+ Request (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": ¸{
                    "name": {
                        "id": "name",
                        "type": "string"
                    },
                    "artifact_name": {
                        "id": "artifact_name",
                        "type": "string"
                    },
                    "devices": {
                        "id": "devices",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "required": [
                    "name",
                    "artifact_name",
                    "devices"
                ]
            }

    + Body

            {
                "name": "Monthly update: January",
                "artifact_name": "MySecretApp v2",
                "devices": [
                    "00a0c91e6-7dec-11d0-a765-f81d4faebf6",
                    "50b0c91e6-1drc-51d0-a165-g81d4faebry"
                ]
            }

+ Response 201 (application/json)
    + Headers

            Location: /api/0.0.1/deployments/{id}

+ Response 400 (application/json)
    Bad request. The request could not be understood by the server due to malformed syntax.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
                }

+ Response 404 (application/json)
    Resource not found

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

## Manage deployment [/api/0.0.1/deployments/{id}]
Manage specific deployment.

### Status [GET]
Check status for specified deployment

+ Parameters
    + id (string,required) - Deployment identifier

+ Response 200 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "created": {
                        "id": "created",
                        "type": "string"
                    },
                    "name": {
                        "id": "name",
                        "type": "string",
                    },
                    "artifact_name": {
                        "id": "artifact_name",
                        "type": "string"
                    },
                    "id": {
                        "id": "id",
                        "type": "string"
                    },
                    "finished": {
                        "id": "finished",
                        "type": "string"
                    }
                },
                "required": [
                    "created",
                    "name",
                    "artifact_name",
                    "id"
                ]
            }

    + Body

            {
                "created": "2016-02-11T13:03:17.063493443Z",
                "name": "production",
                "artifact_name": "Application 0.0.1",
                "id": "00a0c91e6-7dec-11d0-a765-f81d4faebf6",
                "finished": "2016-03-11T13:03:17.063493443Z"
            }

+ Response 404 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

### Cancel [DELETE]
Cancel deployment.
TODO: To be implemented

+ Parameters
    + id: `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` (string,required) - Deployment identifier

+ Response 204

+ Response 404 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

### Statistics [GET /api/0.0.1/deployments/{deployment_id}/statistics]
Statistics for the deployment.
TODO: To be implemented & statuses may change

+ Parameters
    + deployment_id: `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` (string,required) - Deployment identifier

+ Response 200 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "success": {
                        "id": "success",
                        "type": "integer",
                        "description": "Number of successful deployments"
                    },
                    "pending": {
                        "id": "pending",
                        "type": "integer",
                        "description": "Number of pending deployments"
                    },
                    "downloading": {
                        "id": "downloading",
                        "type": "integer",
                        "description": "Number of deployments being downloaded"
                    },
                    "rebooting": {
                        "id": "rebooting",
                        "type": "integer",
                        "description": "Number of deployments devices are rebooting into "
                    },
                    "installing": {
                        "id": "downloading",
                        "type": "integer",
                        "description": "Number of deployments being installed"
                    },
                    "failure": {
                        "id": "failure",
                        "type": "integer",
                        "description": "Number of failed deployments."
                    },
                    "noimage": {
                        "id": "noimage",
                        "type": "integer",
                        "description": "Do not have apropriate image for the device model."
                    }

                },
                "required": [
                    "success",
                    "pending",
                    "failure",
                    "noimage"
                    "downloading",
                    "installing",
                    "rebooting"
                ]
            }

    + Body

            {
                "success": 3,
                "pending": 1,
                "failure": 0,
                "downloading": 1,
                "installing": 2,
                "rebooting": 3
                "noimage:" 0
            }

+ Response 404 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

### List devices [GET /api/0.0.1/deployments/{deployment_id}/devices]
Device statuses for the deployment.

+ Parameters
    + deployment_id: `f81d4fae-7dec-11d0-a765-00a0c91e6bf6` (string,required) - Deployment identifier

+ Response 200 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "id": "/",
                "type": "array",
                "items": {
                    "id": "0",
                    "type": "object",
                    "properties": {
                        "id": {
                            "id": "id",
                            "type": "string"
                        },
                        "finished": {
                            "id": "finished",
                            "type": "string"
                        },
                        "status": {
                            "id": "status",
                            "type": "string",
                            "enum": [
                                "inprogress",
                                "pending",
                                "success",
                                "failure",
                                "noimage"
                            ]
                        },
                        "started": {
                            "id": "started",
                            "type": "string"
                        },
                        "device_type": {
                            "id": "device_type",
                            "type": "string"
                        },
                        "artifact_id": {
                            "id": "artifact_id",
                            "type": "string"
                        }
                    },
                    "required": [
                        "id",
                        "status",
                        "device_type"
                    ]
                }
            }

    + Body

            [
                {
                    "id": "00a0c91e6-7dec-11d0-a765-f81d4faebf6",
                    "finished": "2016-03-11T13:03:17.063493443Z",
                    "status": "pending",
                    "started": "2016-02-11T13:03:17.063493443Z",
                    "device_type": "Raspberry Pi 3",
                    "artifact_id": "60a0c91e6-7dec-11d0-a765-f81d4faebf6"
                }
            ]

+ Response 404 (application/json)
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 400 (application/json)
    Argument error - see response for details.
    + Schema

            {
                "$schema": "http://json-schema.org/draft-04/schema#",
                "type": "object",
                "properties": {
                    "error": {
                        "id": "error",
                        "type": "string"
                    }
                }
            }

    + Body

            {
                "error": "Detailed error message"
            }

+ Response 500 (application/json)
    Internal server error. Please retry in a while.

{'fraction_non_alphanumeric': 0.11450286309213951, 'fraction_numerical': 0.02459135866736075, 'mean_word_length': 0.8303986584343319, 'pattern_counts': {'":': 623, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2079543', 'n_tokens_mistral': 12947, 'n_tokens_neox': 11272, 'n_words': 2383}