Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

61 lines
1.8 KiB
Python
Raw Permalink Normal View History

2013-04-10 13:59:33 -04:00
"""
Sample script for Galaxy Search API
"""
2013-04-10 13:59:33 -04:00
import json
import sys
2024-05-22 09:16:28 +01:00
import requests
2020-10-06 18:49:19 +01:00
class RemoteGalaxy:
2013-04-10 13:59:33 -04:00
def __init__(self, url, api_key):
self.url = url
self.api_key = api_key
def get(self, path):
c_url = self.url + path
params = {}
params["key"] = self.api_key
req = requests.get(c_url, params=params)
return req.json()
def post(self, path, payload):
c_url = self.url + path
params = {}
params["key"] = self.api_key
2017-08-17 00:33:02 +01:00
req = requests.post(
c_url, data=json.dumps(payload), params=params, headers={"Content-Type": "application/json"}
)
2013-04-10 13:59:33 -04:00
return req.json()
2016-11-14 21:12:14 +00:00
2013-04-10 13:59:33 -04:00
if __name__ == "__main__":
server = sys.argv[1]
api_key = sys.argv[2]
rg = RemoteGalaxy(server, api_key)
2016-06-25 20:44:44 -04:00
print("select name, id, file_size from hda")
2017-08-17 00:33:02 +01:00
print(rg.post("/api/search", {"query": "select name, id, file_size from hda"}))
2013-04-10 13:59:33 -04:00
2016-06-25 20:44:44 -04:00
print("select name from hda")
2017-08-17 00:33:02 +01:00
print(rg.post("/api/search", {"query": "select name from hda"}))
2013-04-10 13:59:33 -04:00
2016-06-25 20:44:44 -04:00
print("select name, model_class from ldda")
2017-08-17 00:33:02 +01:00
print(rg.post("/api/search", {"query": "select name, model_class from ldda"}))
2013-04-10 13:59:33 -04:00
2016-06-25 20:44:44 -04:00
print("select * from history")
2017-08-17 00:33:02 +01:00
print(rg.post("/api/search", {"query": "select * from history"}))
2013-04-10 13:59:33 -04:00
2016-06-25 20:44:44 -04:00
print("select * from tool")
2017-08-17 00:33:02 +01:00
print(rg.post("/api/search", {"query": "select * from tool"}))
2013-04-10 13:59:33 -04:00
2016-06-25 20:44:44 -04:00
print("select * from workflow")
2017-08-17 00:33:02 +01:00
print(rg.post("/api/search", {"query": "select * from workflow"}))
2013-04-10 13:59:33 -04:00
2016-06-25 20:44:44 -04:00
print("select id, name from history where name='Unnamed history'")
print(rg.post("/api/search", {"query": "select id, name from history where name='Unnamed history'"}))
2013-04-10 13:59:33 -04:00
2016-06-25 20:44:44 -04:00
print("select * from history where name='Unnamed history'")
print(rg.post("/api/search", {"query": "select * from history where name='Unnamed history'"}))