Back to top

Image Manager

Simple CRUD service for storing firmware image metadata and binaries.

Images

Image Collection

List All Images
GET/image{?label}

Example URI

GET http://localhost:8000/fw-image/image?label="xyz"
URI Parameters
HideShow
label
string (optional) Example: "xyz"

Filter returned images by given label.

Request
HideShow
Headers
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  {
    "created": "2018-02-08T12:25:11.979313+00:00",
    "confirmed": true,
    "label": "ExampleFW",
    "fw_version": "1.0.0-rc1",
    "id": "b60aa5e9-cbe6-4b51-b76c-08cf8273db07"
  },
  {
    "created": "2018-02-08T12:25:11.998107+00:00",
    "confirmed": false,
    "label": "ExampleFW",
    "fw_version": "1.0.0-rc1",
    "id": "51b39543-9de1-4751-9fe2-48c8d6038ba1"
  },
  {
    "confirmed": false,
    "created": "2018-02-22T21:30:39.740576+00:00",
    "fw_version": "1.0.0-rc1",
    "id": "c929e347-0cd3-4925-a9ed-44ec59f7a1b9",
    "label": "ExampleFW"
  }
]
Response  401
HideShow

Returned when there is no Authorization header or if it contains an invalid value.

Headers
Content-Type: application/json
Body
{
  "message": "No authorization token has been supplied",
  "status": 401
}

Create a New Image
POST/image/

Creates a new image based on a JSON object containing the following metadata. All fields are required, images with missing metadata fields will return an error.

  • label: “FW_Example” (string) - An informative human-readable label.

  • fw_version: “1.0.0” (string) - FW Semantic versioning info.

Example URI

POST http://localhost:8000/fw-image/image/
Request
HideShow
Headers
Content-Type: application/json
Authorization: Bearer JWT
Body
{
  "label": "FW_Example",
  "fw_version": "1.0.0"
}
Response  201
HideShow
Headers
Content-Type: application/json
Location: /image/test_image
Schema
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "http://jsonschema.net",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "label": {
      "type": "string"
    },
    "published_at": {
      "type": "string"
    },
    "url": {
      "type": "string",
      "pattern": "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
    }
  },
  "required": [
    "label",
    "published_at",
    "url"
  ]
}
Response  400
HideShow

Returned when there is missing fields in creation request.

Headers
Content-Type: application/json
Body
{
  "message": "failed to parse input",
  "errors": {
    "label": [
      "Missing data for required field."
    ]
  }
}
Response  401
HideShow

Returned when there is no Authorization header or if it contains an invalid value.

Headers
Content-Type: application/json
Body
{
  "message": "No authorization token has been supplied",
  "status": 401
}

Binary Collection

List All Binaries
GET/image/binary/

Example URI

GET http://localhost:8000/fw-image/image/binary/
Request
HideShow
Headers
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json
Body
[
  "b60aa5e9-cbe6-4b51-b76c-08cf8273db07.hex"
]
Response  401
HideShow

Returned when there is no Authorization header or if it contains an invalid value.

Headers
Content-Type: application/json
Body
{
  "message": "No authorization token has been supplied",
  "status": 401
}

Images

Retrieve a single image metadata
GET/image/{image_id}

Example URI

GET http://localhost:8000/fw-image/image/b60aa5e9-cbe6-4b51-b76c-08cf8273db07
URI Parameters
HideShow
image_id
guid (required) Example: b60aa5e9-cbe6-4b51-b76c-08cf8273db07

Unique ID.

Request
HideShow
Headers
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "label": "FW_Example",
  "fw_version": "1.0.0"
}
Response  404
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "No such image: efac",
  "status": 404
}
Response  401
HideShow

Returned when there is no Authorization header or if it contains an invalid value.

Headers
Content-Type: application/json
Body
{
  "message": "No authorization token has been supplied",
  "status": 401
}

Delete
DELETE/image/{image_id}

Example URI

DELETE http://localhost:8000/fw-image/image/b60aa5e9-cbe6-4b51-b76c-08cf8273db07
URI Parameters
HideShow
image_id
guid (required) Example: b60aa5e9-cbe6-4b51-b76c-08cf8273db07

Unique ID.

Request
HideShow
Headers
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "removed_image": {
    "confirmed": true,
    "created": "2019-05-02T20:09:30.981452+00:00",
    "fw_version": "1.0.0-rc1",
    "id": "b60aa5e9-cbe6-4b51-b76c-08cf8273db07",
    "label": "ExampleFW"
  },
  "result": "ok"
}
Response  404
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "No such image: efac",
  "status": 404
}
Response  401
HideShow

Returned when there is no Authorization header or if it contains an invalid value.

Headers
Content-Type: application/json
Body
{
  "message": "No authorization token has been supplied",
  "status": 401
}

Image Binaries

All files should have a “.hex” extension.

Retrieve a single image binary
GET/image/{image_id}/binary

Example URI

GET http://localhost:8000/fw-image/image/b60aa5e9-cbe6-4b51-b76c-08cf8273db07/binary
URI Parameters
HideShow
image_id
guid (required) Example: b60aa5e9-cbe6-4b51-b76c-08cf8273db07

Unique ID.

Request
HideShow
Headers
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/octet-stream
Response  404
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "No such image: 57852f31-a906-4d5f-a0c3-fde41ff64d",
  "status": 404
}
Response  404
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "Image does not have an binary file",
  "status": 404
}
Response  401
HideShow

Returned when there is no Authorization header or if it contains an invalid value.

Headers
Content-Type: application/json
Body
{
  "message": "No authorization token has been supplied",
  "status": 401
}

Delete
DELETE/image/{image_id}/binary

Example URI

DELETE http://localhost:8000/fw-image/image/b60aa5e9-cbe6-4b51-b76c-08cf8273db07/binary
URI Parameters
HideShow
image_id
guid (required) Example: b60aa5e9-cbe6-4b51-b76c-08cf8273db07

Unique ID.

Request
HideShow
Headers
Authorization: Bearer JWT
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "result": "ok"
}
Response  404
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "No such image: 57852f31-a906-4d5f-a0c3-fde41ff64d",
  "status": 404
}
Response  401
HideShow

Returned when there is no Authorization header or if it contains an invalid value.

Headers
Content-Type: application/json
Body
{
  "message": "No authorization token has been supplied",
  "status": 401
}

Add binary to an existing image
POST/image/{image_id}/binary

Example URI

POST http://localhost:8000/fw-image/image/51b39543-9de1-4751-9fe2-48c8d6038ba1/binary
URI Parameters
HideShow
image_id
guid (required) Example: 51b39543-9de1-4751-9fe2-48c8d6038ba1

Unique ID.

Request
HideShow
Headers
Content-Type: multipart/form-data;boundary=BOUNDARY
Authorization: Bearer JWT
Body
--BOUNDARY
Content-Disposition: form-data; name="image"; filename="image.hex"
Content-Type: application/octet-stream

0123456789
--BOUNDARY--
Response  200
HideShow
Headers
Content-Type: application/json
Body
{
  "image": "51b39543-9de1-4751-9fe2-48c8d6038ba1",
  "message": "image uploaded"
}
Response  404
HideShow
Headers
Content-Type: application/json
Body
{
  "message": "No such image: 57852f31-a906-4d5f-a0c3-fde41ff64d",
  "status": 404
}
Response  401
HideShow

Returned when there is no Authorization header or if it contains an invalid value.

Headers
Content-Type: application/json
Body
{
  "message": "No authorization token has been supplied",
  "status": 401
}

Generated by aglio on 18 Jan 2021