Skip to content
forked from adsabs/vault

Microservice for storing queries, user preferences and stuff

License

Notifications You must be signed in to change notification settings

romanchyla/myads

 
 

Repository files navigation

myads

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 myads; alter database myads owner to myads;

  • create modified myads_service/local_config.py, update (at least) MYADS_OAUTH_CLIENT_TOKEN = '.......' SQLALCHEMY_BINDS = { 'myads': '.....' }

  • 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

  • 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.

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
}
  • To save a bigquery:
curl -H "Content-Type: application/json" -H "Authorization: Bearer <TOKEN>" "http://localhos/query" -X POST -d $'{"q": "foo:bar", "bigquery": "bibcode\nfoo\nbar", "fq": "{!bitset}"}' 
{"qid": "eb677e40aa77f7b1c3482aa954f63a60"}

/execute_query

  • 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"

About

Microservice for storing queries, user preferences and stuff

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.4%
  • Mako 1.6%