The Metadata-API (Github) is built in Python, utilizing the Flask framework with Flask-SQLalchemy library. The purpose of the API is to make working with metadata a more smooth operation for all groups involved in the Knox Project.
The API exposes 4 endpoints. The base of the endpoints is: http://knox-????/metadata/.
In common for all the endpoints is that the return value, no matter if succesfull or an error occured, is:
{ success: boolean, message: any }
Meaning that the client can always check for success and read the message depending on usage.
Endpoints:
GET: /
Description: The GET endpoint at root is a health check to verify the api is running. It will only return statuscode 200 and a valid message if the API is running.
GET: /metadata
Description: The GET endpoint /metadata takes in a triple and will return the metadata that is connected to that triple. Depending whether the metadata could be found, a valid or invalid message will be returned. The valid data returned is an array of objects containing metadata, all connected to the specified triple.
Body: { triple: Array<string> }
Responses:
If succesful: { success: true, message: Array<Object> }
If error: { success: false, message: error }
POST: /metadata
Description: The POST endpoint /metadata binds together metadata with a UUID. The user will only be required to input the metadata, and the API will respond with the UUID, that was bound to that metadata.
Body: { metadata: Object }
Responses:
If succesful: { success: true, message: uuid }
If error: { success: false, message: error }
POST: /triple
Description: The POST endpoint /triple binds together a triple with a number of UUID. The user will only be required to input the triple and the UUID, and the API will respond with the triple as a key (a string with all three entries concatenated together).
Body: { triple: Array<string>, uuid: string }
Responses:
If succesful: { success: true, message: triple as primary key }
If error: { success: false, message: error }
The API is hosted in the access api and can be found at http://????.com and port: xxxx. To deploy the API please ensure that you are executing commands as a user with sudo priviliges.
For both builds
Validate the environment variables in the docker-compose files are aligned with the setup intended to run. Please keep in mind that changing the "PYTHON_ENV" file can cause the API to run in unintended ways. To validate:
For production builds
To run the API in production mode enter the root of the project and run:
docker-compose -f prod-docker-compose.yml up
This will setup the environment with database and API.
For development builds
To run the API in development mode enter the root of the project and run:
docker-compose -f dev-docker-compose.yml up
This will setup the environment with database and API.
The module consists of a single app.py in the src of the folder. This file contains all the logic for the API. To handle environment variables and the behaviour of the app please see the section "Deployment". The file includes the logic for 4 endpoints to handle metadata.
Find the repository and source code here
See the TODO list of this api here