From c86d194c8c6c0ee47d4ee075de8e7a62d87d2b06 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Mon, 11 Feb 2019 14:06:11 +0000 Subject: [PATCH] Added request examples to docs --- docs/source/api.rst | 12 +++- docs/source/apirequests.rst | 106 ++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 docs/source/apirequests.rst diff --git a/docs/source/api.rst b/docs/source/api.rst index 3ffe024d..218713b7 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -9,9 +9,17 @@ Summary :endpoints: Details ------------ +------- .. autoflask:: openflexure_microscope.api.app:app :undoc-endpoints: index :undoc-static: :endpoints: - :order: path \ No newline at end of file + :order: path + +Example Requests +---------------- + +.. toctree:: + :maxdepth: 2 + + ./apirequests.rst \ No newline at end of file diff --git a/docs/source/apirequests.rst b/docs/source/apirequests.rst new file mode 100644 index 00000000..e828614b --- /dev/null +++ b/docs/source/apirequests.rst @@ -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') \ No newline at end of file