Skip to content
/ vault Public

Microservice for storing queries, user preferences and stuff

License

Notifications You must be signed in to change notification settings

adsabs/vault

Repository files navigation

vault

Travis Status Coverage Status

Microservice for storing queries, user preferences and stuff

Setup:

(will wary based on the API deployment strategy) In minimal, you need to have a database and OAUTH_CLIENT_TOKEN

  • create database create database vault; alter database vault owner to vault;

  • create modified vault_service/local_config.py, update (at least) VAULT_OAUTH_CLIENT_TOKEN = '.......' SQLALCHEMY_DATABASE_URI = "....."

  • run alembic upgrade head

    • note: you need alembic and all dependencies in your python (virtualenv python; pip install -r requirements; source python/bin/activate)

Usage:

(You can run the service locally: python cors.py)

/query

  • POST (To save a query):
curl -H "Content-Type: application/json" -H "Authorization: Bearer <TOKEN>" "http://localhost:5000/query" -X POST -d $'{"q": "title:foo"}' 

{"qid": "772319e35ff5af56dc79dc43e8ff2d9d", "numFound": 9508}

It will contact SOLR microservice to verify the query (make sure url set in the local_config.py is correct).

The response contains 'qid' - the key to retrieve and/or execute the query again.

  • GET (To get the query info)
curl -H "Content-Type: application/json" -H "Authorization: Bearer <TOKEN>" "http://localhost:5000/query/772319e35ff5af56dc79dc43e8ff2d9d" -X GET
{
	"qid": "772319e35ff5af56dc79dc43e8ff2d9d",
	"query": "{\"query\": \"q=foo%3Abar\", \"bigquery\": \"\"}",
	"numfound": 20
}
  • POST (To save a bigquery):
curl 'http://localhost:5000/query' -H 'Authorization: Bearer:TOKEN' -X POST -d $'{"q":"*:*","fq": "{!bitset}", "bigquery":"bibcode\\n15ASPC..495..40015IAUGA..2257982A\\n2015IAUGA..2257768A\\n2015IAUGA..2257639R\\n2015ASPC..492..208G\\n2015ASPC..492..204F\\n2015ASPC..492..189A\\n2015ASPC..492..150T\\n2015ASPC..492...85E\\n2015ASPC..492...80H\\n2015AAS...22533656H\\n2015AAS...22533655A"}' -H 'Content-Type: application/json'
{"qid": "36baa12ddb7cc3975d8d0fa4c2f216c1", "numFound": 10}

NOTICE the Content-Type: application/json and the double \\n escapes

/execute_query

  • GET - To execute the stored query (and get the SOLR response back)
curl -H "Content-Type: application/json" -H "Authorization: Bearer <TOKEN>" "http://localhost:5000/execute_query/772319e35ff5af56dc79dc43e8ff2d9d" -X GET
  • To execute the query and override some of its parameters (you can't override 'q' and 'bigquery' values):
curl -H "Content-Type: application/json" -H "Authorization: Bearer <TOKEN>" "http://localhost:5000/execute_query/c8ed1163e7643cea5e81aaefb4bb2d91?fl=title,id" -X GET

/user-data

  • To save user-data (i.e. preferences)
curl -H "Content-Type: application/json" -H "Authorization: Bearer <TOKEN>" -H "X-Adsws-Uid: 1" "http://localhost:5000/user-data" -X POST -d $'{"foo": "bar"}'

note: The X-Adsws-Uid header must be present (normally, it is set by the API gateway)

  • To get the user-data:
curl -H "Content-Type: application/json" -H "Authorization: Bearer <TOKEN>" -H "X-Adsws-Uid: 1" "http://localhost:5000/user-data" -X GET

/configuration

  • Retrieve Bumblebee configuration (values that can be used to customize user experience)
curl -H "Content-Type: application/json" -H "Authorization: Bearer <TOKEN>" -H "X-Adsws-Uid: 1" "http://localhost:5000/configuration" -X GET

{"foo": "bar"}

curl -H "Content-Type: application/json" -H "Authorization: Bearer <TOKEN>" -H "X-Adsws-Uid: 1" "http://localhost:5000/configuration/foo" -X GET

"bar"