blob: ce262808ffb42a59d704d1bbe7a57d5e64c3ed7d [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - /plugins/ REST API
Edwin Kempin36eeee22013-08-30 15:57:34 +02002
3This page describes the plugin related REST endpoints.
4Please also take note of the general information on the
5link:rest-api.html[REST API].
6
Edwin Kempin36eeee22013-08-30 15:57:34 +02007[[plugin-endpoints]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08008== Plugin Endpoints
Edwin Kempin36eeee22013-08-30 15:57:34 +02009
Edwin Kempin9de428c2013-09-02 14:44:21 +020010Gerrit REST endpoints for installed plugins are available under
11'/plugins/link:#plugin-id[\{plugin-id\}]/gerrit~<endpoint-id>'.
12The `gerrit~` prefix ensures that the Gerrit REST endpoints for plugins
13do not clash with any REST endpoint that a plugin may offer under its
14namespace.
15
16
17[[list-plugins]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080018=== List Plugins
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -080019--
Edwin Kempin9de428c2013-09-02 14:44:21 +020020'GET /plugins/'
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -080021--
Edwin Kempin9de428c2013-09-02 14:44:21 +020022
23Lists the plugins installed on the Gerrit server. Only the enabled
24plugins are returned unless the `all` option is specified.
25
Edwin Kempin362b14d12014-05-09 14:18:12 +020026To be allowed to see the installed plugins, a user must be a member of
27a group that is granted the 'View Plugins' capability or the
28'Administrate Server' capability.
29
Edwin Kempin9de428c2013-09-02 14:44:21 +020030As result a map is returned that maps the plugin IDs to
31link:#plugin-info[PluginInfo] entries. The entries in the map are sorted
32by plugin ID.
33
34.Request
35----
David Pursehouse91727022017-07-28 14:13:18 +010036 GET /plugins/ HTTP/1.0
37----
38
39.Response
40----
41 HTTP/1.1 200 OK
42 Content-Disposition: attachment
43 Content-Type: application/json; charset=UTF-8
44
45 )]}'
46 {
47 "delete-project": {
48 "id": "delete-project",
49 "index_url": "plugins/delete-project/",
David Pursehouse4a648212017-08-04 21:03:28 +020050 "filename": "delete-project.jar",
Christian Aistleitnerc3afed62020-05-31 09:42:52 +020051 "api_version": "2.9.3-SNAPSHOT",
David Pursehouse91727022017-07-28 14:13:18 +010052 "version": "2.9-SNAPSHOT"
53 }
54 }
55----
56
57[[plugin-options]]
58==== Plugin Options
59All(a)::
60List all plugins including those that are disabled.
61
62.Request
63----
Edwin Kempin9de428c2013-09-02 14:44:21 +020064 GET /plugins/?all HTTP/1.0
65----
66
67.Response
68----
69 HTTP/1.1 200 OK
70 Content-Disposition: attachment
David Pursehouse56bf1cb2015-01-06 15:44:00 +090071 Content-Type: application/json; charset=UTF-8
Edwin Kempin9de428c2013-09-02 14:44:21 +020072
73 )]}'
74 {
75 "delete-project": {
Edwin Kempin9de428c2013-09-02 14:44:21 +020076 "id": "delete-project",
David Ostrovsky83c79862013-12-05 21:40:36 +010077 "index_url": "plugins/delete-project/",
David Pursehouse4a648212017-08-04 21:03:28 +020078 "filename": "delete-project.jar",
Colby Ranger4d3226c2013-12-09 09:01:42 -080079 "version": "2.9-SNAPSHOT"
Edwin Kempin9de428c2013-09-02 14:44:21 +020080 },
81 "reviewers-by-blame": {
Edwin Kempin9de428c2013-09-02 14:44:21 +020082 "id": "reviewers-by-blame",
David Ostrovsky83c79862013-12-05 21:40:36 +010083 "index_url": "plugins/reviewers-by-blame/",
David Pursehouse4a648212017-08-04 21:03:28 +020084 "filename": "reviewers-by-blame.jar",
David Pursehouse62864b72013-10-17 23:05:08 +090085 "version": "2.9-SNAPSHOT",
Edwin Kempin9de428c2013-09-02 14:44:21 +020086 "disabled": true
Colby Ranger4d3226c2013-12-09 09:01:42 -080087 }
Edwin Kempin9de428c2013-09-02 14:44:21 +020088 }
89----
90
David Pursehouse7f577a92017-07-27 17:32:28 +010091Limit(n)::
92Limit the number of plugins to be included in the results.
93+
94Query the first plugin in the plugin list:
95+
96.Request
97----
98 GET /plugins/?n=1 HTTP/1.0
99----
100+
101.Response
102----
103 HTTP/1.1 200 OK
104 Content-Disposition: attachment
105 Content-Type: application/json; charset=UTF-8
106
107 )]}'
108 {
109 "delete-project": {
110 "id": "delete-project",
111 "index_url": "plugins/delete-project/",
David Pursehouse4a648212017-08-04 21:03:28 +0200112 "filename": "delete-project.jar",
David Pursehouse7f577a92017-07-27 17:32:28 +0100113 "version": "2.9-SNAPSHOT"
114 }
115 }
116----
117
David Pursehouse68d975b2017-07-27 22:14:38 +0100118Prefix(p)::
119Limit the results to those plugins that start with the specified
120prefix.
121+
122The match is case sensitive. May not be used together with `m` or `r`.
123+
124List all plugins that start with `delete`:
125+
126.Request
127----
128 GET /plugins/?p=delete HTTP/1.0
129----
130+
131.Response
132----
133 HTTP/1.1 200 OK
134 Content-Disposition: attachment
135 Content-Type: application/json; charset=UTF-8
136
137 )]}'
138 {
139 "delete-project": {
140 "id": "delete-project",
141 "index_url": "plugins/delete-project/",
David Pursehouse4a648212017-08-04 21:03:28 +0200142 "filename": "delete-project.jar",
David Pursehouse68d975b2017-07-27 22:14:38 +0100143 "version": "2.9-SNAPSHOT"
144 }
145 }
146----
147+
148E.g. this feature can be used by suggestion client UI's to limit results.
149
150Regex(r)::
151Limit the results to those plugins that match the specified regex.
152+
153Boundary matchers '^' and '$' are implicit. For example: the regex 'test.*' will
154match any plugins that start with 'test' and regex '.*test' will match any
155project that end with 'test'.
156+
157The match is case sensitive. May not be used together with `m` or `p`.
158+
159List all plugins that match regex `some.*plugin`:
160+
161.Request
162----
163 GET /plugins/?r=some.*plugin HTTP/1.0
164----
165+
166.Response
167----
168 HTTP/1.1 200 OK
169 Content-Disposition: attachment
170 Content-Type: application/json; charset=UTF-8
171
172 )]}'
173 {
174 "some-plugin": {
175 "id": "some-plugin",
176 "index_url": "plugins/some-plugin/",
David Pursehouse4a648212017-08-04 21:03:28 +0200177 "filename": "some-plugin.jar",
David Pursehouse68d975b2017-07-27 22:14:38 +0100178 "version": "2.9-SNAPSHOT"
179 },
180 "some-other-plugin": {
181 "id": "some-other-plugin",
182 "index_url": "plugins/some-other-plugin/",
David Pursehouse4a648212017-08-04 21:03:28 +0200183 "filename": "some-other-plugin.jar",
David Pursehouse68d975b2017-07-27 22:14:38 +0100184 "version": "2.9-SNAPSHOT"
185 }
186 }
187
188----
David Pursehouse7f577a92017-07-27 17:32:28 +0100189
190Skip(S)::
191Skip the given number of plugins from the beginning of the list.
192+
193Query the second plugin in the plugin list:
194+
195.Request
196----
197 GET /plugins/?all&n=1&S=1 HTTP/1.0
198----
199+
200.Response
201----
202 HTTP/1.1 200 OK
203 Content-Disposition: attachment
204 Content-Type: application/json; charset=UTF-8
205
206 )]}'
207 {
208 "reviewers-by-blame": {
209 "id": "reviewers-by-blame",
210 "index_url": "plugins/reviewers-by-blame/",
David Pursehouse4a648212017-08-04 21:03:28 +0200211 "filename": "reviewers-by-blame.jar",
David Pursehouse7f577a92017-07-27 17:32:28 +0100212 "version": "2.9-SNAPSHOT",
213 "disabled": true
214 }
215 }
216----
217
David Pursehouse68d975b2017-07-27 22:14:38 +0100218Substring(m)::
219Limit the results to those plugins that match the specified substring.
220+
221The match is case insensitive. May not be used together with `r` or `p`.
222+
223List all plugins that match substring `project`:
224+
225.Request
226----
227 GET /plugins/?m=project HTTP/1.0
228----
229+
230.Response
231----
232 HTTP/1.1 200 OK
233 Content-Disposition: attachment
234 Content-Type: application/json; charset=UTF-8
235
236 )]}'
237 {
238 "delete-project": {
239 "id": "delete-project",
240 "index_url": "plugins/delete-project/",
David Pursehouse4a648212017-08-04 21:03:28 +0200241 "filename": "delete-project.jar",
David Pursehouse68d975b2017-07-27 22:14:38 +0100242 "version": "2.9-SNAPSHOT"
243 }
244 }
245----
David Pursehouse7f577a92017-07-27 17:32:28 +0100246
Edwin Kempin36eeee22013-08-30 15:57:34 +0200247[[install-plugin]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800248=== Install Plugin
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800249--
Guillaume Chauvelc8fe65c2020-05-17 01:30:59 +0200250'PUT /plugins/link:#plugin-id[\{plugin-id\}].jar'
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800251--
Edwin Kempin36eeee22013-08-30 15:57:34 +0200252
253Installs a new plugin on the Gerrit server. If a plugin with the
David Ostrovsky366ad0e2013-09-05 19:59:09 +0200254specified name already exists it is overwritten. Note: if the plugin
255provides its own name in the MANIFEST file, then the plugin name from
256the MANIFEST file has precedence over the \{plugin-id\} above.
Edwin Kempin36eeee22013-08-30 15:57:34 +0200257
258The plugin jar can either be sent as binary data in the request body
259or a URL to the plugin jar must be provided in the request body inside
260a link:#plugin-input[PluginInput] entity.
261
262.Request
263----
Guillaume Chauvelc8fe65c2020-05-17 01:30:59 +0200264 PUT /plugins/delete-project.jar HTTP/1.0
David Pursehouse56bf1cb2015-01-06 15:44:00 +0900265 Content-Type: application/json; charset=UTF-8
Edwin Kempin36eeee22013-08-30 15:57:34 +0200266
267 {
268 "url": "file:///gerrit/plugins/delete-project/delete-project-2.8.jar"
269 }
270----
271
272To provide the plugin jar as binary data in the request body the
273following curl command can be used:
274
275----
Guillaume Chauvelc8fe65c2020-05-17 01:30:59 +0200276 curl --user admin:TNNuLkWsIV8w -X PUT -H "Content-Type:application/octet-stream" --data-binary @delete-project.jar 'http://gerrit:8080/a/plugins/delete-project.jar'
Edwin Kempin36eeee22013-08-30 15:57:34 +0200277----
278
279As response a link:#plugin-info[PluginInfo] entity is returned that
280describes the plugin.
281
282.Response
283----
284 HTTP/1.1 201 Created
285 Content-Disposition: attachment
Guillaume Chauvelc8fe65c2020-05-17 01:30:59 +0200286 Content-Type: application/json;charset=utf-8
287 Content-Length: 150
Edwin Kempin36eeee22013-08-30 15:57:34 +0200288
289 )]}'
290 {
Edwin Kempin36eeee22013-08-30 15:57:34 +0200291 "id": "delete-project",
Guillaume Chauvelc8fe65c2020-05-17 01:30:59 +0200292 "version": "v2.16-221-g35bb8bbac4",
293 "index_url": "plugins/delete-project/",
294 "filename": "delete-project.jar"
Edwin Kempin36eeee22013-08-30 15:57:34 +0200295 }
296----
297
298If an existing plugin was overwritten the response is "`200 OK`".
299
Edwin Kempin9de428c2013-09-02 14:44:21 +0200300[[get-plugin-status]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800301=== Get Plugin Status
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800302--
Edwin Kempin9de428c2013-09-02 14:44:21 +0200303'GET /plugins/link:#plugin-id[\{plugin-id\}]/gerrit~status'
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800304--
Edwin Kempin9de428c2013-09-02 14:44:21 +0200305
306Retrieves the status of a plugin on the Gerrit server.
307
308.Request
309----
310 GET /plugins/delete-project/gerrit~status HTTP/1.0
311----
312
313As response a link:#plugin-info[PluginInfo] entity is returned that
314describes the plugin.
315
316.Response
317----
318 HTTP/1.1 200 OK
319 Content-Disposition: attachment
David Pursehouse56bf1cb2015-01-06 15:44:00 +0900320 Content-Type: application/json; charset=UTF-8
Edwin Kempin9de428c2013-09-02 14:44:21 +0200321
322 )]}'
323 {
Edwin Kempin9de428c2013-09-02 14:44:21 +0200324 "id": "delete-project",
325 "version": "2.8"
326 }
327----
328
329[[enable-plugin]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800330=== Enable Plugin
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800331--
Edwin Kempin9de428c2013-09-02 14:44:21 +0200332'POST /plugins/link:#plugin-id[\{plugin-id\}]/gerrit~enable'
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800333--
Edwin Kempin9de428c2013-09-02 14:44:21 +0200334
335Enables a plugin on the Gerrit server.
336
337.Request
338----
339 POST /plugins/delete-project/gerrit~enable HTTP/1.0
340----
341
342As response a link:#plugin-info[PluginInfo] entity is returned that
343describes the plugin.
344
345.Response
346----
347 HTTP/1.1 200 OK
348 Content-Disposition: attachment
David Pursehouse56bf1cb2015-01-06 15:44:00 +0900349 Content-Type: application/json; charset=UTF-8
Edwin Kempin9de428c2013-09-02 14:44:21 +0200350
351 )]}'
352 {
Edwin Kempin9de428c2013-09-02 14:44:21 +0200353 "id": "delete-project",
354 "version": "2.8"
355 }
356----
357
358[[disable-plugin]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800359=== Disable Plugin
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800360--
Edwin Kempin9de428c2013-09-02 14:44:21 +0200361'POST /plugins/link:#plugin-id[\{plugin-id\}]/gerrit~disable'
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800362--
Edwin Kempin9de428c2013-09-02 14:44:21 +0200363
364OR
365
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800366--
Edwin Kempin9de428c2013-09-02 14:44:21 +0200367'DELETE /plugins/link:#plugin-id[\{plugin-id\}]'
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800368--
Edwin Kempin9de428c2013-09-02 14:44:21 +0200369
370Disables a plugin on the Gerrit server.
371
372.Request
373----
374 POST /plugins/delete-project/gerrit~disable HTTP/1.0
375----
376
377As response a link:#plugin-info[PluginInfo] entity is returned that
378describes the plugin.
379
380.Response
381----
382 HTTP/1.1 200 OK
383 Content-Disposition: attachment
David Pursehouse56bf1cb2015-01-06 15:44:00 +0900384 Content-Type: application/json; charset=UTF-8
Edwin Kempin9de428c2013-09-02 14:44:21 +0200385
386 )]}'
387 {
Edwin Kempin9de428c2013-09-02 14:44:21 +0200388 "id": "delete-project",
389 "version": "2.8",
390 "disabled": true
391 }
392----
393
Saša Živkovcae842e2019-05-13 14:38:20 +0200394Disabling of a link:config-gerrit.html#plugins.mandatory[mandatory plugin]
395is rejected:
396
397.Request
398----
399 DELETE /plugins/replication HTTP/1.0
400----
401
402.Response
403----
404 HTTP/1.1 405 Method Not Allowed
405 Content-Disposition: attachment
406 Content-Type: application/json; charset=UTF-8
407
408 )]}'
409 Plugin replication is mandatory
410----
411
Edwin Kempin9de428c2013-09-02 14:44:21 +0200412[[reload-plugin]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800413=== Reload Plugin
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800414--
Edwin Kempin9de428c2013-09-02 14:44:21 +0200415'POST /plugins/link:#plugin-id[\{plugin-id\}]/gerrit~reload'
Yuxuan 'fishy' Wangd85b6872013-11-15 11:47:46 -0800416--
Edwin Kempin9de428c2013-09-02 14:44:21 +0200417
418Reloads a plugin on the Gerrit server.
419
420.Request
421----
422 POST /plugins/delete-project/gerrit~reload HTTP/1.0
423----
424
425As response a link:#plugin-info[PluginInfo] entity is returned that
426describes the plugin.
427
428.Response
429----
430 HTTP/1.1 200 OK
431 Content-Disposition: attachment
David Pursehouse56bf1cb2015-01-06 15:44:00 +0900432 Content-Type: application/json; charset=UTF-8
Edwin Kempin9de428c2013-09-02 14:44:21 +0200433
434 )]}'
435 {
Edwin Kempin9de428c2013-09-02 14:44:21 +0200436 "id": "delete-project",
437 "version": "2.8",
438 "disabled": true
439 }
440----
441
Edwin Kempin36eeee22013-08-30 15:57:34 +0200442
443[[ids]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800444== IDs
Edwin Kempin36eeee22013-08-30 15:57:34 +0200445
446[[plugin-id]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800447=== \{plugin-id\}
Edwin Kempin36eeee22013-08-30 15:57:34 +0200448The ID of the plugin.
449
Edwin Kempin36eeee22013-08-30 15:57:34 +0200450[[json-entities]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800451== JSON Entities
Edwin Kempin36eeee22013-08-30 15:57:34 +0200452
453[[plugin-info]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800454=== PluginInfo
Edwin Kempin36eeee22013-08-30 15:57:34 +0200455The `PluginInfo` entity describes a plugin.
456
David Pursehouseae367192014-11-25 17:24:47 +0900457[options="header",cols="1,^2,4"]
Edwin Kempin9de428c2013-09-02 14:44:21 +0200458|=======================
Christian Aistleitnerc3afed62020-05-31 09:42:52 +0200459|Field Name ||Description
460|`id` ||The ID of the plugin.
461|`version` ||The version of the plugin.
462|`api_version`|optional|The version of the Gerrit Api used by the plugin.
463|`index_url` |optional|URL of the plugin's default page.
464|`filename` |optional|The plugin's filename.
465|`disabled` |not set if `false`|Whether the plugin is disabled.
Edwin Kempin9de428c2013-09-02 14:44:21 +0200466|=======================
Edwin Kempin36eeee22013-08-30 15:57:34 +0200467
468[[plugin-input]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800469=== PluginInput
Edwin Kempin36eeee22013-08-30 15:57:34 +0200470The `PluginInput` entity describes a plugin that should be installed.
471
David Pursehouseae367192014-11-25 17:24:47 +0900472[options="header",cols="1,6"]
Edwin Kempin36eeee22013-08-30 15:57:34 +0200473|======================
474|Field Name|Description
475|`url` |URL to the plugin jar.
476|======================
477
478
479GERRIT
480------
481Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700482
483SEARCHBOX
484---------