@@ -16,7 +16,7 @@ REST API for Roundup
1616 :depth: 3
1717
1818Introduction
19- ------------
19+ ============
2020
2121After the last 1.6.0 Release, a REST-API developed in 2015 during a
2222Google Summer of Code (GSOC) by Chau Nguyen, supervised by Ezio
@@ -26,7 +26,7 @@ functions for a single page web application, e.g. etag support,
2626pagination, field embedding among others.
2727
2828Enabling the REST API
29- ---------------------
29+ =====================
3030
3131The REST API can be disabled in the ``[web]`` section of ``config.ini``
3232via the variable ``enable_rest`` which is ``yes`` by default.
@@ -66,7 +66,7 @@ explicitly set.)
6666.. _upgrading directions: upgrading.html
6767
6868Preventing CSRF Attacks
69- =======================
69+ -----------------------
7070
7171Clients should set the header X-REQUESTED-WITH to any value and the
7272tracker's config.ini should have ``csrf_enforce_header_x-requested-with
@@ -78,7 +78,7 @@ the origin using the ``allowed_api_origins`` setting in
7878``config.ini``.
7979
8080Rate Limiting the API
81- =====================
81+ ---------------------
8282
8383This is a work in progress. This version of roundup includes Rate
8484Limiting for the API (which is different from rate limiting login
@@ -114,15 +114,15 @@ possible for it to miscount allowing more than burst count. Errors of
114114up to 10% have been seen on slower hardware.
115115
116116Client API
117- ----------
117+ ==========
118118
119119The top-level REST url ``/rest/`` will display the current version of
120120the REST API (Version 1 as of this writing) and some links to relevant
121121endpoints of the API. In the following the ``/rest`` prefix is omitted
122122from relative REST-API links for brevity.
123123
124124Headers
125- =======
125+ -------
126126
127127If rate limiting is enabled there are 3 "standard" headers:
128128
@@ -153,7 +153,7 @@ If the client has requested a deprecated API endpoint, the header:
153153 the sunset link type.
154154
155155Hyperdb Stats
156- =============
156+ -------------
157157
158158Adding ``@stats=true`` as a GET query parameter or POST data item will
159159augment the response with an ``@stats`` dictionary. Any value other
@@ -180,7 +180,7 @@ understanding of the code is recommended if you are going to use this
180180info.
181181
182182Versioning
183- ==========
183+ ----------
184184
185185Currently there is only one version of the API. Versions are simple
186186integers. The current version is ``1``. Version selection is
@@ -199,7 +199,7 @@ The server default is reported by querying the ``/rest/`` endpoint as
199199described above.
200200
201201Input Formats
202- =============
202+ -------------
203203
204204For a GET or OPTIONS request, the Content-Type header should
205205not be sent.
@@ -209,7 +209,7 @@ Otherwise Content-Type is allowed to be ``application/json`` or
209209code 415.
210210
211211CORS preflight requests
212- ^^^^^^^^^^^^^^^^^^^^^^^
212+ ~~~~~~~~~~~~~~~~~~~~~~~
213213
214214CORS preflight requests are done using the OPTIONS method. They
215215require that REST be enabled. These requests do not make any changes
@@ -263,7 +263,7 @@ cause a problem. If it is an issue, you can see
263263and craft a rate limiter that ignores anonymous OPTIONS requests.
264264
265265Response Formats
266- ================
266+ ----------------
267267
268268The default response format is json.
269269
@@ -300,7 +300,7 @@ the accept header are available or if the accept header is invalid.
300300
301301
302302General Guidelines
303- ==================
303+ ------------------
304304
305305Performing a ``GET`` on an item or property of an item will return an
306306ETag header or an @etag property. This needs to be submitted with
@@ -405,21 +405,21 @@ properties). Example::
405405
406406
407407Special Endpoints
408- =================
408+ -----------------
409409
410410There are a few special endpoints that provide some additional data.
411411Tracker administrators can add new endpoints. See
412412"Programming the REST API"_ below.
413413
414414/summary
415- ^^^^^^^^
415+ ~~~~~~~~
416416
417417A Summary page can be reached via ``/summary`` via the ``GET`` method.
418418This is currently hard-coded for the standard tracker schema shipped
419419with roundup and will display a summary of open issues.
420420
421421/data
422- ^^^^^
422+ ~~~~~
423423
424424This is the primary entry point for data from the tracker.
425425
@@ -439,7 +439,7 @@ dictionary with the entry ``data`` referring to the returned data.
439439Details are in the sections below.
440440
441441/data/\ *class* Collection
442- ==========================
442+ --------------------------
443443
444444When performing the ``GET`` method on a class (e.g. ``/data/issue``),
445445the ``data`` object includes the number of items available in
@@ -474,7 +474,7 @@ decorations in the response. See the section on pagination below for
474474details.
475475
476476Searching
477- ^^^^^^^^^
477+ ~~~~~~~~~
478478
479479Searching is done by adding roundup field names and values as query
480480parameters. Using: https://.../rest/data/issue you can search using:
@@ -549,7 +549,7 @@ body of a msg) is a work in progress.
549549.. _URL Encoding: https://en.wikipedia.org/wiki/Percent-encoding
550550
551551Transitive Searching
552- ~~~~~~~~~~~~~~~~~~~~
552+ ^^^^^^^^^^^^^^^^^^^^
553553
554554In addition to searching an issue by its properties, you can search
555555for issues where linked items have a certain property. For example
@@ -572,7 +572,7 @@ it. However they may be able to use searches to discover the value of
572572the field even if they can't view it.
573573
574574Sorting
575- ^^^^^^^
575+ ~~~~~~~
576576
577577Collection endpoints support sorting. This is controlled by specifying a
578578``@sort`` parameter with a list of properties of the searched class.
@@ -586,7 +586,7 @@ and then by id of an issue::
586586
587587
588588Pagination
589- ^^^^^^^^^^
589+ ~~~~~~~~~~
590590
591591Collection endpoints support pagination. This is controlled by query
592592parameters ``@page_size`` and ``@page_index`` (Note the use of the
@@ -645,7 +645,7 @@ clients must be prepared to handle the incomplete response and request
645645the next URL to retrieve all of the entries.
646646
647647Field embedding and verbose output
648- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
648+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
649649
650650In collections, you can specify what fields should be embedded in the
651651returned data. There are some shortcuts provided using the
@@ -738,7 +738,7 @@ See the `Searches and selection`_ section for the use cases supported
738738by these features.
739739
740740Getting Message and Files Content
741- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
741+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
742742
743743You can retreive a message with a url like
744744``https://.../demo/rest/data/msg/11``. This returns something like::
@@ -850,7 +850,7 @@ You can use the `binary_content property`_ described below to
850850retrieve an encoded copy of the data.
851851
852852Other query params
853- ^^^^^^^^^^^^^^^^^^
853+ ~~~~~~~~~~~~~~~~~~
854854
855855This table lists other supported parameters:
856856
@@ -869,7 +869,7 @@ This table lists other supported parameters:
869869 this time.
870870
871871Using the POST method
872- ^^^^^^^^^^^^^^^^^^^^^
872+ ~~~~~~~~~~~~~~~~~~~~~
873873
874874Only class links support the ``POST`` method for creation of new items
875875of a class, e.g., a new issue via the ``/data/issue`` link. The post
@@ -992,15 +992,15 @@ mechanism.
992992 response was lost.
993993
994994Other Supported Methods for Collections
995- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
995+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
996996
997997Supports the ``OPTIONS`` method for determining which methods are
998998allowed on a given endpoint.
999999
10001000Does not support PUT, DELETE or PATCH.
10011001
10021002/data/\ *class*/\ *id* item
1003- ===========================
1003+ ---------------------------
10041004
10051005When performing the ``GET`` method on an item
10061006(e.g. ``/data/issue/42``), a ``link`` attribute contains the link to
@@ -1083,7 +1083,7 @@ An example of returned values::
10831083 }
10841084
10851085Retrieve item using key value
1086- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1086+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10871087
10881088If the class has a key attribute, e.g. the 'status' class in the
10891089classic tracker, it can be used to retrieve the item.
@@ -1103,7 +1103,7 @@ The long-form (with ``=``) is different from a query-parameter like
11031103that have ``closed`` as a substring.
11041104
11051105Dealing with Messages and Files
1106- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1106+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11071107
11081108Using the requests library you can upload a file using::
11091109
@@ -1147,7 +1147,7 @@ return something like::
11471147
11481148
11491149Other Supported Methods for Items
1150- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1150+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11511151
11521152The method ``PUT`` is allowed on individual items, e.g.
11531153``/data/issue/42`` On success it returns the same parameters as the
@@ -1302,7 +1302,7 @@ payload. When modifying a property via ``PUT`` or ``PATCH`` or
13021302``If-Match`` header.
13031303
13041304/data/\ *class*/\ *id*/\ *property* field
1305- =========================================
1305+ -----------------------------------------
13061306
13071307A ``GET`` method on a property (e.g. ``/data/issue/42/title``) returns the
13081308link, an ``@etag``, the type of the property (e.g. "<type str>") the id
@@ -1325,7 +1325,7 @@ All endpoints support an ``OPTIONS`` method for determining which
13251325methods are allowed on a given endpoint.
13261326
13271327Message and File Content
1328- ^^^^^^^^^^^^^^^^^^^^^^^^
1328+ ~~~~~~~~~~~~~~~~~~~~~~~~
13291329
13301330Messages and files have content properties. If the data is utf-8
13311331compatible (e.g. an email message) you can retrieve it with
@@ -1369,7 +1369,7 @@ The data is a json encoded hexidecimal representation of the data.
13691369
13701370
13711371Other Supported Methods for fields
1372- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1372+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13731373
13741374The method ``PUT`` is allowed on a property e.g.,
13751375``/data/issue/42/title``. On success it returns the same parameters as
@@ -1421,7 +1421,7 @@ payload. When modifying a property via ``PUT`` or ``PATCH`` or
14211421``If-Match`` header.
14221422
14231423Tunneling Methods via POST
1424- ==========================
1424+ --------------------------
14251425
14261426If you are working through a proxy and unable to use http methods like
14271427PUT, PATCH, or DELETE, you can use POST to perform the action. To tunnel
@@ -1431,10 +1431,10 @@ POST should be what you would send if you were using the method
14311431without tunneling.
14321432
14331433Examples and Use Cases
1434- ----------------------
1434+ ======================
14351435
14361436sample python client
1437- ====================
1437+ --------------------
14381438
14391439The client uses the python ``requests`` library for easier interaction
14401440with a REST API supporting JSON encoding::
@@ -1516,7 +1516,7 @@ and restore::
15161516
15171517
15181518Searches and selection
1519- ======================
1519+ ----------------------
15201520
15211521One difficult interface issue is selection of items from a long list.
15221522Using multi-item selects requires loading a lot of data (e.g. consider
@@ -1611,14 +1611,14 @@ fields can be used for subsearch and sorting.
16111611
16121612
16131613Programming the REST API
1614- ------------------------
1614+ ========================
16151615
16161616You can extend the rest api for a tracker. This describes how to add
16171617new rest end points. At some point it will also describe the rest.py
16181618structure and implementation.
16191619
16201620Adding new rest endpoints
1621- =========================
1621+ -------------------------
16221622
16231623Add or edit the file `interfaces.py`_ at the root of the tracker
16241624directory.
@@ -1692,7 +1692,7 @@ Adding other endpoints (e.g. to allow an OPTIONS query against
16921692``/data/issue/@schema``) is left as an exercise for the reader.
16931693
16941694Redefine/move rest endpoints
1695- ============================
1695+ ----------------------------
16961696
16971697In addition to adding new endpoints, you can redefine existing
16981698endpoints. Adding this as described above::
@@ -1734,7 +1734,7 @@ normally at /rest/data/<class>.
17341734
17351735
17361736Controlling Access to Backend Data
1737- ==================================
1737+ ----------------------------------
17381738
17391739Roundup's schema is the primary access control mechanism. Roles and
17401740Permissions provide the ability to carefully control what data can be
@@ -1846,7 +1846,7 @@ the url passes the ``roles=User`` filter option which is silently
18461846ignored.
18471847
18481848Changing Access Roles with JSON Web Tokens
1849- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1849+ ------------------------------------------
18501850
18511851As discussed above Roundup's schema is the access control mechanism.
18521852However you may want to integrate a third party system with roundup.
@@ -2110,7 +2110,7 @@ for ideas or add your own.
21102110.. _thoughts on JWT credentials: https://issues.roundup-tracker.org/issue2551064
21112111
21122112Final steps
2113- ^^^^^^^^^^^
2113+ ~~~~~~~~~~~
21142114
21152115See the `upgrading directions`_ on how to use the ``updateconfig``
21162116command to generate an updated copy of config.ini using
@@ -2133,7 +2133,7 @@ subscribing and for archives of the lists.
21332133
21342134
21352135Creating Custom Rate Limits
2136- ===========================
2136+ ---------------------------
21372137
21382138You can replace the default rate limiter that is configured using
21392139the tracker's ``config.ini``. You can return different rate
@@ -2177,7 +2177,7 @@ and period that are specific to a user. If either is set to 0,
21772177the defaults from ``config.ini`` file are used.
21782178
21792179Test Examples
2180- ^^^^^^^^^^^^^
2180+ ~~~~~~~~~~~~~
21812181
21822182Rate limit tests::
21832183
0 commit comments