Templates

Templates scheme

Each template is identified by its unique id, its label and a list of elements.

Scheme:

{
    "id": "UUID",
    "label": "String",
    "elements": [
        {
            "id": "UUID",
            "metric": "String",
            "type": "String
        }
    ]
}

Example chart:

{
    "label": "template",
    "id": "12618492-27ed-4108-8398-479274adfd32",
    "elements": [
        {
            "type": "test.type",
            "metric": "hree",
            "id": "d2c418da-7b40-4482-89cb-f1362fd7190e"
        },
        {
            "type": "test.type",
            "metric": "wo",
            "id": "f562799a-1151-45f7-8f2d-d71ee79c9b8e"
        }
    ]
}

GET methods

GET /api/v1/templates

Returns all the templates with their relative information if at least one resource exists, otherwise returns an empty collection.

Example request:

GET /api/v1/templates HTTP/1.1
Host: https://ccharts.hir.facts4.work/

Example response:

HTTP/1.1 200 OK
Content-type: application/json

{
    "data": [
        {
            "label": "template",
            "id": "12618492-27ed-4108-8398-479274adfd32",
            "elements": [
                {
                    "type": "test.type",
                    "metric": "hree",
                    "id": "d2c418da-7b40-4482-89cb-f1362fd7190e"
                },
                {
                    "type": "test.type",
                    "metric": "wo",
                    "id": "f562799a-1151-45f7-8f2d-d71ee79c9b8e"
                }
            ]
        }
    ]
}
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Response JSON Array of Objects:
 
  • id (string) – id of the template
  • label (string) – label of the template
  • elements (array) – array of elements composing the template
Status Codes:
GET /api/v1/templates/:id

Returns a specific template with :id and the rest of its parameters if it exists, otherwise returns 404 error.

Example request:

GET /api/v1/templates/12618492-27ed-4108-8398-479274adfd32 HTTP/1.1
Host: https://ccharts.hir.facts4.work/

Example response:

HTTP/1.1 200 OK
Content-type: application/json

{
    "data": {
        "label": "template",
        "id": "12618492-27ed-4108-8398-479274adfd32",
        "elements": [
            {
                "type": "test.type",
                "metric": "hree",
                "id": "d2c418da-7b40-4482-89cb-f1362fd7190e"
            },
            {
                "type": "test.type",
                "metric": "wo",
                "id": "f562799a-1151-45f7-8f2d-d71ee79c9b8e"
            }
        ]
    }
}
Parameters:
  • id (string) – template’s unique id
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Response JSON Array of Objects:
 
  • id (string) – id of the template
  • label (string) – label of the template
  • elements (array) – array of elements composing the template
Status Codes:

POST methods

POST /api/v1/templates

Adds a new template with its required fields. Required fields are label and elements.

Returns the newly created resource or error message if the request was not valid.

Example request:

POST /api/v1/templates HTTP/1.1
Host: https://ccharts.hir.facts4.work/
Content-Type: application/json

{
    "template": {
        "label": "template one",
        "elements": [
            {
                "type": "test.type",
                "metric": "hree"
            },
            {
                "type": "test.type",
                "metric": "wo"
            }
        ]
    }
}

Example response:

HTTP/1.1 201 Created
Content-type: application/json

{
    "data": {
        "label": "template",
        "id": "12618492-27ed-4108-8398-479274adfd32",
        "elements": [
            {
                "type": "test.type",
                "metric": "hree",
                "id": "d2c418da-7b40-4482-89cb-f1362fd7190e"
            },
            {
                "type": "test.type",
                "metric": "wo",
                "id": "f562799a-1151-45f7-8f2d-d71ee79c9b8e"
            }
        ]
    }
}
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Request JSON Array of Objects:
 
  • label (string) – label of the template
  • elements (array) – array of elements composing the template
Response JSON Array of Objects:
 
  • id (string) – id of the template
  • label (string) – label of the template
  • elements (array) – array of elements composing the template
Status Codes:

PUT methods

PUT /api/v1/templates/:id

Updates an existing template with new information. Returns the updated resource or an error message.

Example request:

PUT /api/v1/templates/12618492-27ed-4108-8398-479274adfd32 HTTP/1.1
Host: https://ccharts.hir.facts4.work/
Content-Type: application/json

{
    "template": {
        "label": "template",
        "elements": [
            {
                "type": "test.type",
                "metric": "hree"
            },
            {
                "type": "test.type",
                "metric": "wo"
            }
        ]
    }
}

Example response:

HTTP/1.1 200 OK
Content-type: application/json

{
    "data": {
        "label": "template",
        "id": "12618492-27ed-4108-8398-479274adfd32",
        "elements": [
            {
                "type": "test.type",
                "metric": "hree",
                "id": "1da7a3dd-6fe9-474d-bb22-b89d0155ea44"
            },
            {
                "type": "test.type",
                "metric": "wo",
                "id": "8dafac91-515a-4db5-8365-143d46e71438"
            }
        ]
    }
}
Parameters:
  • id (string) – template’s unique id
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Request JSON Array of Objects:
 
  • label (string) – label of the template
  • elements (array) – array of elements composing the template
Response JSON Array of Objects:
 
  • id (string) – id of the template
  • label (string) – label of the template
  • elements (array) – array of elements composing the template
Status Codes:

DELETE methods

DELETE /api/v1/templates/:id

Delete an existing template, responds with the confirmation or error. Can only delete one resource at a time, to remove a collection of machines call the DELETE method for each element.

Example request:

DELETE /api/v1/templates/77e79dce-5a36-481f-a19a-cf2f80ed4673 HTTP/1.1
Host: https://ccharts.hir.facts4.work/

Example response:

HTTP/1.1 200 OK
Parameters:
  • id (string) – template’s unique id
Query Parameters:
 
  • access_token (string) – valid access token for OAuth2 authentication
Status Codes: