Giter VIP home page Giter VIP logo

vault's Introduction

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"

vault's People

Contributors

ehenneken avatar jonnybazookatone avatar kelockhart avatar marblestation avatar nemanjamart avatar romanchyla avatar tjacovich avatar vsudilov avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vault's Issues

Get Library Servers from external source

The link_servers currently, stored in MYADS_BUMBLEBEE_OPTIONS in the config and pulled in at

https://github.com/adsabs/myads/blob/master/myads_service/views/bumblebee.py#L16

should be stored externally (for example in a database table). In the current setup, the myads service has to be re-deployed every time a server gets added and if it accidentally gets re-deployed with an old local_config.py, the library server disappears from the BBB menu

Increase rate limit for execute_query

When viewing search results from a bigquery, one easily hits the maximum limit apparently due to the fact that each facet query counts against execute_query. So 100 queries per day is way too small a limit, we should set this to be at least 5000.

{
 "error": "TOO MANY REQUESTS",
 "errorCode": 429,
 "destination": "vault/execute_query/0266c70541ae6b94365db350d6ef073b",
 "query": {
  "fq": [
   "{!type=aqp cache=false cost=150 v=$fq_author}",
   "{!type=aqp v=$fq_database}"
  ],
  "fq_author": [
   "(author_facet_hier:\"0/Murray, S\")"
  ],
  "q": [
   "*:*"
  ],
  "__qid": [
   "0266c70541ae6b94365db350d6ef073b"
  ],
  "fq_database": [
   "(database:physics)"
  ],
  "__database_fq_database": [
   "AND",
   "database:physics"
  ],
  "facet": [
   "true"
  ],
  "facet.field": [
   "author_facet_hier"
  ],
  "facet.mincount": [
   "1"
  ],
  "facet.limit": [
   20
  ],
  "facet.prefix": [
   "1/Accomazzi, A/"
  ],
  "fl": [
   "id"
  ],
  "facet.offset": [
   0
  ]
 }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.