Skip to content

Repository for query config files

Julio Zevallos edited this page Sep 23, 2019 · 7 revisions

This page will explain the file structure of the query configuration files, as well as show templates for the files.

Based on the repoRoot configuration placed in the application.yml file, this root directory should contain json files which are tied to a shared safe on your t-vault instance by name, and is also the L1 identifier for the path of the request. For example, if I am using a shared safe called "teamA" on t-vault, I should have a file on this repository called "teamA.json".

This json file contains two properties, "statements", and "default_env". Below is an example of what the file would look like.

{
  "statements": {
    "getcustomersbyzipcode": "select * FROM addresses where zipcode = {zipcode}",
    "getusers": "select * FROM users where id < {id}"
  },
  "default_env": "prod"
}

There are 2 queries defined in this file, as well as a default environment to be "prod". If making use of the qAPI without passing in an env as part of the path, the "default_env" value will be used from the file, and thus that folder will be selected from the safe specified from your t-vault safe.

Additionally, both queries in this file have a dynamic parameter, which are specified inside the {}. These parameters will be set as json in the body of the request made. So for example if calling the query "getusers", the body of the request would look something like this:

{
  "id": 6
}

Note: Multiple parameters can be passed in a query as well as the body.

Then, when using the above file with the above query, the request path would be: localhost:8081/api/datareader/teamA/getusers/v1/dev assuming you are running it locally.

This would call the example query, but since we specified the environment to be "dev", the default value of "prod" from the config file is not used. This means, that on the t-vault safe called "teamA", there should be a folder called "prod", where the database configurations are made.

qAPI service will automatically re-scan the repository every 5 minutes, or can be updated manually as well by making a call to the path /api/datareader/scan .

For more details on where to place the database configurations on T-Vault, please visit the subpage Centralizing DB Credentials on T-vault