Added request examples to docs

This commit is contained in:
Joel Collins 2019-02-11 14:06:11 +00:00
parent 1bbe234749
commit c86d194c8c
2 changed files with 116 additions and 2 deletions

View file

@ -9,9 +9,17 @@ Summary
:endpoints:
Details
-----------
-------
.. autoflask:: openflexure_microscope.api.app:app
:undoc-endpoints: index
:undoc-static:
:endpoints:
:order: path
:order: path
Example Requests
----------------
.. toctree::
:maxdepth: 2
./apirequests.rst

106
docs/source/apirequests.rst Normal file
View file

@ -0,0 +1,106 @@
Introduction
------------
In these examples, our microscope is located at the IP ``192.168.1.126``, running on port 5000.
New Image Capture
-----------------
Temprary capture, using video port.
CURL
++++
.. code-block:: none
curl -X POST -H "Content-Type: application/json" -d \\
'{"temporary": true, "use_video_port": true}' http://192.168.1.126:5000/api/v1/camera/capture
HTTPie
++++++
.. code-block:: none
http POST http://192.168.1.126:5000/api/v1/camera/capture temporary:=true use_video_port:=true
Python Requests
+++++++++++++++
.. code-block:: python
json_payload = {
"keep_on_disk": keep_on_disk,
"use_video_port": use_video_port
}
requests.post('http://192.168.1.126:5000/api/v1/camera/capture', json=json_payload)
Update Config
-------------
Example, changing picamera shutter speed to 2000, and the JPEG quality to 90.
CURL
++++
.. code-block:: none
curl -X POST -H "Content-Type: application/json" -d \\
'{"picamera_settings": {"shutter_speed": 2000}, "jpeg_quality": 90}' http://192.168.1.126:5000/api/v1/config
HTTPie
++++++
.. code-block:: none
http POST http://192.168.1.126:5000/api/v1/config jpeg_quality:=90 picamera_settings:='{"shutter_speed": 2000}'
Python Requests
+++++++++++++++
.. code-block:: python
json_payload = {
"jpeg_quality": 90,
"picamera_settings": {"shutter_speed": 2000}
}
requests.post('http://192.168.1.126:5000/api/v1/config', json=json_payload)
Read Config
-----------
CURL
++++
.. code-block:: none
curl http://192.168.1.126:5000/api/v1/config
HTTPie
++++++
.. code-block:: none
http GET http://192.168.1.126:5000/api/v1/config
Python Requests
+++++++++++++++
.. code-block:: python
requests.get('http://192.168.1.126:5000/api/v1/config')
Recalibrate Picamera
--------------------
Starts the automatic recalibration plugin
CURL
++++
.. code-block:: none
curl -X POST -H "Content-Type: application/json" \\
http://192.168.1.126:5000/api/v1/plugin/default/camera_calibration/recalibrate
HTTPie
++++++
.. code-block:: none
http POST http://192.168.1.126:5000/api/v1/plugin/default/camera_calibration/recalibrate
Python Requests
+++++++++++++++
.. code-block:: python
requests.post('http://192.168.1.126:5000/api/v1/plugin/default/camera_calibration/recalibrate')