From 0f9a652e08d429d8edcf12638d642003baa5d8ec Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Mon, 20 Jul 2020 11:49:21 +0100 Subject: REST API --- test/rest-api.org | 51 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/test/rest-api.org b/test/rest-api.org index c797cf3..4a7b09b 100644 --- a/test/rest-api.org +++ b/test/rest-api.org @@ -1,40 +1,38 @@ * PubSeq REST API Here we document the public REST API that comes with PubSeq. The tests -are written and run in the amazing emacs [[https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html][org-babel]]. Execute a code -block with C-c C-c. You may need to set +run in the amazing emacs [[https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html][org-babel]]. See the bottom of this document +for running the tests inside emacs. -#+begin_src elisp -(org-babel-do-load-languages - 'org-babel-load-languages - '((python . t))) -(setq org-babel-python-command "python3") -#+end_src +** Introduction -#+RESULTS: -: python3 +We built a REST API for COVID-19 PubSeq. The API source code can be +found in [[https://github.com/arvados/bh20-seq-resource/tree/master/bh20simplewebuploader/api.py][api.py]]. To see if the service is up try -To skip confirmations you may also want to set +: curl http://covid19.genenetwork.org/api/version -: (setq org-confirm-babel-evaluate nil) +#+begin_src js +{ + "service": "PubSeq", + "version": 0.1 +} +#+end_src -** Check the version +The Python3 version is #+begin_src python :session import requests -response = requests.get("http://localhost:5000/api/version") +response = requests.get("http://covid19.genenetwork.org/api/version") response_body = response.json() assert response_body["service"] == "PubSeq", "PubSeq API not found" -response_body #+end_src #+RESULTS: -| service | : | PubSeq | version | : | 0.1 | ** Fetch EBI XML #+begin_src python :session -requests.get("http://localhost:5000/api/ebi/sample-MT32690.1.xml").text +requests.get("http://covid19.genenetwork.org/api/ebi/sample-MT32690.1.xml").text #+end_src #+RESULTS: @@ -91,3 +89,22 @@ requests.get("http://localhost:5000/api/ebi/sample-MT32690.1.xml").text #+end_example + +* Configure emacs to run tests + +Execute a code +block with C-c C-c. You may need to set + +#+begin_src elisp +(org-babel-do-load-languages + 'org-babel-load-languages + '((python . t))) +(setq org-babel-python-command "python3") +#+end_src + +#+RESULTS: +: python3 + +To skip confirmations you may also want to set + +: (setq org-confirm-babel-evaluate nil) -- cgit v1.2.3