Unit Type
A Unit Type expresses and measures physical quantities used in various infrastructures, service providers, and projects. It is used to describe a class or group of Units based on a single characteristic. Once a Unit 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 Unit Type. The aforementioned operations are described below.
The Unit Type can be expressed by the following structure:
Field | Description |
---|---|
id | A unique identifier |
unit_type | The Unit Type |
description | Short Description of a Unit Type |
[POST] - Create a Unit Type
The client can submit a new Unit Type by executing the following POST request:
POST /accounting-system/unit-types
Content-type: application/json
Authorization: Bearer {token}
{
"unit_type" : "number_of_users",
"description" : "Number of users"
}
Upon inserting the record into the database, the API returns the stored Unit Type :
Success Response 201 CREATED
{
"id": "63cfa31aca73200e5a7707b6",
"unit_type": "number_of_users",
"description": "Number of users",
"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 Unit Type
The client should be able to fetch an existing Unit Type. By passing the Unit Type ID, the client can request the corresponding Unit Type by executing the following request:
GET /accounting-system/unit-types/{unit_type_id}
Authorization: Bearer {token}
The response returned to the client is the following:
Success Response 200 OK
{
"id": "63cfa31aca73200e5a7707b6",
"unit_type": "number_of_users",
"description": "Number of users",
"creator_id": "115143399384cc3177df5377691ccdbb284cb245fad1c@aai.eosc-portal.eu"
}
[PATCH] - Update a Unit Type
You can update a part or all attributes of an existing Unit Type using the following PATCH request. The empty or null values are ignored.
You cannot update a Unit Type registered by Accounting Service or a Unit Type used in an existing Metric Definition.
PATCH /accounting-system/unit-types/{unit_type_id}
Content-type: application/json
Authorization: Bearer {token}
{
"unit_type" : "unit_type_to_be_updated",
"description" : "description_to_be_updated"
}
The response will be the updated entity :
Success Response 200 OK
{
"id": "63cfa31aca73200e5a7707b6",
"unit_type": "updated_unit_type",
"description": "updated_description",
"creator_id": "115143399384cc3177df5377691ccdbb284cb245fad1c@aai.eosc-portal.eu"
}
To update the properties of an actual Unit Type, the body of the request must contain an updated representation of it. For example, to edit the unit type, send the following request:
PATCH /accounting-system/unit-types/{unit_type_id}
Content-type: application/json
Authorization: Bearer {token}
{
"unit_type": "unit_type_to_be_updated"
}
[DELETE] - Delete a Unit Type
A Unit Type can be deleted by executing the following request:
DELETE /accounting-system/unit-types/{unit_type_id}
Authorization: Bearer {token}
If the operation is successful, you get the following response:
Success Response 200 OK
{
"code": 200,
"message": "The Unit Type has been deleted successfully."
}
You cannot delete a Unit Type registered by Accounting Service or a Unit Type used in an existing Metric Definition.
[GET] - Fetch all the Unit Types
You can also fetch all the Unit Types that exist to the accounting system.
GET /accounting-system/unit-types
Authorization: Bearer {token}
If the operation is successful, you get the following response:
{
"size_of_page": 10,
"number_of_page": 1,
"total_elements": 11,
"total_pages": 2,
"content": [
{
"id": "63cfd515f5c3c21ba78ca3a1",
"unit_type": "TB",
"description": "terabyte",
"creator_id": ""
},
{
"id": "63cfd515f5c3c21ba78ca3a2",
"unit_type": "TB/year",
"description": "terabyte per year",
"creator_id": ""
},
{
"id": "63cfd515f5c3c21ba78ca3a3",
"unit_type": "Endpoints Monitored/hour",
"description": "Endpoints Monitored per hour",
"creator_id": ""
},
{
"id": "63cfd515f5c3c21ba78ca3a4",
"unit_type": "Messages/hour",
"description": "Messages per hour",
"creator_id": ""
},
{
"id": "63cfd515f5c3c21ba78ca3a5",
"unit_type": "Service Updates",
"description": "Service Updates",
"creator_id": ""
},
{
"id": "63cfd515f5c3c21ba78ca3a6",
"unit_type": "#",
"description": "number of",
"creator_id": ""
},
{
"id": "63cfd515f5c3c21ba78ca3a7",
"unit_type": "count",
"description": "count of",
"creator_id": ""
},
{
"id": "63cfd515f5c3c21ba78ca3a8",
"unit_type": "API reqs",
"description": "API requests",
"creator_id": ""
},
{
"id": "63cfd515f5c3c21ba78ca3a9",
"unit_type": "PID prefixes",
"description": "PID prefixes",
"creator_id": ""
},
{
"id": "63cfd515f5c3c21ba78ca3aa",
"unit_type": "CPU Time",
"description": "the exact amount of time that the CPU has spent processing data",
"creator_id": ""
}
],
"links": [
{
"href": "http://localhost:8080/accounting-system/unit-types?page=1&size=10",
"rel": "first"
},
{
"href": "http://localhost:8080/accounting-system/unit-types?page=2&size=10",
"rel": "last"
},
{
"href": "http://localhost:8080/accounting-system/unit-types?page=1&size=10",
"rel": "self"
},
{
"href": "http://localhost:8080/accounting-system/unit-types?page=2&size=10",
"rel": "next"
}
]
}
The Unit Types, which have empty creator_id, have been generated by Accounting Service. The Unit Types created by a client contains their ID.
Errors
Please refer to section Errors to see all possible Errors.