Mercurial > p > roundup > code
annotate doc/rest.txt @ 5826:8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 25 Jun 2019 17:02:37 -0400 |
| parents | 352e78c3b4ab |
| children | da1f40b5148d |
| rev | line source |
|---|---|
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
1 |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
2 ==================== |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
3 REST API for Roundup |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
4 ==================== |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
5 |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
6 .. contents:: |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
7 :local: |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
8 :depth: 3 |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
9 |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
10 Introduction |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
11 ------------ |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
12 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
13 After the last 1.6.0 Release, a REST-API developed in 2015 during a |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
14 Google Summer of Code (GSOC) by Chau Nguyen, supervised by Ezio |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
15 Melotti was integrated. The code was updated by John Rouillard and |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
16 Ralf Schlatterbeck to fix some shortcomings and provide the necessary |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
17 functions for a single page web application, e.g. etag support, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
18 pagination, field embedding among others. |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
19 |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
20 Enabling the REST API |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
21 --------------------- |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
22 |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
23 The REST API can be disabled in the ``[web]`` section of ``config.ini`` |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
24 via the variable ``enable_rest`` which is ``yes`` by default. |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
25 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
26 The REST api is reached via the ``/rest/`` endpoint of the tracker |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
27 URL. Partial URLs paths below (not starting with https) will have |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
28 /rest removed for brevity. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
29 |
|
5826
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
30 Make sure that the ``secret_key`` option is defined in the |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
31 ``[web]`` section of your tracker's ``config.ini``. Following the |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
32 `upgrading directions`_ using ``roundup-admin ... updateconfig |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
33 ...`` will generate the ``secret_key`` comments and setting. Then |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
34 you can merge this into your ``config.ini``. If you are |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
35 installing a new tracker with ``roundup-admin ... install`` the |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
36 ``secret_key`` value is automatically set to some random value. |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
37 |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
38 If ``secret_key`` is not set, the etag value returned by a REST |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
39 call will be change on every call even though the item has not |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
40 changed. |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
41 |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
42 .. _upgrading directions: upgrading.html |
|
8e17c34a5cf0
issue2551048. Document WEB_SECRET_KEY in config.ini.
John Rouillard <rouilj@ieee.org>
parents:
5824
diff
changeset
|
43 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
44 Preventing CSRF Attacks |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
45 ======================= |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
46 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
47 Clients should set the header X-REQUESTED-WITH to any value and the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
48 tracker's config.ini should have ``csrf_enforce_header_x-requested-with |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
49 = yes`` or ``required``. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
50 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
51 Rate Limiting the API |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
52 ===================== |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
53 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
54 This is a work in progress. Check the release notes to see if your |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
55 version of roundup includes Rate Limiting for the API (which is |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
56 different from rate limiting login attempts on the web interface). |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
57 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
58 This is enabled by setting the ``api_calls_per_interval`` and |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
59 ``api_interval_in_sec`` configuration parameters in the ``[web]`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
60 section of ``config.ini``. The settings are documented in the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
61 config.ini file. |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
62 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
63 If ``api_calls_per_interval = 60`` and ``api_interval_in_sec = 60`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
64 the user can make 60 calls in a minute. They can use them all up in the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
65 first second and then get one call back every second. With |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
66 ``api_calls_per_interval = 60`` and ``api_interval_in_sec = 3600`` (1 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
67 hour) they can use all 60 calls in the first second and they get one |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
68 additional call every 10 seconds. ``api_calls_per_interval`` is the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
69 burst rate that you are willing to allow within `api_interval_in_sec`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
70 seconds. The average rate of use is the ratio of |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
71 ``api_calls_per_interval/api_interval_in_sec``. So you can have many |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
72 values that permit one call per second on average: 1/1, 60/60, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
73 3600/3600, but they all have a different maximum burst rates: 1/sec, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
74 60/sec and 3600/sec. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
75 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
76 A single page app may make 20 or 30 calls to populate the page (e.g. a |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
77 list of open issues). Then wait a few seconds for the user to select |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
78 an issue. When displaying the issue, it needs another 20 or calls to |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
79 populate status dropdowns, pull the first 10 messages in the issue |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
80 etc. Controlling the burst rate as well as the average rate is a |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
81 tuning exercise left for the tracker admin. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
82 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
83 Also the rate limit is a little lossy. Under heavy load, it is |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
84 possible for it to miscount allowing more than burst count. Errors of |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
85 up to 10% have been seen on slower hardware. |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
86 |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
87 Client API |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
88 ---------- |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
89 |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
90 The top-level REST url ``/rest/`` will display the current version of |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
91 the REST API (Version 1 as of this writing) and some links to relevant |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
92 endpoints of the API. In the following the ``/rest`` prefix is omitted |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
93 from relative REST-API links for brevity. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
94 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
95 Headers |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
96 ======= |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
97 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
98 If rate limiting is enabled there are 3 "standard" headers: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
99 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
100 **X-RateLimit-Limit**: Calls allowed per period. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
101 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
102 **X-RateLimit-Remaining**: Calls available to be completed in this window. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
103 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
104 **X-RateLimit-Reset**: window ends in this many seconds. (Note, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
105 not an epoch timestamp). After this time, all |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
106 X-RateLimit-Limit calls are available again. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
107 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
108 and one helpful header to report the period that is missing |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
109 from other lists of rate limit headers: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
110 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
111 **X-RateLimit-Limit-Period**: Defines period in seconds for X-RateLimit-Limit. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
112 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
113 Also if the user has exceeded the rate limit, this header is added: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
114 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
115 **Retry-After**: The number of second to wait until 1 api call will succeed. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
116 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
117 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
118 General Guidelines |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
119 ================== |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
120 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
121 Performing a ``GET`` on an item or property of an item will rethrn an |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
122 ETag header or an @etag property. This needs to be submitted with |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
123 ``DELETE``, ``PUT`` and ``PATCH`` operations on the item using an |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
124 ``If-Match`` header or an ``"@etag`` property in the data payload if |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
125 the method supports a payload. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
126 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
127 The exact details of returned data is determined by the value of the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
128 ``@verbose`` query parameter. The various supported values and their |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
129 effects are described in the following sections. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
130 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
131 The default return format is JSON. If you add the ``dicttoxml.py`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
132 module you can request XML formatted data using the header ``Accept: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
133 application/xml`` in your request. Both output formats are similar in |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
134 structure. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
135 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
136 All output is wrapped in an envelope called ``data``. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
137 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
138 When using collection endpoints (think list of issues, users ...), the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
139 ``data`` envelope contains metadata (e.g. total number of items) as |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
140 well as a ``collections`` list of objects:: |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
141 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
142 { "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
143 "meta data field1": "value", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
144 "meta data field2": "value", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
145 "collecton": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
146 { "link": "url to item", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
147 "id": "internal identifier for item" }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
148 { "link": "url to second item", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
149 "id": "id item 2" }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
150 ... ] |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
151 "@links": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
152 "relation": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
153 { "rel": "relation/subrelation", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
154 "uri": "uri to use to implement relation" }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
155 ... |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
156 ], |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
157 "relation2": [ {...} ], ... |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
158 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
159 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
160 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
161 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
162 available meta data is described in the documention for the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
163 collections endpoint. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
164 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
165 The ``link`` fields implement HATEOS by supplying a url for the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
166 resource represented by that object. The "link" parameter with the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
167 value of a url is a special case of the @links parameter. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
168 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
169 In the @links object, each relationship is a list of full link json |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
170 objects. These include rel (relationship) and uri properties. In the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
171 future this may be extended to include other data like content-type. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
172 However including a full @links object for every item includes a lot |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
173 of overhead since in most cases only the self relationship needs to be |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
174 represented. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
175 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
176 Because every object, link and multilink ends up getting a url, the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
177 shorter 'link' representation is used for this special case. The |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
178 ``link`` property expresses the ``self`` relationship and its value is |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
179 the uri property of the full link object. In collections, properties |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
180 from each item can be embedded in the returned data (see ``@fields`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
181 below). This can not be done if the property is called link as that |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
182 conflicts with the self url. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
183 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
184 When using an item endpoint (think an individual issue), metadata is |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
185 included in the ``data`` envelope. Inside of the envelope, the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
186 ``attributes`` object contains the data for the field/properties of |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
187 the issue. Example:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
188 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
189 { "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
190 "meta data field1": "value", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
191 "type": "type of item, issue, user ..." |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
192 "link": "link to retreive item", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
193 "attributes": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
194 "title": "title of issue", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
195 "nosy": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
196 { "link": "url for user4", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
197 "id": "4" } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
198 ], |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
199 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
200 ... } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
201 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
202 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
203 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
204 Using a property endpoint (e.g. title or nosy list for an issue) the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
205 ``data`` wrapper has a ``data`` subfield that represents the value of |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
206 the property. This ``data`` subfield may be a simple string (all types |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
207 except mutlilink) or a list of strings (multilink |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
208 properties). Example:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
209 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
210 { "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
211 "type": "description of class", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
212 "@etag": "\"f15e6942f00a41960de45f9413684591\"", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
213 "link": "link to retreive property", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
214 "id": "id for object with this property", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
215 "data": "value of property" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
216 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
217 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
218 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
219 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
220 Special Endpoints |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
221 ================= |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
222 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
223 There are a few special endpoints that provide some additional data. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
224 Tracker admiinstrators can add new endpoints. See |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
225 "Programming the REST API"_ below. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
226 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
227 /summary |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
228 ^^^^^^^^ |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
229 |
|
5695
3e1b66c4e1e2
Update docs. Correct errors reported by setup.py build_docs. Add rest
John Rouillard <rouilj@ieee.org>
parents:
5688
diff
changeset
|
230 A Summary page can be reached via ``/summary`` via the ``GET`` method. |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
231 This is currently hard-coded for the standard tracker schema shipped |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
232 with roundup and will display a summary of open issues. |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
233 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
234 /data |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
235 ^^^^^ |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
236 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
237 This is the primary entry point for data from the tracker. |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
238 |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
239 The ``/data`` link will display a set of classes of the tracker. All |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
240 classes can be reached via ``/data/<classname>`` where ``<classname>`` |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
241 is replace with the name of the class to query, e.g. ``/data/issue``. |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
242 Individual items of a class (e.g. a single issue) can be queried by |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
243 giving the issue-id, e.g., ``/data/issue/42``. Individual properties of |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
244 an item can be queried by appending the property, e.g., |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
245 ``/data/issue/42/title``. |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
246 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
247 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
248 All the links mentioned in the following support the http method ``GET``. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
249 Results of a ``GET`` request will always return the results as a |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
250 dictionary with the entry ``data`` referring to the returned data. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
251 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
252 Details are in the sections below. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
253 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
254 /data/\ *class* Collection |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
255 ========================== |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
256 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
257 When performing the ``GET`` method on a class (e.g. ``/data/issue``), |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
258 the ``data`` object includes the number of items available in |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
259 ``@total_size``. A a ``collection`` list follows which contains the id |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
260 and link to the respective item. For example a get on |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
261 https://.../rest/data/issue returns:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
262 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
263 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
264 "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
265 "collection": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
266 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
267 "id": "1", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
268 "link": "https://.../rest/data/issue/1" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
269 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
270 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
271 "id": "100", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
272 "link": "https://.../rest/data/issue/100" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
273 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
274 ... |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
275 ], |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
276 "@total_size": 171 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
277 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
278 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
279 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
280 Collection endpoints support a number of features as seen in the next |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
281 sections. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
282 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
283 Searching |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
284 ^^^^^^^^^ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
285 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
286 Searching is done by adding roundup field names and values as query |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
287 parameters. Using: https://.../rest/data/issue you can search using: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
288 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
289 .. list-table:: Query Parameters Examples |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
290 :header-rows: 1 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
291 :widths: 20 20 80 |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
292 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
293 * - Query parameter |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
294 - Field type |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
295 - Explanation |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
296 * - ``title=foo`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
297 - String |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
298 - perform a substring search and find any issue with the word foo |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
299 in the title. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
300 * - ``status=2`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
301 - Link |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
302 - find any issue whose status link is set to the id 2. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
303 * - ``status=open`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
304 - Link |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
305 - find any issue where the name of the status is open. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
306 Note this is not a string match so using nosy=ope will fail. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
307 * - ``nosy=1`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
308 - MultiLink |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
309 - find any issue where the multilink nosy includes the id 1. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
310 * - ``nosy=admin`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
311 - MultiLink |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
312 - find any issue where the multilink nosy includes the user admin. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
313 Note this is not a string match so using nosy=admi will fail. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
314 * - ``booleanfield=1`` - also values: true, TRUE, yes, YES etc. Other |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
315 values match false. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
316 - Boolean |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
317 - find an issue with the boolean field set to true. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
318 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
319 As seen above, Links and Multilinks can be specified numerically or |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
320 symbolically, e.g., searching for issues in status ``closed`` can be |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
321 achieved by searching for ``status=closed`` or ``status=3`` (provided |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
322 the ``closed`` status has ID 3). Note that even though the symbolic |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
323 name is a string, in this case it is also a key value. As a result it |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
324 only does an exact match. |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
325 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
326 Searching for strings (e.g. the issue title, or a keyword name) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
327 performs a case-insensitive substring search, so searching for |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
328 title=Something will find all issues with "Something" or "someThing", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
329 etc. in the title. There is currently no way to perform an exact |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
330 string match. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
331 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
332 To make this clear, searching |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
333 ``https://.../rest/data/issue?keyword=foo`` will not work unless there |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
334 is a keyword with a name field of ``foo`` which is the key field of |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
335 the keyword. However searching the text property ``name`` using |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
336 ``https://.../rest/data/keyword?name=foo`` (note searching keyword |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
337 class not issue class) will return matches for ``foo``, ``foobar``, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
338 ``foo taz`` etc. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
339 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
340 In all cases the field ``@total_size`` is reported which is the total |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
341 number of items available if you were to retreive all of them. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
342 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
343 Other data types: Date, Interval Integer, Number need examples and may |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
344 need work to allow range searches. Full text search (e.g. over the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
345 body of msgs) is a work in progress. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
346 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
347 Pagination |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
348 ^^^^^^^^^^ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
349 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
350 Collection endpoints support pagination. This is controlled by query |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
351 parameters ``@page_size`` and ``@page_index`` (Note the use of the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
352 leading `@` to make the parameters distinguishable from field names.) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
353 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
354 .. list-table:: Query Parameters Examples |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
355 :header-rows: 1 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
356 :widths: 20 80 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
357 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
358 * - Query parameter |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
359 - Explanation |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
360 * - ``@page_size`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
361 - specifies how many items are displayed at once. If no |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
362 ``@page_size`` is specified, all matching items are returned. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
363 * - ``@page_index`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
364 - (which defaults to 1 if not given) specifies which page number |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
365 of ``@page_size`` items is displayed. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
366 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
367 Also when pagenation is enabled the returned data include pagenation |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
368 links along side the collection data. This looks like:: |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
369 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
370 { "data": |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
371 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
372 "collection": { ... }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
373 "@total_size": 222, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
374 "@links": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
375 "self": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
376 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
377 "uri": |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
378 "https://.../rest/data/issue?@page_index=1&@fields=status&@page_size=5", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
379 "rel": "self" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
380 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
381 ], |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
382 "next": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
383 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
384 "uri": |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
385 "https://.../rest/data/issue?@page_index=2&@fields=status&@page_size=5", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
386 "rel": "next" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
387 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
388 ] |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
389 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
390 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
391 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
392 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
393 The ``@links`` parameter is a dictionary indexed by |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
394 relationships. Each relationship is a list of one or more full link |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
395 json objects. Above we have link relations to move to the next |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
396 page. If we weren't at the first page, there would be a ``prev`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
397 relation to move to the previous page. Also we have a self relation |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
398 (which is missing the @page_index, hence we are at page 1) that can be |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
399 used to get the same page again. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
400 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
401 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
402 Field embedding and verbose output |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
403 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
404 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
405 In collections, you can specify what fields should be embedded in the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
406 returned data. There are some shortcuts provided using the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
407 ``@verbose`` parameter. All the examples in this section are for a GET |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
408 operation on ``https://.../rest/data/issue``. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
409 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
410 .. list-table:: Query Parameters Examples |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
411 :header-rows: 1 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
412 :widths: 20 80 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
413 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
414 * - Query parameter |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
415 - Explanation |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
416 * - ``@verbose=0`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
417 - each item in the collection has its "id" property displayed |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
418 and a link with the URL to retreive the item. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
419 * - ``@verbose=1`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
420 - for collections this output is the same as ``@verbose=0``. This |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
421 is the default. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
422 * - ``@verbose=2`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
423 - each item in the collection includes the "label" property in |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
424 addition to "id" property and a link for the item. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
425 This is useful as documented below in "Searches and selection"_. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
426 * - ``@verbose=3`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
427 - will display the content property of messages and files. Note |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
428 warnings about this below. Using this for collections is |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
429 discouraged as it is slow and produces a lot of data. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
430 * - ``@fields=status,title`` |
|
5824
352e78c3b4ab
Allow @fields to include protected properties, document @protected
John Rouillard <rouilj@ieee.org>
parents:
5738
diff
changeset
|
431 - will return the ``status`` and ``title`` fields for the |
|
352e78c3b4ab
Allow @fields to include protected properties, document @protected
John Rouillard <rouilj@ieee.org>
parents:
5738
diff
changeset
|
432 displayed issues. It is added to the fields returned by the |
|
352e78c3b4ab
Allow @fields to include protected properties, document @protected
John Rouillard <rouilj@ieee.org>
parents:
5738
diff
changeset
|
433 @verbose parameter. Protected properties |
|
352e78c3b4ab
Allow @fields to include protected properties, document @protected
John Rouillard <rouilj@ieee.org>
parents:
5738
diff
changeset
|
434 can be included in the list and will be returned. |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
435 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
436 In addition collections support the ``@fields`` parameter which is a |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
437 colon or comma separated list of fields to embed in the response. For |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
438 example ``https://.../rest/data/issue?@verbose=2`` is the same as: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
439 ``https://.../rest/data/issue?@fields=title`` since the label property |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
440 for an issue is its title. You can use both ``@verbose`` and |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
441 ``@fields`` to get additional info. For example |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
442 ``https://.../rest/data/issue?@verbose=2&@fields=status`` returns:: |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
443 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
444 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
445 "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
446 "collection": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
447 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
448 "link": |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
449 "https://.../rest/data/issue/1", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
450 "title": "Welcome to the tracker START HERE", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
451 "id": "1", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
452 "status": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
453 "link": |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
454 "https://.../rest/data/status/1", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
455 "id": "1", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
456 "name": "new" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
457 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
458 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
459 ... |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
460 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
461 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
462 the format of the status field (included because of |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
463 ``@fields=status``) includes the label for the status. This is due to |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
464 inclusion of ``@verbose=2``. Without verbose you would see:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
465 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
466 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
467 "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
468 "collection": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
469 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
470 "link": |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
471 "https://.../rest/data/issue/1", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
472 "id": "1", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
473 "status": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
474 "link": |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
475 "https://.../rest/data/status/1", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
476 "id": "1" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
477 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
478 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
479 ... |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
480 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
481 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
482 Note that the ``link`` field that is returned doesn't exist in the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
483 database. It is a construct of the rest interface. This means that you |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
484 can not set ``@fields=link`` and get the link property included in the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
485 output. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
486 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
487 Also using ``@fields=@etag`` will not work to retreive the etag for |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
488 items in the collection. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
489 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
490 See the `Searches and selection`_ section for the use cases supported |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
491 by these features. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
492 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
493 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
494 Other query params |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
495 ^^^^^^^^^^^^^^^^^^ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
496 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
497 This table lists other supported parameters: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
498 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
499 .. list-table:: Query Parameters Examples |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
500 :header-rows: 1 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
501 :widths: 20 80 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
502 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
503 * - Query parameter |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
504 - Explanation |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
505 * - ``@pretty=false`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
506 - by default json data is pretty printed to make it readable to |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
507 humans. This eases testing and with compression enabled the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
508 extra whitespace doesn't bloat the returned payload excessively. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
509 You can disable pretty printing by using this query parameter. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
510 Note the default is true, so @pretty=true is not supported at |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
511 this time. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
512 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
513 Using the POST method |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
514 ^^^^^^^^^^^^^^^^^^^^^ |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
515 |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
516 Only class links support the ``POST`` method for creation of new items |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
517 of a class, e.g., a new issue via the ``/data/issue`` link. The post |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
518 gets a dictionary of keys/values for the new item. It returns the same |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
519 parameters as the GET method after successful creation. |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
520 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
521 If you perform a get on an item with ``@verbose=0``, it is in the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
522 correct form to use as a the payload of a post. |
|
5660
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
523 |
|
d8d2b7724292
First attempt at REST-API documentation
Ralf Schlatterbeck <rsc@runtux.com>
parents:
diff
changeset
|
524 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
525 Safely Re-sending POST |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
526 ^^^^^^^^^^^^^^^^^^^^^^ |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
527 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
528 POST is used to create new object in a class. E.G. a new issue. One |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
529 problem is that a POST may time out. Because it is not idempotent like |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
530 a PUT or DELETE, retrying the interrupted POST may result in the |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
531 creation of a duplicate issue. |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
532 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
533 To solve this problem, a two step process inspired by the POE - Post |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
534 Once Exactly spec: |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
535 https://tools.ietf.org/html/draft-nottingham-http-poe-00 is provided. |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
536 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
537 This mechanism returns a single use URL. POSTing to the URL creates |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
538 a new object in the class. |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
539 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
540 First we get the URL. Here is an example using curl:: |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
541 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
542 curl -u demo:demo -s -X POST -H "Referer: https://.../demo/" \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
543 -H "X-requested-with: rest" \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
544 -H "Content-Type: application/json" \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
545 --data '' \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
546 https://.../demo/rest/data/issue/@poe |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
547 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
548 This will return a json payload like:: |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
549 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
550 { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
551 "data": { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
552 "expires": 1555266310.4457426, |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
553 "link": "https://.../demo/rest/data/issue/@poe/vizl713xHtIzANRW9jPb3bWXePRzmehdmSXzEta1" |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
554 } |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
555 } |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
556 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
557 The value of expires is a Unix timestamp in seconds. In this case it |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
558 has the default lifetime of 30 minutes after the current time. Using |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
559 the link more than 30 minutes into the future will cause a 400 error. |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
560 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
561 Within 30 minutes, the link can be used to post an issue with the same |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
562 payload that would normally be sent to: |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
563 ``https://.../demo/rest/data/issue``. |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
564 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
565 For example:: |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
566 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
567 curl -u demo:demo -s -X POST \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
568 -H "Referer: https://.../demo/" \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
569 -H "X-requested-with: rest" \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
570 -H "Content-Type: application/json" \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
571 --data-binary '{ "title": "a problem" }' \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
572 https://.../demo/rest/data/issue/@poe/vizl713xHtIzANRW9jPb3bWXePRzmehdmSXzEta1 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
573 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
574 returns:: |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
575 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
576 { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
577 "data": { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
578 "link": "https://.../demo/rest/data/issue/2280", |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
579 "id": "2280" |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
580 } |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
581 } |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
582 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
583 Once the @poe link is used and creates an issue, it becomes invalid |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
584 and can't be used again. Posting to it after the issue, or other |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
585 object, is created, results in a 400 error [#poe_retry]_. |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
586 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
587 Note that POE links are by restricted to the class that was used to |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
588 get the link. So you can only create an issue using the link returned |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
589 from ``rest/data/issue/@poe``. You can create a generic POE link by adding |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
590 the "generic" field to the post payload:: |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
591 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
592 curl -u demo:demo -s -X POST -H "Referer: https://.../demo/" \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
593 -H "X-requested-with: rest" \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
594 --data 'lifetime=100&generic=1' \ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
595 https://.../demo/rest/data/issue/@poe |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
596 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
597 This will return a link under: ``https://.../demo/rest/data/issue/@poe``:: |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
598 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
599 { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
600 "data": { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
601 "expires": 1555268640.9606116, |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
602 "link": |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
603 "https://.../demo/rest/data/issue/@poe/slPrzmEq6Q9BTjvcKhfxMNZL4uHXjbHCidY1ludZ" |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
604 } |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
605 } |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
606 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
607 You could use the link and change 'issue' to 'user' and it would work |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
608 to create a user. Creating generic POE tokens is *not* recommended, |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
609 but is available if a use case requires it. |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
610 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
611 This example also changes the lifetime of the POE url. This link has |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
612 a lifetime of 15 minutes (900 seconds). Using it after 16 minutes will |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
613 result in a 400 error. A lifetime up to 1 hour can be specified. |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
614 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
615 POE url's are an optional mechanism. If: |
|
5688
1b9ef04b9528
Add docs on how to add new rest endpoints.
John Rouillard <rouilj@ieee.org>
parents:
5678
diff
changeset
|
616 |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
617 * you do not expect your client to retry a failed post, |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
618 * a failed post is unlikely (e.g. you are running over a local lan), |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
619 * there is a human using the client and who can intervene if a post |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
620 fails |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
621 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
622 you can use the url ``https://.../demo/data/<class>``. However if you |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
623 are using this mechanism to automate creation of objects and will |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
624 automatically retry a post until it succeeds, please use the POE |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
625 mechanism. |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
626 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
627 .. [#poe_retry] As a future enhancement, performing a POST to the POE |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
628 link soon after it has been used to create an object will |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
629 change. It will not return a 400 error. It will will trigger a |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
630 301 redirect to the url for the created object. After some |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
631 period of time (maybe a week) the POE link will be removed and |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
632 return a 400 error. This is meant to allow the client (a time |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
633 limited way) to retrieve the created resource if the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
634 response was lost. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
635 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
636 Other Supported Methods for Collections |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
637 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
638 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
639 Supports the ``OPTIONS`` method for determining which methods are |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
640 allowed on a given endpoint. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
641 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
642 Does not support PUT, DELETE or PATCH. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
643 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
644 /data/\ *class*/\ *id* item |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
645 =========================== |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
646 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
647 When performing the ``GET`` method on an item |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
648 (e.g. ``/data/issue/42``), a ``link`` attribute contains the link to |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
649 the item, ``id`` contains the id, ``type`` contains the class name |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
650 (e.g. ``issue`` in the example) and an ``etag`` property can be used |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
651 to detect modifications since the last query. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
652 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
653 Individual properties of the item are returned in an ``attributes`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
654 dictionary. The properties returned depend on the permissions of the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
655 account used for the query. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
656 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
657 By default all (visible to the current user) attributes/properties are |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
658 returned. You can limit this by using the ``@fields`` query parameter |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
659 similar to how it is used in collections. This way you can only return |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
660 the fields you are interested in reducing network load as well as |
|
5824
352e78c3b4ab
Allow @fields to include protected properties, document @protected
John Rouillard <rouilj@ieee.org>
parents:
5738
diff
changeset
|
661 memory and parsing time on the client side. By default protected |
|
352e78c3b4ab
Allow @fields to include protected properties, document @protected
John Rouillard <rouilj@ieee.org>
parents:
5738
diff
changeset
|
662 properties (read only in the database) are not listed. Th |
|
352e78c3b4ab
Allow @fields to include protected properties, document @protected
John Rouillard <rouilj@ieee.org>
parents:
5738
diff
changeset
|
663 is makes it easier to submit the attributes from a |
|
352e78c3b4ab
Allow @fields to include protected properties, document @protected
John Rouillard <rouilj@ieee.org>
parents:
5738
diff
changeset
|
664 ``@verbose=0`` query using PUT. To include protected properties |
|
352e78c3b4ab
Allow @fields to include protected properties, document @protected
John Rouillard <rouilj@ieee.org>
parents:
5738
diff
changeset
|
665 in the output og a GET add the query parameter |
|
352e78c3b4ab
Allow @fields to include protected properties, document @protected
John Rouillard <rouilj@ieee.org>
parents:
5738
diff
changeset
|
666 ``@protected=true`` to the query and attributes like: actor, |
|
352e78c3b4ab
Allow @fields to include protected properties, document @protected
John Rouillard <rouilj@ieee.org>
parents:
5738
diff
changeset
|
667 created, creator and activity will be include in the result. |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
668 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
669 Link and Multilink properties are displayed as a dictionary with a |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
670 ``link`` and an ``id`` property by default. This is controlled by the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
671 ``@verbose`` attribute which is set to 1 by default. If set to 0, only |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
672 the id is shown for Link and Multilink attributes. In this form, the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
673 data can be modified and sent back using ``PUT`` to change the item. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
674 If set to 2, the label property (usually ``name`` e.g. for status) is |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
675 also put into the dictionary. Content properties of message and file |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
676 object are by default also shown as a dictionary with a sole link |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
677 attribute. The link is the download link for the file or message. If |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
678 @verbose is >= 3, the content property is shown in json as a (possibly |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
679 very long) string. Currently the json serializer cannot handle files |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
680 not properly utf-8 encoded, so specifying @verbose=3 for files is |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
681 currently discouraged. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
682 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
683 An example of returned values:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
684 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
685 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
686 "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
687 "type": "issue", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
688 "@etag": "\"f15e6942f00a41960de45f9413684591\"", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
689 "link": "https://.../rest/data/issue/23", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
690 "attributes": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
691 "keyword": [], |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
692 "messages": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
693 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
694 "link": "https://.../rest/data/msg/375", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
695 "id": "375" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
696 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
697 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
698 "link": "https://.../rest/data/msg/376", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
699 "id": "376" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
700 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
701 ... |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
702 ], |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
703 "files": [], |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
704 "status": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
705 "link": "https://.../rest/data/status/2", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
706 "id": "2" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
707 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
708 "title": "This is a title title", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
709 "superseder": [], |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
710 "nosy": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
711 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
712 "link": "https://.../rest/data/user/4", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
713 "id": "4" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
714 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
715 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
716 "link": "https://.../rest/data/user/5", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
717 "id": "5" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
718 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
719 ], |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
720 "assignedto": null, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
721 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
722 "id": "23" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
723 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
724 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
725 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
726 Retrieve item using key value |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
727 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
728 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
729 If the class has a key attribute, e.g. the 'status' class in the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
730 classic tracker, it can be used to retried the item. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
731 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
732 You can get an individual status by specifying the key-attribute value |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
733 e.g. ``/data/status/name=closed``. Note that ``name`` in this example |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
734 must be the key-attribute of the class. A short-form (which might not |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
735 be supported in future version of the API) is to specify only the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
736 value, e.g. ``/data/status/closed``. This short-form only works when |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
737 you're sure that the key of the class is not numeric. E.G. if the name |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
738 was "7", /data/status/7 would return the status with id 7 not the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
739 status with name "7". To get the status with name 7, you must use |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
740 the long form /data/status/name=7 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
741 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
742 The long-form (with ``=``) is different from a query-parameter like |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
743 ``/data/status?name=closed`` which would find all stati (statuses) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
744 that have ``closed`` as a substring. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
745 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
746 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
747 Other Supported Methods for Items |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
748 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
749 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
750 The method ``PUT`` is allowed on individual items, e.g. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
751 ``/data/issue/42`` On success it returns the same parameters as the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
752 respective ``GET`` method. Note that for ``PUT`` an Etag has to be |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
753 supplied, either in the request header or as an @etag parameter. An |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
754 example:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
755 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
756 curl -u admin:admin -X PUT \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
757 --header 'Referer: https://example.com/demo/' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
758 --header 'X-Requested-With: rest' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
759 --header "Content-Type: application/json" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
760 --header "Accept: application/json" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
761 --header 'If-Match: "dd41f02d6f8b4c34b439fc712b522fb3"' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
762 --data '{ "nosy": [ "1", "5" ] }' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
763 "https://example.com/demo/rest/data/issue/23" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
764 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
765 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
766 "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
767 "attribute": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
768 "nosy": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
769 "1", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
770 "5" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
771 ] |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
772 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
773 "type": "issue", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
774 "link": |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
775 "https://example.com/demo/rest/data/issue/23", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
776 "id": "23" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
777 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
778 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
779 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
780 If the above command is repeated with the data attribute:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
781 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
782 --data '{ "nosy": [ "1", "5" ], "title": "This is now my title" }' |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
783 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
784 this is returned:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
785 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
786 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
787 "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
788 "attribute": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
789 "title": "This is now my title" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
790 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
791 "type": "issue", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
792 "link": |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
793 "https://rouilj.dynamic-dns.net/demo/rest/data/issue/23", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
794 "id": "23" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
795 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
796 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
797 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
798 Note that nosy is not in the attributes returned. It is the same as |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
799 before, so no change has happened and it is not reported. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
800 Changing both nosy and title:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
801 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
802 curl -u admin:admin -X PUT \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
803 --header 'Referer: https://.../' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
804 --header 'X-Requested-With: rest' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
805 --header "Content-Type: application/json" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
806 --header "Accept: application/json" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
807 --header 'If-Match: "8209add59a79713d64f4d1a072aef740"' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
808 --data '{ "nosy": [ "4", "5" ], "title": "This is now my new title" }' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
809 "https://rouilj.dynamic-dns.net/demo/rest/data/issue/23" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
810 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
811 which returns both title and nosy attributes:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
812 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
813 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
814 "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
815 "attribute": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
816 "title": "This is now my new title", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
817 "nosy": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
818 "4", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
819 "5" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
820 ] |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
821 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
822 "type": "issue", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
823 "link": |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
824 "https://rouilj.dynamic-dns.net/demo/rest/data/issue/23", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
825 "id": "23" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
826 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
827 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
828 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
829 Note that mixing url query parameters with payload submission doesn't |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
830 work. So using:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
831 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
832 https://.../rest/data/issue/23?@pretty=false |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
833 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
834 doesn't have the desired effect. However it can be put in the data |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
835 payload: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
836 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
837 curl -u admin:admin ... |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
838 --data '{ "nosy": [ "4", "5" ], "title": "...", "@pretty": "false" }' |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
839 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
840 produces:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
841 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
842 {"data": {"attribute": {}, "type": "issue", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
843 "link": "https://...", "id": "23"}} |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
844 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
845 the lines are wrapped for display purposes, in real life it's one long |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
846 line. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
847 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
848 The method ``DELETE`` is allowed on items, e.g., ``/data/issue/42`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
849 and will retire (mark as deleted) the respective item. On success it |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
850 will only return a status code. The item is still available if |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
851 accessed directly by it's item url. The item will not show up in |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
852 searches where it would have been matched if not retired. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
853 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
854 Finally the ``PATCH`` method can be applied to individual items, e.g., |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
855 ``/data/issue/42``. This method gets an operator ``@op=<method>`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
856 where ``<method>`` is one of ``add``, ``replace``, ``remove``. For |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
857 items, an additional operator ``action`` is supported. If no operator |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
858 is specified, the default is ``replace``. The first three operators |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
859 are self explanatory. For an ``action`` operator an ``@action_name`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
860 and optional ``@action_argsXXX`` parameters have to be |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
861 supplied. Currently there are only two actions, neither has args, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
862 namely ``retire`` and ``restore``. The ``retire`` action on an item is |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
863 the same as a ``DELETE`` method, it retires the item. The ``restore`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
864 action is the inverse of ``retire``, the item is again visible. On |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
865 success the returned value is the same as the respective ``GET`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
866 method. An example to add a user to the nosy list of an item is: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
867 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
868 curl -u admin:admin -p -X PATCH \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
869 --header "Content-Type: application/x-www-form-urlencoded" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
870 --header "Accept: application/json" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
871 --header 'If-Match: "c6e2d81019acff1da7a2da45f93939bd"' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
872 --data-urlencode '@op=add' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
873 --data 'nosy=3' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
874 "https://.../rest/data/issue/23" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
875 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
876 which returns:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
877 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
878 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
879 "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
880 "attribute": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
881 "nosy": [ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
882 "3", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
883 "4" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
884 ] |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
885 }, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
886 "type": "issue", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
887 "link": "https://.../rest/data/issue/23", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
888 "id": "23" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
889 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
890 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
891 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
892 Note that the changed values are returned so you can update |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
893 internal state in your app with the new data. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
894 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
895 The ``GET`` method on an item (e.g. ``/data/issue/43``) returns an |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
896 ETag in the http header *and* the ``@etag`` value in the json |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
897 payload. When modifying a property via ``PUT`` or ``PATCH`` or |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
898 ``DELETE`` the etag value for the item must be supplied using an |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
899 ``If-Match`` header. If you are using ``PUT`` or ``PATCH`` an |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
900 ``@etag`` value can be supplied in the payload in place of the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
901 ``If-Match`` header. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
902 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
903 /data/\ *class*/\ *id*/\ *property* field |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
904 ========================================= |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
905 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
906 A ``GET`` method on a property (e.g. ``/data/issue/42/title``) returns the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
907 link, an ``@etag``, the type of the property (e.g. "<type str>") the id |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
908 of the item and the content of the property in ``data``. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
909 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
910 For example:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
911 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
912 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
913 "data": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
914 "link": "https://.../rest/data/issue/22/title", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
915 "data": "I need Broken PC", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
916 "type": "<class 'str'>", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
917 "id": "22", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
918 "@etag": "\"370510512b2d8fc3f98aac3d762cc7b1\"" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
919 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
920 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
921 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
922 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
923 All endpoints support an ``OPTIONS`` method for determining which |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
924 methods are allowed on a given endpoint. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
925 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
926 Other Supported Methods for fields |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
927 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
928 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
929 The method ``PUT`` is allowed on a property e.g., |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
930 ``/data/issue/42/title``. On success it returns the same parameters as |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
931 the respective ``GET`` method. Note that for ``PUT`` an Etag has to be |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
932 supplied, either in the request header or as an @etag parameter. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
933 Example using multipart/form-data rather than json:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
934 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
935 curl -vs -u provisional:provisional -X PUT \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
936 --header "Accept: application/json" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
937 --data "data=Provisional" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
938 --header "If-Match: 079eba599152f3eed00567e23258fecf" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
939 --data-urlencode "@etag=079eba599152f3eed00567e23258fecf" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
940 "https://.../rest/data/user/5/realname" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
941 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
942 This example updates a leadtime field that is declared as an interval |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
943 type:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
944 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
945 curl -vs -u demo:demo -X PUT \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
946 --header "Accept: application/json" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
947 --header 'Content-Type: application/json' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
948 --header "Referer: https://.../" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
949 --header "x-requested-with: rest" \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
950 --header 'If-Match: "e2e6cc43c3475a4a3d9e5343617c11c3"' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
951 --data '{"leadtime": "2d" }' \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
952 "https://.../rest/data/issue/10" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
953 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
954 It is also possible to call ``DELETE`` on a |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
955 property of an item, e.g., ``/data/issue/42/nosy`` to delete the nosy |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
956 list. The same effect can be achieved with a ``PUT`` request and an |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
957 empty new value. This may fail if the property is required. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
958 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
959 The ``PATCH`` method can be applied to properties, e.g., |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
960 ``/data/issue/42/title``. This method gets an operator |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
961 ``@op=<method>`` where ``<method>`` is one of ``add``, ``replace``, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
962 ``remove``. If no operator is specified, the default is ``replace`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
963 which is the same as performing a PUT on the field url. ``add`` and |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
964 ``remove`` allow ading and removing values from MultiLink |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
965 properties. This is easier than having to rewrite the entire value for |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
966 the field using the ``replace`` operator or doing a PUT to the field. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
967 On success the returned value is the same as the respective ``GET`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
968 method. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
969 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
970 The ``GET`` method on an item (e.g. ``/data/issue/43``) returns an |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
971 ETag in the http header *and* the ``@etag`` value in the json |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
972 payload. When modifying a property via ``PUT`` or ``PATCH`` or |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
973 ``DELETE`` the etag value for the item must be supplied using an |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
974 ``If-Match`` header. If you are using ``PUT`` or ``PATCH`` an |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
975 ``@etag`` value can be supplied in the payload in place of the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
976 ``If-Match`` header. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
977 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
978 Tunneling Methods via POST |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
979 ========================== |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
980 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
981 If you are working through a proxy and unable to use http method like |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
982 PUT, PATCH or DELETE you can use POST to perform the action. To tunnel |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
983 an action throught POST, send the ``X-HTTP-METHOD-OVERRIDE`` header |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
984 with a value of DELETE or other capitalized HTTP verb. The body of the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
985 POST should be what you would send if you were using the method |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
986 without tunneling. |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
987 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
988 Examples and Use Cases |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
989 ---------------------- |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
990 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
991 sample python client |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
992 ==================== |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
993 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
994 The client uses the python ``requests`` library for easier interaction |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
995 with a REST API supporting JSON encoding:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
996 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
997 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
998 >>> import requests |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
999 >>> u = 'http://user:password@tracker.example.com/demo/rest/data/' |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1000 >>> s = requests.session() |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1001 >>> r = s.get(u + 'issue/42/title') |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1002 >>> if r.status_code != 200: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1003 ... print("Failed: %s: %s" % (r.status_code, r.reason)) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1004 ... exit(1) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1005 >>> print (r.json() ['data']['data'] |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1006 TEST Title |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1007 >>> h = {'X-Requested-With': 'rest', 'Referer': 'http://tracker.example.com/demo/'} |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1008 >>> r = s.post (u + 'issue', data = dict (title = 'TEST Issue'), headers=h) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1009 >>> if not 200 <= r.status_code <= 201: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1010 ... print("Failed: %s: %s" % (r.status_code, r.reason)) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1011 ... exit(1) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1012 >>> print(r.json()) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1013 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1014 Retire/Restore:: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1015 >>> r = s.delete (u + 'issue/42') |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1016 >>> print (r.json()) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1017 >>> r = s.get (u + 'issue/42') |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1018 >>> etag = r.headers['ETag'] |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1019 >>> print("ETag: %s" % etag) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1020 >>> etag = r.json()['data']['@etag'] |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1021 >>> print("@etag: %s" % etag) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1022 >>> h = {'If-Match': etag, |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1023 ... 'X-Requested-With': 'rest', |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1024 ... 'Referer': 'http://tracker.example.com/demo/'} |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1025 >>> d = {'@op:'action', '@action_name':'retire'} |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1026 >>> r = s.patch(u + 'issue/42', data = d, headers = h) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1027 >>> print(r.json()) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1028 >>> d = {'@op:'action', '@action_name':'restore'} |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1029 >>> r = s.patch(u + 'issue/42', data = d, headers = h) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1030 >>> print(r.json()) |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1031 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1032 Note the addition of headers for: x-requested-with and referer. This |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1033 allows the request to pass the CSRF protection mechanism. You may need |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1034 to add an Origin header if this check is enabled in your tracker's |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1035 config.ini (look for csrf_enforce_header_origin). |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1036 |
|
5695
3e1b66c4e1e2
Update docs. Correct errors reported by setup.py build_docs. Add rest
John Rouillard <rouilj@ieee.org>
parents:
5688
diff
changeset
|
1037 |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1038 Searches and selection |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1039 ====================== |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1040 |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1041 One difficult interface issue is selection of items from a long list. |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1042 Using multi-item selects requires loading a lot of data (e.g. consider |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1043 a selection tool to select one or more issues as in the classic |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1044 superseder field). |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1045 |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1046 This can be made easier using javascript selection tools like select2, |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1047 selectize.js, chosen etc. These tools can query a remote data provider |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1048 to get a list of items for the user to select from. |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1049 |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1050 Consider a multi-select box for the superseder property. Using |
|
5695
3e1b66c4e1e2
Update docs. Correct errors reported by setup.py build_docs. Add rest
John Rouillard <rouilj@ieee.org>
parents:
5688
diff
changeset
|
1051 selectize.js (and jquery) code similar to:: |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1052 |
|
5695
3e1b66c4e1e2
Update docs. Correct errors reported by setup.py build_docs. Add rest
John Rouillard <rouilj@ieee.org>
parents:
5688
diff
changeset
|
1053 $('#superseder').selectize({ |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1054 valueField: 'id', |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1055 labelField: 'title', |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1056 searchField: 'title', ... |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1057 load: function(query, callback) { |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1058 if (!query.length) return callback(); |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1059 $.ajax({ |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1060 url: '.../rest/data/issue?@verbose=2&title=' |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1061 + encodeURIComponent(query), |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1062 type: 'GET', |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1063 error: function() {callback();}, |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1064 success: function(res) { |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1065 callback(res.data.collection);} |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1066 |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1067 Sets up a box that a user can type the word "request" into. Then |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1068 selectize.js will use that word to generate an ajax request with the |
|
5695
3e1b66c4e1e2
Update docs. Correct errors reported by setup.py build_docs. Add rest
John Rouillard <rouilj@ieee.org>
parents:
5688
diff
changeset
|
1069 url: ``.../rest/data/issue?@verbose=2&title=request`` |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1070 |
|
5695
3e1b66c4e1e2
Update docs. Correct errors reported by setup.py build_docs. Add rest
John Rouillard <rouilj@ieee.org>
parents:
5688
diff
changeset
|
1071 This will return data like:: |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1072 |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1073 { |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1074 "data": { |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1075 "@total_size": 440, |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1076 "collection": [ |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1077 { |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1078 "link": ".../rest/data/issue/8", |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1079 "id": "8", |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1080 "title": "Request for Power plugs" |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1081 }, |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1082 { |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1083 "link": ".../rest/data/issue/27", |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1084 "id": "27", |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1085 "title": "Request for foo" |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1086 }, |
|
5695
3e1b66c4e1e2
Update docs. Correct errors reported by setup.py build_docs. Add rest
John Rouillard <rouilj@ieee.org>
parents:
5688
diff
changeset
|
1087 ... |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1088 |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1089 selectize.js will look at these objects (as passed to |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1090 callback(res.data.collection)) and create a select list from the each |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1091 object showing the user the labelField (title) for each object and |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1092 associating each title with the corresponding valueField (id). The |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1093 example above has 440 issues returned from a total of 2000 |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1094 issues. Only 440 had the word "request" somewhere in the title greatly |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1095 reducing the amount of data that needed to be transferred. |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1096 |
|
5695
3e1b66c4e1e2
Update docs. Correct errors reported by setup.py build_docs. Add rest
John Rouillard <rouilj@ieee.org>
parents:
5688
diff
changeset
|
1097 Similar code can be set up to search a large list of keywords using:: |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1098 |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1099 .../rest/data/keyword?@verbose=2&name=some |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1100 |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1101 which would return: "some keyword" "awesome" "somebody" making |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1102 selections for links and multilinks much easier. |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1103 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1104 A get on a collection endpoint can include other properties. Why do we |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1105 want this? Selectize.js can set up option groups (optgroups) in the |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1106 select pulldown. So by including status in the returned data using |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1107 a url like ``https://.../rest/data/issue?@verbose=2&@fields=status`` |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1108 we get:: |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1109 |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1110 { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1111 "link": "https://.../rest/data/issue/1001", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1112 "title": "Request for Broken PC", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1113 "id": "1001", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1114 "status": { |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1115 "link": "https://.../rest/data/status/6", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1116 "id": "6", |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1117 "name": "resolved" |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1118 } |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1119 } |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1120 |
|
5695
3e1b66c4e1e2
Update docs. Correct errors reported by setup.py build_docs. Add rest
John Rouillard <rouilj@ieee.org>
parents:
5688
diff
changeset
|
1121 a select widget like:: |
|
5677
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1122 |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1123 === New === |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1124 A request |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1125 === Open === |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1126 Request for bar |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1127 Request for foo |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1128 |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1129 etc. can be generated. Also depending on the javascript library, other |
|
1fa59181ce58
Add support for @verbose=2 to a GET on a collection object. Using this
John Rouillard <rouilj@ieee.org>
parents:
5674
diff
changeset
|
1130 fields can be used for subsearch and sorting. |
|
5710
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1131 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1132 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1133 Programming the REST API |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1134 ------------------------ |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1135 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1136 You can extend the rest api for a tracker. This describes how to add |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1137 new rest end points. At some point it will also describe the rest.py |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1138 structure and implementation. |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1139 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1140 Adding new rest endpoints |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1141 ========================= |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1142 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1143 Add or edit the file interfaces.py at the root of the tracker |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1144 directory. |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1145 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1146 In that file add:: |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1147 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1148 from roundup.rest import Routing, RestfulInstance, _data_decorator |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1149 from roundup.exceptions import Unauthorised |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1150 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1151 class RestfulInstance: |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1152 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1153 @Routing.route("/summary2") |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1154 @_data_decorator |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1155 def summary2(self, input): |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1156 result = { "hello": "world" } |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1157 return 200, result |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1158 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1159 will make a new endpoint .../rest/summary2 that you can test with:: |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1160 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1161 $ curl -X GET .../rest/summary2 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1162 { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1163 "data": { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1164 "hello": "world" |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1165 } |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1166 } |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1167 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1168 Similarly appending this to interfaces.py after summary2:: |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1169 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1170 # handle more endpoints |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1171 @Routing.route("/data/<:class_name>/@schema", 'GET') |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1172 def get_element_schema(self, class_name, input): |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1173 result = { "schema": {} } |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1174 uid = self.db.getuid () |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1175 if not self.db.security.hasPermission('View', uid, class_name) : |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1176 raise Unauthorised('Permission to view %s denied' % class_name) |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1177 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1178 class_obj = self.db.getclass(class_name) |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1179 props = class_obj.getprops(protected=False) |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1180 schema = result['schema'] |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1181 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1182 for prop in props: |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1183 schema[prop] = { "type": repr(class_obj.properties[prop]) } |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1184 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1185 return result |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1186 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1187 .. |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1188 the # comment in the example is needed to preserve indention under Class. |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1189 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1190 returns some data about the class:: |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1191 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1192 $ curl -X GET .../rest/data/issue/@schema |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1193 { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1194 "schema": { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1195 "keyword": { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1196 "type": "<roundup.hyperdb.Multilink to \"keyword\">" |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1197 }, |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1198 "title": { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1199 "type": "<roundup.hyperdb.String>" |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1200 }, |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1201 "files": { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1202 "type": "<roundup.hyperdb.Multilink to \"file\">" |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1203 }, |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1204 "status": { |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1205 "type": "<roundup.hyperdb.Link to \"status\">" |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1206 }, ... |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1207 } |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1208 } |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1209 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1210 |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1211 Adding other endpoints (e.g. to allow an OPTIONS query against |
|
0b79bfcb3312
Add support for making an idempotent POST. This allows retrying a POST
John Rouillard <rouilj@ieee.org>
parents:
5698
diff
changeset
|
1212 ``/data/issue/@schema``) is left as an exercise for the reader. |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1213 |
|
5737
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1214 Creating Custom Rate Limits |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1215 =========================== |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1216 |
|
5738
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1217 You can replace the default rate limiter that is configured using |
|
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1218 the tracker's ``config.ini``. You can return different rate |
|
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1219 limits based on the user, time of day, phase of moon etc. |
|
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1220 |
|
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1221 Assume you add two integer valued properties to the user |
|
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1222 object. Let's call them ``rate_limit_interval`` and |
|
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1223 ``rate_limit_calls``. Add code similar to this to interfaces.py |
|
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1224 to override the default rate limiter code:: |
|
5737
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1225 |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1226 from roundup.rest import RestfulInstance, RateLimit |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1227 from datetime import timedelta |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1228 |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1229 def grl(self): |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1230 calls = self.db.config.WEB_API_CALLS_PER_INTERVAL |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1231 interval = self.db.config.WEB_API_INTERVAL_IN_SEC |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1232 |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1233 if calls and interval: # use to disable all rate limits |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1234 |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1235 uid = self.db.getuid() |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1236 class_obj = self.db.getclass('user') |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1237 node = class_obj.getnode(uid) |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1238 |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1239 # set value to 0 to use WEB_API_CALLS_PER_INTERVAL |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1240 user_calls = node.__getattr__('rate_limit_calls') |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1241 # set to 0 to use WEB_API_INTERVAL_IN_SEC |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1242 user_interval = node.__getattr__('rate_limit_interval') |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1243 |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1244 return RateLimit(user_calls or calls, |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1245 timedelta(seconds=(user_interval or interval))) |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1246 else: |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1247 # disable rate limiting if either parameter is 0 |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1248 return None |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1249 |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1250 RestfulInstance.getRateLimit = grl |
|
07d8bbf6ee5f
Add example on overriding RestfulInstance.getRateLimit from interfaces.py.
John Rouillard <rouilj@ieee.org>
parents:
5723
diff
changeset
|
1251 |
|
5738
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1252 this should replace the default getRateLimit with the new grl |
|
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1253 function. This new function uses values for the number of calls |
|
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1254 and period that are specific to a user. If either is set to 0, |
|
9777d7311bc0
Clean up the custom rate limit doc.
John Rouillard <rouilj@ieee.org>
parents:
5737
diff
changeset
|
1255 the defaults from ``config.ini`` file are used. |
|
5723
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1256 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1257 Test Examples |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1258 ============= |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1259 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1260 Rate limit tests: |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1261 |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1262 seq 1 300 | xargs -P 20 -n 1 curl --head -si \ |
|
59a3bbd3603a
Expanded documentation. More examples, added sections based on each
John Rouillard <rouilj@ieee.org>
parents:
5710
diff
changeset
|
1263 https://.../rest/data/status/new \# | grep Remaining |
