2. Connect¶
A client needs three things: the server's address, an API key (or a JWT from your
identity provider, authentication), and trust in the
server's certificate. Step 1 left the key in api-key and the certificate in server.pem,
for the container and for the binary alike.
The settings, once¶
Every later step and program reads these variables:
cat > oliviadb.env <<EOF
export OLIVIADB_URL=https://localhost:8443
export OLIVIADB_KEY=\$(cat $PWD/api-key)
export OLIVIADB_NATIVE_HOST=localhost OLIVIADB_NATIVE_PORT=7655
export OLIVIADB_CA_FILE=$PWD/server.pem
# curl, Python and Node.js trust the certificate through these:
export CURL_CA_BUNDLE=$PWD/server.pem SSL_CERT_FILE=$PWD/server.pem NODE_EXTRA_CA_CERTS=$PWD/server.pem
EOF
In a new shell: . ./oliviadb.env. A certificate from a public or company CA needs none of
the CA variables.
Health, the key, a first call¶
. ./oliviadb.env
curl -fsS "$OLIVIADB_URL/healthz" # the process is up: {"status":"ok"}
curl -fsS "$OLIVIADB_URL/readyz" # it serves (on a high-availability pair: the primary)
# A wrong key is refused with 401 ...
test "$(curl -s -o /dev/null -w '%{http_code}' -H 'Authorization: Token wrong' "$OLIVIADB_URL/v1/aggregates/Customer")" = 401
# ... the right one gets through. Until a schema is deployed (step 4) there is nothing to read:
curl -sS -H "Authorization: Token $OLIVIADB_KEY" "$OLIVIADB_URL/v1/aggregates/Customer"
The last call answers 404 with a problem document, the shape of every error:
{"detail":"this server serves no native aggregates (configure a schema that declares some)",
"retryable":false,"status":404,"title":"not found","type":"https://olivia-db.com/problems/not-found"}
retryable: true (429, 503) means the request was not done and may be sent again; a 504
outcome-unknown means a write may or may not have happened: read before retrying
(errors).
The console and the tools¶
- Console: open
https://localhost:8443/consolein a browser and enter the key. It is read only: browse data by path, as of a time, and (with anadminkey) the server's statistics and storage check (the console). - The command line:
oliviadbchecks and plans schemas (step 4), generates typed clients, and works on DL/I stores (oliviadb check,backup,restore,extract,load; operations). Over the network you use the clients of step 5 orcurl(HTTP API by example). - SQL: the container image also serves a read-only SQL projection on port 5432 (SQL projection).
With your coding agent¶
With the OliviaDB skills installed (step 0), the agent does this step from one request, and runs the commands above:
Ask your agent
Using the oliviadb-develop skill, check that the OliviaDB server is up, that my API key
is accepted, and write the connection settings to oliviadb.env.
Next: databases and tenants.