|
1 |
| -Design of APIv3 |
2 |
| -=============== |
| 1 | +======================= |
| 2 | + APIv3 Design Document |
| 3 | +======================= |
| 4 | + |
| 5 | +This document describes the design, |
| 6 | +some decisions already made and built (current Version 1 of APIv3) |
| 7 | +and an implementation plan for next Versions of APIv3. |
3 | 8 |
|
4 | 9 | APIv3 will be designed to be easy to use and useful to perform read and write operations as the main two goals.
|
5 | 10 |
|
6 | 11 | It will be based on Resources as APIv2 but considering the ``Project`` resource as the main one,
|
7 | 12 | from where most of the endpoint will be based on it.
|
8 | 13 |
|
| 14 | +.. contents:: |
| 15 | + :local: |
| 16 | + :backlinks: none |
| 17 | + :depth: 1 |
9 | 18 |
|
10 |
| -Problems with APIv2 |
11 |
| -------------------- |
12 |
| - |
13 |
| - |
14 |
| -* No authentication |
15 |
| -* It's read-only |
16 |
| -* Not designed for slugs |
17 |
| -* Useful APIs not exposed (only for internal usage currently) |
18 |
| -* Error reporting is a mess |
19 |
| -* Relationships between API resources is not obvious |
20 |
| -* Footer API endpoint returns HTML |
21 |
| - |
22 |
| - |
23 |
| -Proposed improves |
24 |
| -+++++++++++++++++ |
25 |
| - |
26 |
| - |
27 |
| -Use authentication |
28 |
| -~~~~~~~~~~~~~~~~~~ |
29 |
| - |
30 |
| -* Pros: |
31 |
| - |
32 |
| - * queries can be personalized depending on the user |
33 |
| - * allows us to perform write actions |
34 |
| - |
35 |
| -* Cons: |
36 |
| - |
37 |
| - * harder to implement |
38 |
| - * requires a lot of time for good testing and QA |
39 |
| - |
40 |
| - |
41 |
| -Questions: |
42 |
| - |
43 |
| -#. Do we want make auth a requirement? |
44 |
| -#. Should we expose some endpoints as Read Only if not authenticated? |
45 |
| -#. How we do communicate users about deprecation if they are Anonymous? Is it enough to add a note in the docs saying that "Auth is preferred for communication"? |
46 |
| -#. How are we going to expose the ``Token`` required for Auth when building if auth is mandatory? |
47 |
| - |
48 |
| - |
49 |
| -Read and Write |
50 |
| -~~~~~~~~~~~~~~ |
51 | 19 |
|
52 |
| -* Pros: |
| 20 | +Goals |
| 21 | +----- |
53 | 22 |
|
54 |
| - * most of the actions can be performed by a script instead of by |
55 |
| - accessing readthedocs.org with a browser |
| 23 | +* Easy to use for our users (access most of resources by ``slug``) |
| 24 | +* Useful to perform read and write operations |
| 25 | +* Authentication/Authorization |
56 | 26 |
|
57 |
| -* Cons: |
| 27 | + * Authentication based on scoped-tokens |
| 28 | + * Handle Authorization nicely using an abstraction layer |
58 | 29 |
|
59 |
| - * we have to deal with authorization |
60 |
| - * open the door to possibilities of security holes |
| 30 | +* Cover most useful cases: |
61 | 31 |
|
| 32 | + * Integration on CI (check build status, trigger new build, etc) |
| 33 | + * Usage from public Sphinx/MkDocs extensions |
| 34 | + * Allow creation of flyout menu client-side |
| 35 | + * Simplify migration from other services (import projects, create multiple redirects, etc) |
62 | 36 |
|
63 |
| -Questions: |
64 | 37 |
|
65 |
| -#. Do we want to allow the user to perform **all the write actions** |
66 |
| - that are possible to do from the dashboard via the API? |
67 |
| - |
68 |
| - |
69 |
| -Design it for slugs |
70 |
| -~~~~~~~~~~~~~~~~~~~ |
71 |
| - |
72 |
| -* Pros: |
73 |
| - |
74 |
| - * knowing the slug of your project (which is presented to the user) |
75 |
| - you can perform all the actions or retrieve all the data |
76 |
| - |
77 |
| -* Cons: |
78 |
| - |
79 |
| - * it will be a mixture between most of the endpoint using ``slug`` |
80 |
| - and to retrieve details of a Build it will be an ``id`` |
81 |
| - |
82 |
| - |
83 |
| -Expose internal endpoints |
84 |
| -~~~~~~~~~~~~~~~~~~~~~~~~~ |
85 |
| - |
86 |
| -There are some endpoints that we are using internally like |
87 |
| -``/api/v2/search/``, ``/api/v2/footer/`` and |
88 |
| -``/api/v2/sustainability/``. |
89 |
| - |
90 |
| - |
91 |
| -* Pros: |
92 |
| - |
93 |
| - * allow to build custom footer |
94 |
| - * allow to build custom search autocomplete widget |
95 |
| - |
96 |
| -* Cons: |
| 38 | +Non-Goals |
| 39 | +--------- |
97 | 40 |
|
98 |
| - * n/a |
| 41 | +* Filter by arbitrary and non-useful fields |
99 | 42 |
|
100 |
| -Questions: |
| 43 | + * "Builds with ``exit_code=1``" |
| 44 | + * "Builds containing ``ERROR`` on their output" |
| 45 | + * "Projects created after X datetime" |
| 46 | + * "Versions with tag ``python``" |
101 | 47 |
|
102 |
| -#. Do we want to add ``/api/v2/sustainability/`` to APIv3 or that |
103 |
| - should be part of the new Ad Server that we are building? |
| 48 | +* Cover *all the actions* available from the WebUI |
104 | 49 |
|
105 | 50 |
|
106 |
| -Proper status codes for error reporting |
107 |
| -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 51 | +Problems with APIv2 |
| 52 | +------------------- |
108 | 53 |
|
109 |
| -* Pros: |
| 54 | +There are several problem with our current APIv2 that we can list: |
110 | 55 |
|
111 |
| - * user knows what it's happening and can take decisions about it |
| 56 | +* No authentication |
| 57 | +* It's read-only |
| 58 | +* Not designed for slugs |
| 59 | +* Useful APIs not exposed (only for internal usage currently) |
| 60 | +* Error reporting is a mess |
| 61 | +* Relationships between API resources is not obvious |
| 62 | +* Footer API endpoint returns HTML |
112 | 63 |
|
113 |
| -* Cons: |
114 | 64 |
|
115 |
| - * n/a |
| 65 | +Implementation stages |
| 66 | +--------------------- |
116 | 67 |
|
| 68 | +Version 1 |
| 69 | ++++++++++ |
117 | 70 |
|
118 |
| -Relationship between API resources |
119 |
| -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 71 | +The first implementation of APIv3 will cover the following aspects: |
120 | 72 |
|
121 |
| -* Pros: |
| 73 | +.. note:: |
122 | 74 |
|
123 |
| - * browse-able API by accessing to the default resource (Project) |
124 |
| - * knowing the project's slug you can perform all the actions related to it |
| 75 | + This is currently implemented and live. Although, it's only for internal testing. |
125 | 76 |
|
126 |
| -* Cons: |
| 77 | +* Authentication |
127 | 78 |
|
128 |
| - * more data is returned with all the links to the endpoints |
| 79 | + * all endpoints require authentication via ``Authorization:`` request header |
| 80 | + * detail endpoints are available for all authenticated users |
| 81 | + * only Project's maintainers can access listing endpoints |
| 82 | + * personalized listing |
129 | 83 |
|
| 84 | +* Read and Write |
130 | 85 |
|
131 |
| -Make footer API returns JSON |
132 |
| -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 86 | + * edit attributes from Version (only ``active`` and ``privacy_level``) |
| 87 | + * trigger Build for a specific Version |
133 | 88 |
|
134 |
| -* Pros: |
| 89 | +* Accessible by slug |
135 | 90 |
|
136 |
| - * users can build their own version menu flyout |
137 |
| - * cleaner than returning a HTML and injecting it |
| 91 | + * Projects are accessed by ``slug`` |
| 92 | + * Versions are accessed by ``slug`` |
| 93 | + * ``/projects/`` endpoint is the main one and all of the other are nested under it |
| 94 | + * Builds are accessed by ``id``, as exception to this rule |
| 95 | + * access all (active/non-active) Versions of a Project by ``slug`` |
| 96 | + * get latest Build for a Project (and Version) by ``slug`` |
| 97 | + * filter by relevant fields |
138 | 98 |
|
139 |
| -* Cons: |
| 99 | +* Proper status codes to report errors |
140 | 100 |
|
141 |
| - * we need to adapt our theme for this |
| 101 | +* Browse-able endpoints |
142 | 102 |
|
| 103 | + * browse is allowed hitting ``/api/v3/projects/`` as starting point |
| 104 | + * ability to navigate clicking on other resources under ``_links`` attribute |
143 | 105 |
|
144 |
| -Questions: |
| 106 | +* Rate limited |
145 | 107 |
|
146 |
| -#. Do we want an specific endpoint for the footer? |
147 |
| -#. The flyout could be built by querying 2 or 3 of the regular |
148 |
| - endpoint. Would this add too much overhead to the page loading |
149 |
| - time? |
150 | 108 |
|
| 109 | +Version 2 |
| 110 | ++++++++++ |
151 | 111 |
|
152 |
| -Use cases |
153 |
| ---------- |
| 112 | +Second iteration will polish issues found from the first step, |
| 113 | +and add new endpoints to allow *import a project and configure it* |
| 114 | +without the needed of using the WebUI as a main goal. |
154 | 115 |
|
155 |
| -We want to cover |
156 |
| -++++++++++++++++ |
| 116 | +After Version 2 is deployed, |
| 117 | +we will invite users that reach us as beta testers to receive more feedback |
| 118 | +and continue improving it by supporting more use cases. |
157 | 119 |
|
| 120 | +This iteration will include: |
158 | 121 |
|
159 |
| -* Return all **my** projects |
160 |
| -* Access all the resources by knowing the project's slug |
161 |
| -* Ability to filter by fields |
| 122 | +* Minor changes to fields returned in the objects |
| 123 | +* Import Project endpoint |
| 124 | +* Edit Project attributes ("Settings" and "Advanced settings-Global settings" in the WebUI) |
| 125 | +* Trigger Build for default version |
| 126 | +* Allow CRUD for Redirect, Environment Variables and Notifications (``WebHook`` and ``EmailHook``) |
| 127 | +* Documentation |
162 | 128 |
|
163 |
| - * all the active versions of specific project |
164 | 129 |
|
165 |
| -* Data about builds |
| 130 | +Version 3 |
| 131 | ++++++++++ |
166 | 132 |
|
167 |
| - * latest build for project |
168 |
| - * latest build for a particular version of a project |
169 |
| - * status of a particular build |
| 133 | +Third iteration will implement granular permissions. |
| 134 | +Keeping in mind how Sphinx extension will use it: |
170 | 135 |
|
171 |
| -* Perform write actions like |
| 136 | +* ``sphinx-version-warning`` needs to get *all active Versions of a Project* |
| 137 | +* An extension that creates a landing page, will need *all the subprojects of a Project* |
172 | 138 |
|
173 |
| - * add a Domain, |
174 |
| - * add User as mantainer, |
175 |
| - * import a new Project under my username, |
176 |
| - * set the language of the Project, |
177 |
| - * trigger a Build, |
178 |
| - * activate/deactivate a Version to be built, |
179 |
| - * and all the actions you can perform from the Admin tab. |
| 139 | +To fulfill these requirements, this iteration will include: |
180 | 140 |
|
181 |
| -* Retrieve all the information needed to create a custom version menu flyout |
| 141 | +* Scope-based authorization token |
182 | 142 |
|
183 | 143 |
|
184 |
| -Considering some useful cases for the corporate site: |
| 144 | +Version 4 |
| 145 | ++++++++++ |
185 | 146 |
|
186 |
| -* Give access to a doc page (``objects.inv``, ``/design/core.html``) |
| 147 | +* Specific endpoint for our flyout menu (returning JSON instead of HTML) |
187 | 148 |
|
188 | 149 |
|
189 |
| -We do NOT want to cover |
190 |
| -+++++++++++++++++++++++ |
| 150 | +Out of roadmap |
| 151 | +-------------- |
191 | 152 |
|
192 |
| -* Random filtering over a whole and not useful Resource |
| 153 | +These are some features that we may want to build at some point. |
| 154 | +Although, they are currently out of our near roadmap because they don't affect too many users, |
| 155 | +or are for internal usage only. |
193 | 156 |
|
194 |
| - * "All the ``stable`` versions" |
195 |
| - * "Builds with ``exit_code`` equal to 257" |
| 157 | +* CRUD for Domain |
| 158 | +* Add User as maintainer |
| 159 | +* Give access to a documentation page (``objects.inv``, ``/design/core.html``) |
| 160 | +* Internal Build process |
196 | 161 |
|
197 | 162 |
|
198 |
| -Technical aspects that would be good to have |
199 |
| --------------------------------------------- |
| 163 | +Nice to have |
| 164 | +------------ |
200 | 165 |
|
201 |
| -* Rate limit |
202 | 166 | * ``Request-ID`` header
|
203 | 167 | * `JSON minified by default`_ (maybe with ``?pretty=true``)
|
204 | 168 | * `JSON schema and validation`_ with docs_
|
|
0 commit comments