From 207b2bad3b55de1022ac8429bccdf2d6816d75c3 Mon Sep 17 00:00:00 2001 From: aviau Date: Tue, 9 Jun 2015 13:39:03 -0400 Subject: [PATCH] Docs: New tutorial - Developing the API Change-Id: Id53bf61191ed600ac7dfbbd01e1dc0c010c468bc --- doc/source/tutorials/developing_the_api.rst | 41 +++++++++++++++++++++ doc/source/tutorials/getting_started.rst | 2 + doc/source/tutorials/index.rst | 1 + 3 files changed, 44 insertions(+) create mode 100644 doc/source/tutorials/developing_the_api.rst diff --git a/doc/source/tutorials/developing_the_api.rst b/doc/source/tutorials/developing_the_api.rst new file mode 100644 index 0000000..a637b98 --- /dev/null +++ b/doc/source/tutorials/developing_the_api.rst @@ -0,0 +1,41 @@ +.. role:: bash(code) + :language: bash + +Developping the API +------------------- + +Launching the stack +~~~~~~~~~~~~~~~~~~~ + +If you have completed the :ref:`tutorial_getting_started` tutorial, you should know how to launch the stack: :: + + sudo docker-compose up + +Editing the code +~~~~~~~~~~~~~~~~ + +The Surveil container mounts your local project folder and pecan reloads every time the project files change thus providing a proper development environment. + +For example, edit the ``surveil/api/controllers/v2/hello.py`` file and change ``Hello World!`` by ``Hello Devs!``. + +After you save the file, the following logs will appear in Surveil's output: :: + + surveil_1 | Some source files have been modified + surveil_1 | Restarting server... + +You should be able to test your modification by accessing ``http://localhost:8080/v2/hello`` with your browser. + +Disabling permissions +~~~~~~~~~~~~~~~~~~~~~ + +Depending on what you are working on, it might be practical to disable permissions. This can be done by editing the ``policy.json`` file found at ``etc/surveil/policy.json``. + +For example, you could modify the following line: :: + + "surveil:admin": "rule:admin_required", + +by: :: + + "surveil:admin": "rule:pass", + +This will modify permissions so that all API calls that require the ``admin`` rule now pass without any verification. diff --git a/doc/source/tutorials/getting_started.rst b/doc/source/tutorials/getting_started.rst index 69ad1f3..3b90adc 100644 --- a/doc/source/tutorials/getting_started.rst +++ b/doc/source/tutorials/getting_started.rst @@ -1,3 +1,5 @@ +.. _tutorial_getting_started: + .. role:: bash(code) :language: bash diff --git a/doc/source/tutorials/index.rst b/doc/source/tutorials/index.rst index 67e34d3..83fb6f7 100644 --- a/doc/source/tutorials/index.rst +++ b/doc/source/tutorials/index.rst @@ -5,3 +5,4 @@ Tutorials :maxdepth: 1 getting_started + developing_the_api