Algorithm Catalog¶
Contains the available algorithms.
Schema¶
Field |
Type |
Required |
Readonly |
Auto Managed |
Example |
---|---|---|---|---|---|
|
String |
True |
True |
False |
ddos-predictor |
|
List(Parameter) |
False |
False |
False |
|
|
String |
False |
False |
False |
DDoS predictor. |
Parameter Schema¶
Field |
Type |
Required |
Readonly |
Auto Managed |
Example |
---|---|---|---|---|---|
|
String |
True |
True |
False |
frequency |
|
Enum(String) 1 |
True |
False |
False |
integer |
|
Boolean |
False |
False |
False |
False |
|
Enum(String) |
False |
False |
False |
mysql |
|
String |
False |
False |
False |
Frequency to scan the network. |
|
String |
False |
False |
False |
10s |
- 1
Possible values are “integer”, “number”, “time-duration”, “string”, “choice”, “boolean”, and “binary”.
Warning
It is not possible to update readonly fields.
it is not possible to set the Auto managed fields.
Note
id
is required but it is auto-generated if not provided. It is recommended to provide a friendly for simplify the retrieve of connected date in other indices.
Create¶
To create a new algorithm in the catalog use the following REST call:
-
POST
/catalog/algorithm/
(string: id)¶ with the request body in JSON format:
POST /catalog/algorithm HTTP/1.1 Host: cb-manager.example.com Content-Type: application/json { "id": "<algorithm-id>", "parameters": [ { "id": "<parameter-id>", "type": "<parameter-type>", "description": "<parameter-human-readable-description>", "example": "<parameter-example>", } ] }
- Parameters
id – optional algorithm id.
- Request Headers
Authorization – HTTP Basic Authentication with username and password.
Content-Type – application/json
- Response Headers
Content-Type – application/json
- Status Codes
201 Created – Algorithms correctly created.
204 No Content – No content to create algorithms for the catalog based on the request.
400 Bad Request – Request not valid.
401 Unauthorized – Authentication failed.
406 Not Acceptable – Request validation failed.
415 Unsupported Media Type – Media type not supported.
422 Unprocessable Entity – Not possible to create ore or more algorithms for the catalog based on the request.
500 Internal Server Error – Server not available to satisfy the request.
Replace the data with the correct values, for example <algorithm-id> with
ddos-predictor
.If the creation is correctly executed the response is:
HTTP/1.1 201 Created Content-Type: application/json [ { "status": "Created", "code": 201, "error": false, "message": "Algorithm catalog with id=<algorithm-id> correctly created" } ]
Otherwise, if, for example, an algorithm with the given
id
is already found in the catalog, this is the response:HTTP/1.1 406 Not Acceptable Content-Type: application/json [ { "status": "Not Acceptable", "code": 406, "error": true, "message": "Id already found" } ]
If some required data is missing (for example
type
of oneparameter
), the response could be:HTTP/1.1 406 Not Acceptable Content-Type: application/json [ { "status": "Not Acceptable", "code": 406, "error": true, "message": { "parameter.type": "required" } } ]
Read¶
To get the list of the algorithms available in the catalog:
-
GET
/catalog/algorithm/(string: id)
¶ The response includes all the algorithms.
It is possible to filter the results using the following request body:
GET /catalog/algorithm HTTP/1.1 Host: cb-manager.example.com Content-Type: application/json { "select": [ "parameters" ], "where": { "equals": { "target:" "id", "expr": "<algorithm-id>" } } }
- Parameters
id – optional algorithm id from the catalog.
- Request Headers
Authorization – HTTP Basic Authentication with username and password.
Content-Type – application/json
- Response Headers
Content-Type – application/json
- Status Codes
200 OK – List of algorithms from the catalog filtered by the query in the request body.
400 Bad Request – Request not valid.
401 Unauthorized – Authentication failed.
404 Not Found – Data based on the request query not found.
406 Not Acceptable – Request validation failed.
415 Unsupported Media Type – Media type not supported.
422 Unprocessable Entity – Not possible to get algorithms from the catalog with the request query.
500 Internal Server Error – Server not available to satisfy the request.
In this way, it will be returned only the
parameters
of the algorithm in the catalog withid
= “<algorithm-id>”.
Update¶
To update an algorithm in the catalog, use:
-
PUT
/catalog/algorithm/
(string: id)¶ PUT /catalog/algorithm HTTP/1.1 Host: cb-manager.example.com Content-Type: application/json { "id": "<algorithm-id>", "parameters": [ { "id": "<parameter-id>", "type": "<new-parameter-type>" } ] }
- Parameters
id – optional algorithm id.
- Request Headers
Authorization – HTTP Basic Authentication with username and password.
Content-Type – application/json
- Response Headers
Content-Type – application/json
- Status Codes
200 OK – All algorithms in the catalog correctly updated.
204 No Content – No content to update algorithms in the catalog based on the request.
304 Not Modified – Update for one or more algorithms in the catalog not necessary.
400 Bad Request – Request not valid.
401 Unauthorized – Authentication failed.
406 Not Acceptable – Request validation failed.
415 Unsupported Media Type – Media type not supported.
422 Unprocessable Entity – Not possible to update one or more algorithms in the catalog based on the request.
500 Internal Server Error – Server not available to satisfy the request.
This example
updates the new
type
of theparameter
withid
= “<parameter-id>”;adds a new action
of the algorithm with
id
= “<algorithm-id>”.A possible response is:
HTTP/1.1 200 OK Content-Type: application/json [ { "status": "OK", "code": 200, "error": false, "message": "Algorithm catalog with id=<algorithm-id> correctly updated" } ]
Instead, if the are not changes the response is:
HTTP/1.1 304 Not Modified Content-Type: application/json [ { "status": "Not Modified", "code": 304, "error": false, "message": "Update for algorithm catalog with id=<algorithm-id> not necessary" } ]
Delete¶
To delete algorithms from the catalog, use:
-
DELETE
/catalog/algorithm/
(string: id)¶ DELETE /catalog/algorithm HTTP/1.1 Host: cb-manager.example.com Content-Type: application/json { "where": { "equals": { "target:" "id", "expr": "<algorithm-id>" } } }
- Parameters
id – optional algorithm id from the catalog.
- Request Headers
Authorization – HTTP Basic Authentication with username and password.
Content-Type – application/json
- Response Headers
Content-Type – application/json
- Status Codes
205 Reset Content – All algorithms correctly deleted from the catalog.
400 Bad Request – Request not valid.
401 Unauthorized – Authentication failed.
404 Not Found – Algorithms based on the request query not found in the catalog.
406 Not Acceptable – Request validation failed.
415 Unsupported Media Type – Media type not supported.
422 Unprocessable Entity – Not possible to delete one or more algorithms from the catalog based on the request query.
500 Internal Server Error – Server not available to satisfy the request.
This request removes from the catalog the algorithm with
id
= “<algorithm-id>”.This is a possible response:
HTTP/1.1 205 Reset Content Content-Type: application/json [ { "status": "Reset Content", "code": 200, "error": false, "message": "Algorithm catalog the id=<algorithm-id> correctly deleted" } ]
Caution
Without request body, it removes all the algorithms from the catalog.