ESAP-DB is an ESAP component providing managed database services.
## Installation
This project should be cloned in the directory containing the repositories https://git.astron.nl/astron-sdc/esap-api-gateway and https://git.astron.nl/astron-sdc/esap-gui. Once it is done, add this .env file in the esap-db/host-files directory:
```
DOMAIN=localhost
OIDC_RP_CLIENT_SECRET=********
DBADMIN_USER=postgres
DBADMIN_PASSWORD=postgres
DBPROJECT_USER=postgres
DBPROJECT_PASSWORD=postgres
```
To check that ESAP-DB is working locally:
```bash
$ esap-db/host-files/run-tests.sh
```
Upon success, the tests should pass.
## Using ESAP-DB
In order to use ESAP-DB locally, you can launch the required services in a ternminal:
```bash
$ esap-db/host-files/run.sh
```
In a browser, the ESAP-DB apis can be tested at the url `http://localhost:8001/docs` or `http://localhost:8001/redoc`.
The PostgreSQL administration platform `pgAdmin` can be accessed at the url `http://localhost:5050`. It can be used to view the dbadmin and dbproject1 databases.
## Storing an ESAP-API request into a table.
Let's create a project:
```bash
curl -XPOST\
'http://localhost:8001/api/v0/projects'\
-H'Content-Type: application/json'\
-d'{
"name": "my_project",
"description": "My first project 😀"
}'
```
In this project, let's create a dataset, i.e., a group of tables:
Once the project and the dataset are created, we can store the result of an ESAP-API query into a table that belongs to the dataset that we have just created.