2 Levels Applications Data¶
In some cases an application running on top of the APIO could need to store some data (application related, not user related) in APIO DB as they do not have their own DB.
The 2 LevelsApplications Data APIs are offering this possibility by exposing a mechanism of key/subKey/value elements for an application.
It must be very clear that an application must use this mechanism wisely in terms of access, for example by caching the results, in order to not overload the APIO and therefore impacts its main role.
It must also be noted that the ‘application’ and the ‘key’ themself are virtual objects: it virtual existence relies on the fact that subKeys exist or not for it.
This mechanism is an extension of the existing Application data but with one more level in the structure.
Listing existing applications¶
-
GET
/api/v1/configs/applications2levels/
¶ Return the list of all the currently existing applications
Example request:
GET /api/v1/configs/applications2levels/ HTTP/1.1 Host: example.com Content-Type: "application/json" { }
Example response:
HTTP/1.1 200 OK Content-Type: "application/json" { "applications": [ {"applicationId": "netaxis"} ] }
- Response JSON Object:
applications (array) – The list of applications. Each of them containing an attribute ‘applicationId’.
- Status Codes:
200 OK – no error
Listing existing keys of an application¶
-
GET
/api/v1/configs/applications2levels/
(string: applicationId)/
¶ Return the list of all the keys of an application
Example request:
GET /api/v1/configs/applications2levels/netaxis/ HTTP/1.1 Host: example.com Content-Type: "application/json" { }
Example response:
HTTP/1.1 200 OK Content-Type: "application/json" { "applicationKeys": [ {"applicationId": "netaxis", "key": "need"}, {"applicationId": "netaxis", "key": "own"} ] }
- Response JSON Object:
applicationKeys (array) – The list of application objects. Each of them containing an attribute ‘applicationId’ and an attribute ‘key’.
- Status Codes:
200 OK – No error
404 Not Found – Application not found
Listing existing subKeys of a key of an application¶
-
GET
/api/v1/configs/applications2levels/
(string: applicationId)/
(string: key)/
¶ Return the list of all the subKeys of an application+key
Example request:
GET /api/v1/configs/applications2levels/netaxis/need/ HTTP/1.1 Host: example.com Content-Type: "application/json" { }
Example response:
HTTP/1.1 200 OK Content-Type: "application/json" { "applicationKeys": [ {"applicationId": "netaxis", "key": "need", "subKey": "coffee"}, {"applicationId": "netaxis", "key": "need", "subKey": "tacos"} ] }
- Response JSON Object:
applicationKeys (array) – The list of application objects. Each of them containing an attribute ‘applicationId’, an attribute ‘key’ and an attribute ‘subKey’.
- Status Codes:
200 OK – No error
404 Not Found – Application not found
Create a new subKey for an application+key¶
-
POST
/api/v1/configs/applications2levels/
(string: applicationId)/
(string: key)/
¶ Create a new subKey for an application+key.
Example request:
POST /api/v1/configs/applications2levels/netaxis/need/ HTTP/1.1 Host: example.com Content-Type: "application/json" { "subKey": "coffee", "data": "Lavazza is great" }
- Request JSON Object:
subKey (string) – The new subKey to be created.
data (string) – The data to be saved. It can be a normal string, a base64 encoded object, a json string, or any other type as long as it encdoed as a string.
Example response:
HTTP/1.1 200 OK Content-Type: "application/json" { "applicationdId": "netaxis", "key": "need", "subKey": "coffee", "data": "Lavazza is great" }
- Response JSON Object:
applicationId (string) – the id of the application
key (string) – the key
subKey (string) – the subKey newly created
data (string) – the data saved.
- Status Codes:
200 OK – No error
Unable to create the subKey/value, with possible sub-error codes:
11: ALREADY_EXISTS
2: INVALID_PARAMETERS
Modify an existing subKey of an application+key¶
-
PUT
/api/v1/configs/applications2levels/
(string: applicationId)/
(string: key)/
(string: subKey)/
¶ Modify an existing subKey of an application+key.
Example request:
PUT /api/v1/configs/applications2levels/netaxis/need/coffee/ HTTP/1.1 Host: example.com Content-Type: "application/json" { "data": "Starbucks is cool" }
- Request JSON Object:
data (string) – The data to be saved. It can be a normal string, a base64 encoded object, a json string, or any other type as long as it encoded as a string.
auto_create (boolean) – (Optional) if set to true (default is false) if the application key subKey does not exist it will be created.
Example response:
HTTP/1.1 200 OK Content-Type: "application/json" { "applicationdId": "netaxis", "key": "need", "subKey": "coffee", "data": "Starbucks is cool" }
- Response JSON Object:
applicationId (string) – The id of the application.
key (string) – The key updated.
data (string) – The data saved.
- Status Codes:
200 OK – No error
404 Not Found – Application or key not found
Unable to create the key/value, with possible sub-error codes:
2: INVALID_PARAMETERS
Read an existing subKey of an application+key¶
-
GET
/api/v1/configs/applications2levels/
(string: applicationId)/
(string: key)/
(string: subKey)/
¶ Read an existing subKey for an application+key.
Example request:
GET /api/v1/configs/applications2levels/netaxis/need/coffee/ HTTP/1.1 Host: example.com Content-Type: "application/json" { }
Example response:
HTTP/1.1 200 OK Content-Type: "application/json" { "applicationdId": "netaxis", "key": "need", "subKey": "coffee", "data": "Starbucks is cool" }
- Response JSON Object:
applicationId (string) – The id of the application.
key (string) – The key.
data (string) – The data.
- Status Codes:
200 OK – No error
404 Not Found – Application or key not found
Delete an existing subKey of an application+key¶
-
DELETE
/api/v1/configs/applications2levels/
(string: applicationId)/
(string: key)/
(string: subKey)/
¶ Delete an existing subKey for an application+key.
Example request:
DELETE /api/v1/configs/applications2levels/netaxis/need/coffee/ HTTP/1.1 Host: example.com Content-Type: "application/json" { }
Example response:
HTTP/1.1 200 OK Content-Type: "application/json" { }
- Status Codes:
200 OK – No error. If the key does not exists, a 200 is also returned.