blob: 6919afd56f3ae727424a1665297fa4f517c77651 [file] [log] [blame]
Edwin Kempind0a63922013-01-23 16:32:59 +01001Gerrit Code Review - '/projects/' REST API
2==========================================
3
4This page describes the project related REST endpoints.
5Please also take note of the general information on the
6link:rest-api.html[REST API].
7
8Endpoints
9---------
10
Edwin Kempinc3fe3cb2013-02-13 15:09:23 +010011[[project-endpoints]]
12Project Endpoints
13-----------------
14
Edwin Kempin76202742013-02-15 13:51:50 +010015[[list-projects]]
Edwin Kempin82d30372013-02-04 08:49:34 +010016GET /projects/ (List Projects)
17~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Edwin Kempind0a63922013-01-23 16:32:59 +010018Lists the projects accessible by the caller. This is the same as
19using the link:cmd-ls-projects.html[ls-projects] command over SSH,
20and accepts the same options as query parameters.
21
Edwin Kempin51a6dc92013-02-04 15:43:59 +010022As result a map is returned that maps the project names to
23link:#project-info[ProjectInfo] entries. The entries in the map are sorted
24by project name.
25
Edwin Kempin37440832013-02-06 11:36:00 +010026.Request
Edwin Kempind0a63922013-01-23 16:32:59 +010027----
28 GET /projects/?d HTTP/1.0
Edwin Kempin37440832013-02-06 11:36:00 +010029----
Edwin Kempind0a63922013-01-23 16:32:59 +010030
Edwin Kempin37440832013-02-06 11:36:00 +010031.Response
32----
Edwin Kempind0a63922013-01-23 16:32:59 +010033 HTTP/1.1 200 OK
34 Content-Disposition: attachment
35 Content-Type: application/json;charset=UTF-8
36
37 )]}'
38 {
39 "external/bison": {
40 "kind": "gerritcodereview#project",
41 "id": "external%2Fbison",
42 "description": "GNU parser generator"
43 },
44 "external/gcc": {
45 "kind": "gerritcodereview#project",
46 "id": "external%2Fgcc",
47 },
48 "external/openssl": {
49 "kind": "gerritcodereview#project",
50 "id": "external%2Fopenssl",
51 "description": "encryption\ncrypto routines"
52 },
53 "test": {
54 "kind": "gerritcodereview#project",
55 "id": "test",
56 "description": "\u003chtml\u003e is escaped"
57 }
58 }
59----
60
Edwin Kempina64c4b92013-01-23 11:30:40 +010061.Get all projects with their description
62****
63get::/projects/?d
64****
65
Edwin Kempind0a63922013-01-23 16:32:59 +010066[[suggest-projects]]
67The `/projects/` URL also accepts a prefix string in the `p` parameter.
68This limits the results to those projects that start with the specified
69prefix.
70List all projects that start with `platform/`:
Edwin Kempin37440832013-02-06 11:36:00 +010071
72.Request
Edwin Kempind0a63922013-01-23 16:32:59 +010073----
74 GET /projects/?p=platform%2F HTTP/1.0
Edwin Kempin37440832013-02-06 11:36:00 +010075----
Edwin Kempind0a63922013-01-23 16:32:59 +010076
Edwin Kempin37440832013-02-06 11:36:00 +010077.Response
78----
Edwin Kempind0a63922013-01-23 16:32:59 +010079 HTTP/1.1 200 OK
80 Content-Disposition: attachment
81 Content-Type: application/json;charset=UTF-8
82
83 )]}'
84 {
85 "platform/drivers": {
86 "kind": "gerritcodereview#project",
87 "id": "platform%2Fdrivers",
88 },
89 "platform/tools": {
90 "kind": "gerritcodereview#project",
91 "id": "platform%2Ftools",
92 }
93 }
94----
95E.g. this feature can be used by suggestion client UI's to limit results.
96
Edwin Kempin57f303c2013-02-13 15:52:22 +010097[[get-project-description]]
98GET /projects/\{project-name\}/description (Get Project Description)
99~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100Retrieves the description of a project.
101
102.Request
103----
104 GET /projects/plugins%2Freplication/description HTTP/1.0
105----
106
107.Response
108----
109 HTTP/1.1 200 OK
110 Content-Disposition: attachment
111 Content-Type: application/json;charset=UTF-8
112
113 )]}'
114 "Copies to other servers using the Git protocol"
115----
116
Edwin Kempinefec4492013-02-22 10:09:23 +0100117If the project does not have a description an empty string is returned.
118
Edwin Kempin57f303c2013-02-13 15:52:22 +0100119[[set-project-description]]
120PUT /projects/\{project-name\}/description (Set Project Description)
121~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122Sets the description of a project.
123
124The new project description must be provided in the request body inside
125a link:#project-description-input[ProjectDescriptionInput] entity.
126
127.Request
128----
129 PUT /projects/plugins%2Freplication/description HTTP/1.0
130 Content-Type: application/json;charset=UTF-8
131
132 {
133 "description": "Plugin for Gerrit that handles the replication.",
134 "commit_message": "Update the project description"
135 }
136----
137
138As response the new project description is returned.
139
140.Response
141----
142 HTTP/1.1 200 OK
143 Content-Disposition: attachment
144 Content-Type: application/json;charset=UTF-8
145
146 )]}'
147 "Plugin for Gerrit that handles the replication."
148----
149
150[[delete-project-description]]
151DELETE /projects/\{project-name\}/description (Delete Project Description)
152~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
153Deletes the description of a project.
154
Edwin Kempinefec4492013-02-22 10:09:23 +0100155The request body does not need to include a
156link:#project-description-input[ProjectDescriptionInput] entity if no
157commit message is specified.
Edwin Kempin57f303c2013-02-13 15:52:22 +0100158
Edwin Kempinefec4492013-02-22 10:09:23 +0100159Please note that some proxies prohibit request bodies for DELETE
Edwin Kempin57f303c2013-02-13 15:52:22 +0100160requests. In this case, if you want to specify a commit message, use
161link:#set-project-description[PUT] to delete the description.
162
163.Request
164----
165 DELETE /projects/plugins%2Freplication/description HTTP/1.0
166----
167
168.Response
169----
170 HTTP/1.1 204 No Content
171----
172
Edwin Kempinecad88c2013-02-14 12:09:44 +0100173[[get-project-parent]]
174GET /projects/\{project-name\}/parent (Get Project Parent)
175~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
176Retrieves the name of a project's parent project. For the
177`All-Projects` root project an empty string is returned.
178
179.Request
180----
181 GET /projects/plugins%2Freplication/parent HTTP/1.0
182----
183
184.Response
185----
186 HTTP/1.1 200 OK
187 Content-Disposition: attachment
188 Content-Type: application/json;charset=UTF-8
189
190 )]}'
191 "All-Projects"
192----
193
194[[set-project-parent]]
195PUT /projects/\{project-name\}/parent (Set Project Parent)
196~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
197Sets the parent project for a project.
198
199The new name of the parent project must be provided in the request body
200inside a link:#project-parent-input[ProjectParentInput] entity.
201
202.Request
203----
204 PUT /projects/plugins%2Freplication/parent HTTP/1.0
205 Content-Type: application/json;charset=UTF-8
206
207 {
208 "parent": "Public-Plugins",
209 "commit_message": "Update the project parent"
210 }
211----
212
213As response the new parent project name is returned.
214
215.Response
216----
217 HTTP/1.1 200 OK
218 Content-Disposition: attachment
219 Content-Type: application/json;charset=UTF-8
220
221 )]}'
222 "Public-Plugins"
223----
224
Edwin Kempinc3fe3cb2013-02-13 15:09:23 +0100225[[dashboard-endpoints]]
226Dashboard Endpoints
227-------------------
228
Edwin Kempin76202742013-02-15 13:51:50 +0100229[[list-dashboards]]
Edwin Kempin7fe2f7f2013-02-06 10:12:52 +0100230GET /projects/\{project-name\}/dashboards/ (List Dashboards)
231~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Edwin Kempind0a63922013-01-23 16:32:59 +0100232List custom dashboards for a project.
233
Edwin Kempin55367622013-02-05 09:09:23 +0100234As result a list of link:#dashboard-info[DashboardInfo] entries is
235returned.
236
Edwin Kempind0a63922013-01-23 16:32:59 +0100237List all dashboards for the `work/my-project` project:
Edwin Kempin37440832013-02-06 11:36:00 +0100238
239.Request
Edwin Kempind0a63922013-01-23 16:32:59 +0100240----
241 GET /projects/work%2Fmy-project/dashboards/ HTTP/1.0
Edwin Kempin37440832013-02-06 11:36:00 +0100242----
Edwin Kempind0a63922013-01-23 16:32:59 +0100243
Edwin Kempin37440832013-02-06 11:36:00 +0100244.Response
245----
Edwin Kempind0a63922013-01-23 16:32:59 +0100246 HTTP/1.1 200 OK
247 Content-Disposition: attachment
248 Content-Type: application/json;charset=UTF-8
249
250 )]}'
251 [
252 {
253 "kind": "gerritcodereview#dashboard",
254 "id": "main:closed",
255 "ref": "main",
256 "path": "closed",
257 "description": "Merged and abandoned changes in last 7 weeks",
258 "url": "/dashboard/?title\u003dClosed+changes\u0026Merged\u003dstatus:merged+age:7w\u0026Abandoned\u003dstatus:abandoned+age:7w",
259 "default": true,
260 "title": "Closed changes",
261 "sections": [
262 {
263 "name": "Merged",
264 "query": "status:merged age:7w"
265 },
266 {
267 "name": "Abandoned",
268 "query": "status:abandoned age:7w"
269 }
270 ]
271 }
272 ]
273----
274
Edwin Kempina64c4b92013-01-23 11:30:40 +0100275.Get all dashboards of the 'All-Projects' project
276****
277get::/projects/All-Projects/dashboards/
278****
279
Edwin Kempin67e923c2013-02-14 13:57:12 +0100280[[get-dashboard]]
281GET /projects/\{project-name\}/dashboards/\{dashboard-id\} (Get Dashboard)
282~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
283Retrieves a project dashboard. The dashboard can be defined on that
284project or be inherited from a parent project.
285
286.Request
287----
288 GET /projects/work%2Fmy-project/dashboards/main:closed HTTP/1.0
289----
290
291As response a link:#dashboard-info[DashboardInfo] entity is returned
292that describes the dashboard.
293
294.Response
295----
296 HTTP/1.1 200 OK
297 Content-Disposition: attachment
298 Content-Type: application/json;charset=UTF-8
299
300 )]}'
301 {
302 "kind": "gerritcodereview#dashboard",
303 "id": "main:closed",
304 "ref": "main",
305 "path": "closed",
306 "description": "Merged and abandoned changes in last 7 weeks",
307 "url": "/dashboard/?title\u003dClosed+changes\u0026Merged\u003dstatus:merged+age:7w\u0026Abandoned\u003dstatus:abandoned+age:7w",
308 "default": true,
309 "title": "Closed changes",
310 "sections": [
311 {
312 "name": "Merged",
313 "query": "status:merged age:7w"
314 },
315 {
316 "name": "Abandoned",
317 "query": "status:abandoned age:7w"
318 }
319 ]
320 }
321----
322
323To retrieve the default dashboard of a project use `default` as
324dashboard-id.
Edwin Kempin37440832013-02-06 11:36:00 +0100325
326.Request
Edwin Kempind0a63922013-01-23 16:32:59 +0100327----
328 GET /projects/work%2Fmy-project/dashboards/default HTTP/1.0
Edwin Kempin37440832013-02-06 11:36:00 +0100329----
Edwin Kempind0a63922013-01-23 16:32:59 +0100330
Edwin Kempin37440832013-02-06 11:36:00 +0100331.Response
332----
Edwin Kempind0a63922013-01-23 16:32:59 +0100333 HTTP/1.1 200 OK
334 Content-Disposition: attachment
335 Content-Type: application/json;charset=UTF-8
336
337 )]}'
338 {
339 "kind": "gerritcodereview#dashboard",
340 "id": "main:closed",
341 "ref": "main",
342 "path": "closed",
Edwin Kempin67e923c2013-02-14 13:57:12 +0100343 "description": "Merged and abandoned changes in last 7 weeks",
344 "url": "/dashboard/?title\u003dClosed+changes\u0026Merged\u003dstatus:merged+age:7w\u0026Abandoned\u003dstatus:abandoned+age:7w",
Edwin Kempind0a63922013-01-23 16:32:59 +0100345 "default": true,
Edwin Kempin67e923c2013-02-14 13:57:12 +0100346 "title": "Closed changes",
347 "sections": [
348 {
349 "name": "Merged",
350 "query": "status:merged age:7w"
351 },
352 {
353 "name": "Abandoned",
354 "query": "status:abandoned age:7w"
355 }
356 ]
Edwin Kempind0a63922013-01-23 16:32:59 +0100357 }
358----
359
Edwin Kempin67e923c2013-02-14 13:57:12 +0100360[[set-dashboard]]
361PUT /projects/\{project-name\}/dashboards/\{dashboard-id\} (Set Dashboard)
362~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
363Updates/Creates a project dashboard.
364
365Currently only supported for the `default` dashboard.
366
367The creation/update information for the dashboard must be provided in
368the request body as a link:#dashboard-input[DashboardInput] entity.
369
370.Request
371----
372 PUT /projects/work%2Fmy-project/dashboards/default HTTP/1.0
373 Content-Type: application/json;charset=UTF-8
374
375 {
376 "id": "main:closed",
377 "commit_message": "Define the default dashboard"
378 }
379----
380
381As response the new/updated dashboard is returned as a
382link:#dashboard-info[DashboardInfo] entity.
383
384.Response
385----
386 HTTP/1.1 200 OK
387 Content-Disposition: attachment
388 Content-Type: application/json;charset=UTF-8
389
390 )]}'
391 {
392 "kind": "gerritcodereview#dashboard",
393 "id": "main:closed",
394 "ref": "main",
395 "path": "closed",
396 "description": "Merged and abandoned changes in last 7 weeks",
397 "url": "/dashboard/?title\u003dClosed+changes\u0026Merged\u003dstatus:merged+age:7w\u0026Abandoned\u003dstatus:abandoned+age:7w",
398 "default": true,
399 "title": "Closed changes",
400 "sections": [
401 {
402 "name": "Merged",
403 "query": "status:merged age:7w"
404 },
405 {
406 "name": "Abandoned",
407 "query": "status:abandoned age:7w"
408 }
409 ]
410 }
411----
412
413[[delete-dashboard]]
414DELETE /projects/\{project-name\}/dashboards/\{dashboard-id\} (Delete Dashboard)
415~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
416Deletes a project dashboard.
417
418Currently only supported for the `default` dashboard.
419
Edwin Kempinefec4492013-02-22 10:09:23 +0100420The request body does not need to include a link:#dashboard-input[
421DashbaordInput] entity if no commit message is specified.
Edwin Kempin67e923c2013-02-14 13:57:12 +0100422
423Please note that some proxies prohibit request bodies for DELETE
424requests.
425
426.Request
427----
428 DELETE /projects/work%2Fmy-project/dashboards/default HTTP/1.0
429----
430
431.Response
432----
433 HTTP/1.1 204 No Content
434----
435
Edwin Kempin34d83352013-02-06 10:40:17 +0100436
437[[ids]]
438IDs
439---
440
Edwin Kempin67e923c2013-02-14 13:57:12 +0100441\{dashboard-id\}
442~~~~~~~~~~~~~~~~
443The ID of a dashboard in the format '<ref>:<path>'.
444
445A special dashboard ID is `default` which represents the default
446dashboard of a project.
447
Edwin Kempin34d83352013-02-06 10:40:17 +0100448\{project-name\}
449~~~~~~~~~~~~~~~~
450The name of the project.
451
452
Edwin Kempin51a6dc92013-02-04 15:43:59 +0100453[[json-entities]]
454JSON Entities
455-------------
456
Edwin Kempin55367622013-02-05 09:09:23 +0100457[[dashboard-info]]
458DashboardInfo
459~~~~~~~~~~~~~
460The `DashboardInfo` entity contains information about a project
461dashboard.
462
463[options="header",width="50%",cols="1,^2,4"]
464|===============================
465|Field Name ||Description
466|`kind` ||`gerritcodereview#dashboard`
467|`id` ||
468The ID of the dashboard. The ID has the format '<ref>:<path>',
469where ref and path are URL encoded.
470|`project` ||
471The name of the project for which this dashboard is returned.
472|`defining_project`||
473The name of the project in which this dashboard is defined.
474This is different from `project` if the dashboard is inherited from a
475parent project.
476|`ref` ||
477The name of the ref in which the dashboard is defined, without the
478`refs/meta/dashboards/` prefix, which is common for all dashboard refs.
479|`path` ||
480The path of the file in which the dashboard is defined.
481|`description` |optional|The description of the dashboard.
482|`foreach` |optional|
483Subquery that applies to all sections in the dashboard. +
484Tokens such as `${project}` are not resolved.
485|`url` ||
486The URL under which the dashboard can be opened in the Gerrit WebUI. +
487The URL is relative to the canonical web URL. +
488Tokens in the queries such as `${project}` are resolved.
489|`default` |not set if `false`|
490Whether this is the default dashboard of the project.
491|`title` |optional|The title of the dashboard.
492|`sections` ||
493The list of link:#dashboard-section-info[sections] in the dashboard.
494|===============================
495
Edwin Kempin67e923c2013-02-14 13:57:12 +0100496[[dashboard-input]]
497DashboardInput
498~~~~~~~~~~~~~~
499The `DashboardInput` entity contains information to create/update a
500project dashboard.
501
502[options="header",width="50%",cols="1,^2,4"]
503|=============================
504|Field Name ||Description
505|`id` |optional|
506ID of a dashboard to which this dashboard should link to.
507|`commit_message`|optional|
508Message that should be used to commit the change of the dashboard.
509|=============================
510
Edwin Kempin55367622013-02-05 09:09:23 +0100511[[dashboard-section-info]]
512DashboardSectionInfo
513~~~~~~~~~~~~~~~~~~~~
514The `DashboardSectionInfo` entity contains information about a section
515in a dashboard.
516
517[options="header",width="50%",cols="1,6"]
518|===========================
519|Field Name |Description
520|`name` |The title of the section.
521|`query` |The query of the section. +
522Tokens such as `${project}` are not resolved.
523|===========================
524
Edwin Kempin57f303c2013-02-13 15:52:22 +0100525[[project-description-input]]
526ProjectDescriptionInput
527~~~~~~~~~~~~~~~~~~~~~~~
528The `ProjectDescriptionInput` entity contains information for setting a
529project description.
530
531[options="header",width="50%",cols="1,^2,4"]
532|=============================
533|Field Name ||Description
534|`description` |optional|The project description. +
535The project description will be deleted if not set.
536|`commit_message`|optional|
537Message that should be used to commit the change of the project
538description in the `project.config` file to the `refs/meta/config`
539branch.
540|=============================
541
Edwin Kempin51a6dc92013-02-04 15:43:59 +0100542[[project-info]]
543ProjectInfo
544~~~~~~~~~~~
545The `ProjectInfo` entity contains information about a project.
546
547[options="header",width="50%",cols="1,^2,4"]
548|===========================
549|Field Name ||Description
550|`kind` ||`gerritcodereview#project`
551|`id` ||The URL encoded project name.
552|`name` |
553not set if returned in a map where the project name is used as map key|
554The name of the project.
555|`parent` |optional, +
556not set for the root project|
557The name of the parent project. +
558`?-<n>` if the parent project is not visible (`<n>` is a number which
559is increased for each non-visible project).
560|`description` |optional|The description of the project.
561|`branches` |optional|Map of branch names to HEAD revisions.
562|===========================
563
Edwin Kempinecad88c2013-02-14 12:09:44 +0100564[[project-parent-input]]
565ProjectParentInput
566~~~~~~~~~~~~~~~~~~
567The `ProjectParentInput` entity contains information for setting a
568project parent.
569
570[options="header",width="50%",cols="1,^2,4"]
571|=============================
572|Field Name ||Description
573|`parent` ||The name of the parent project.
574|`commit_message`|optional|
575Message that should be used to commit the change of the project parent
576in the `project.config` file to the `refs/meta/config` branch.
577|=============================
578
Edwin Kempind0a63922013-01-23 16:32:59 +0100579
580GERRIT
581------
582Part of link:index.html[Gerrit Code Review]