Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Latest commit

 

History

History
256 lines (230 loc) · 6.25 KB

File metadata and controls

256 lines (230 loc) · 6.25 KB

Anomaly

An Anomaly is something that deviates from what is standard, normal, or expected.

The Anomaly API allows the administrator to create, view and manage a set of common anomalies for each device.

All the vocabulary used in the anomalies representations is described here.

Anomaly API contents

List device anomalies

List the anomalies of a specific device.

GET /devices/{deviceId}/anomalies

Parameters

Name Type In Required Description
deviceId integer path yes Identifier of the device.
accept string header no Setting to application/vnd.qrreport+json is recommended.
page integer query no Page number of the results to fetch. Default: 1

Response

Status: 200 OK 
{
    "class": [ "anomaly", "collection" ],
    "properties": {
        "pageIndex": 1,
        "pageMaxSize": 10,
        "collectionSize": 1
    },
    "entities": [
        {
            "class": [ "anomaly" ],
            "rel": [ "item" ],
            "properties": {
                "id": 1,
                "anomaly": "Broken toilet"
            },
            "actions": [
                {
                    "name": "update-anomaly",
                    "title": "Update anomaly",
                    "method": "PUT",
                    "href": "/devices/1/anomalies/1",
                    "type": "application/json",
                    "properties": [
                        { "name": "anomaly", "type": "string" }
                    ]
                },
                {
                    "name": "delete-anomaly",
                    "title": "Delete anomaly",
                    "method": "DELETE",
                    "href": "/devices/1/anomalies/1"
                }
            ],
            "links": [
                { "rel": [ "self" ], "href": "/devices/1/anomalies/1" }
            ]
        }
    ],
    "actions": [
        {
            "name": "create-anomaly",
            "title": "Create anomaly",
            "method": "POST",
            "href": "/devices/1/anomalies",
            "type": "application/json",
            "properties": [
                { "name": "anomaly", "type": "string" }
            ]
        }
    ],
    "links": [
        { "rel": [ "self" ], "href": "/devices/1/anomalies?page=1" },
        { "rel": [ "pagination" ], "href": "/devices/1/anomalies{?page}", "templated": true }
    ]
}
Status: 400 Bad Request
Status: 401 Unauthorized
Status: 403 Forbidden
Status: 404 Not Found

Create a device anomaly

Create a new anomaly for a specific device.

POST /devices/{deviceId}/anomalies

Parameters:

Name Type In Required Description
deviceId integer path yes Identifier of the device.
accept string header no Setting to application/vnd.qrreport+json is recommended.
content-type string header yes Set to application/json.
anomaly string body yes Unique anomaly.

Response

Status: 201 Created
Location: /devices/{deviceId}/anomalies
{
    "class": [ "anomaly" ],
    "properties": {
        "id": 1,
        "anomaly": "Broken toilet"
    },
    "links": [
        { "rel": [ "device-anomalies" ], "href": "/devices/1/anomalies" }
    ]
}
Status: 400 Bad Request
Status: 401 Unauthorized
Status: 403 Forbidden
Status: 409 Conflict
  • type: unique-constraint

Update an anomaly

Update the anomaly subject.

PUT /devices/{deviceId}/anomalies/{anomalyId}

Parameters

Name Type In Required Description
deviceId integer path yes Identifier of the device.
anomalyId integer path yes Identifier of the anomaly.
accept string header no Setting to application/vnd.qrreport+json is recommended.
content-type string header yes Set to application/json.
anomaly string body yes New unique anomaly for the device.

Response

Status: 200 OK 
{
    "class": [ "anomaly" ],
    "properties": {
        "id": 1,
        "name": "Broken toilet with water problem"
    },
    "links": [
        { "rel": [ "device-anomalies" ], "href": "/devices/1/anomalies" }
    ]
}
Status: 400 Bad Request
Status: 401 Unauthorized
Status: 403 Forbidden
Status: 404 Not Found
Status: 409 Conflict
  • type: unique-constraint

Delete an anomaly

Delete an anomaly on a specific device.

DELETE /devices/{deviceId}/anomalies/{anomalyId}

Parameters

Name Type In Required Description
deviceId integer path yes Identifier of the device.
anomalyId integer path yes Identifier of the anomaly.
accept string header no Setting to application/vnd.qrreport+json is recommended.

Response

Status: 200 OK 
{
    "class": [ "anomaly" ],
    "properties": {
        "id": 1,
        "anomaly": "Broken toilet"
    },
    "links": [
        { "rel": [ "device-anomalies" ], "href": "/devices/1/anomalies" }
    ]
}
Status: 400 Bad Request
Status: 401 Unauthorized
Status: 403 Forbidden
Status: 404 Not Found

Company representations vocabulary

Name Type Description
id number Unique identifier of the anomaly. Must be greater than 0.
anomaly string Unique subject for an anomaly of a specific device, but not globally unique.

Domain specific link relations

Name Description
device-anomalies Set of anomalies that belong to the device.

The vocabulary about the devices can be consulted here.

The documentation for the media-type, classes, standard link relations and generic errors used in the representations are described here.