Skip to main content

Metric Type

A Metric Type determines how the physical quantities are collected over longer time windows. Once a Metric Type is generated, it can be used as an attribute of a Metric Definition.

The client can interact through several operations with the API in order to create, update, delete or fetch a Metric Type. The aforementioned operations are described below.

The Metric Type can be expressed by the following structure:

FieldDescription
idA unique identifier
metric_typeThe Metric Type
descriptionShort Description of a Metric Type

[POST] - Create a Metric Type

The client can submit a new Metric Type by executing the following POST request:

POST /accounting-system/metric-types

Content-type: application/json
Authorization: Bearer {token}

{
"metric_type" : "aggregated",
"description" : "The sum of all values captured over the aggregation interval"
}

Upon inserting the record into the database, the API returns the stored Metric Type :

Success Response 201 CREATED

{
"id": "63cfa31aca73200e5a7707b6",
"metric_type": "aggregated",
"description": "The sum of all values captured over the aggregation interval",
"creator_id": "115143399384cc3177df5377691ccdbb284cb245fad1c@aai.eosc-portal.eu"
}

The response also contains the id generated by the database and the creator_id, which is the client's unique id.

[GET] - Fetch a Metric Type

The client should be able to fetch an existing Metric Type. By passing the Metric Type ID, the client can request the corresponding Metric Type by executing the following request:

GET /accounting-system/metric-types/{metric_type_id}

Authorization: Bearer {token}

The response returned to the client is the following:

Success Response 200 OK

{
"id": "63cfa31aca73200e5a7707b6",
"metric_type": "aggregated",
"description": "The sum of all values captured over the aggregation interval",
"creator_id": "115143399384cc3177df5377691ccdbb284cb245fad1c@aai.eosc-portal.eu"
}

[PATCH] - Update a Metric Type

You can update a part or all attributes of an existing Metric Type using the following PATCH request. The empty or null values are ignored.

You cannot update a Metric Type registered by Accounting Service or a Metric Type used in an existing Metric Definition.

PATCH /accounting-system/metric-types/{metric_type_id}

Content-type: application/json
Authorization: Bearer {token}


{
"metric_type" : "metric_type_to_be_updated",
"description" : "description_to_be_updated"
}

The response will be the updated entity :

Success Response 200 OK

{
"id": "63cfa31aca73200e5a7707b6",
"metric_type": "updated_metric_type",
"description": "updated_description",
"creator_id": "115143399384cc3177df5377691ccdbb284cb245fad1c@aai.eosc-portal.eu"
}

To update the properties of an actual Metric Type, the body of the request must contain an updated representation of it. For example, to edit the metric type, send the following request:

PATCH /accounting-system/metric-types/{metric_type_id}

Content-type: application/json
Authorization: Bearer {token}

{
"metric_type": "metric_type_to_be_updated"
}

[DELETE] - Delete a Metric Type

A Metric Type can be deleted by executing the following request:

DELETE /accounting-system/metric-types/{metric_type_id}

Authorization: Bearer {token}

If the operation is successful, you get the following response:

Success Response 200 OK

{
"code": 200,
"message": "The Metric Type has been deleted successfully."
}

You cannot delete a Metric Type registered by Accounting Service or a Metric Type used in an existing Metric Definition.

[GET] - Fetch all the Metric Types

You can also fetch all the Metric Types that exist to the accounting system.

GET /accounting-system/metric-types

Authorization: Bearer {token}

If the operation is successful, you get the following response:

{
"size_of_page": 2,
"number_of_page": 1,
"total_elements": 5,
"total_pages": 3,
"content": [
{
"id": "63d23e504fed2081bbe3955e",
"metric_type": "aggregated",
"description": "The sum of all values captured over the aggregation interval",
"creator_id": ""
},
{
"id": "63d23e504fed2081bbe3955f",
"metric_type": "count",
"description": "It represents the total number of event occurrences in one time interval",
"creator_id": ""
}
],
"links": [
{
"href": "http://localhost:8080/accounting-system/metric-types?page=1&size=2",
"rel": "first"
},
{
"href": "http://localhost:8080/accounting-system/metric-types?page=3&size=2",
"rel": "last"
},
{
"href": "http://localhost:8080/accounting-system/metric-types?page=1&size=2",
"rel": "self"
},
{
"href": "http://localhost:8080/accounting-system/metric-types?page=2&size=2",
"rel": "next"
}
]
}

The Metric Types, which have empty creator_id, have been generated by Accounting Service. The Metric Types created by a client contains their id.

Errors

Please refer to section Errors to see all possible Errors.