summaryrefslogtreecommitdiffstats
path: root/Documentation/rest-api-plugins.txt
blob: 53f4bb5febf73b58e8e86212304f3600181f70f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
= Gerrit Code Review - /plugins/ REST API

This page describes the plugin related REST endpoints.
Please also take note of the general information on the
link:rest-api.html[REST API].

[[plugin-endpoints]]
== Plugin Endpoints

Gerrit REST endpoints for installed plugins are available under
'/plugins/link:#plugin-id[\{plugin-id\}]/gerrit~<endpoint-id>'.
The `gerrit~` prefix ensures that the Gerrit REST endpoints for plugins
do not clash with any REST endpoint that a plugin may offer under its
namespace.


[[list-plugins]]
=== List Plugins
--
'GET /plugins/'
--

Lists the plugins installed on the Gerrit server. Only the enabled
plugins are returned unless the `all` option is specified.

To be allowed to see the installed plugins, a user must be a member of
a group that is granted the 'View Plugins' capability or the
'Administrate Server' capability.

As result a map is returned that maps the plugin IDs to
link:#plugin-info[PluginInfo] entries. The entries in the map are sorted
by plugin ID.

.Request
----
  GET /plugins/ HTTP/1.0
----

.Response
----
  HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json; charset=UTF-8

  )]}'
  {
    "delete-project": {
      "id": "delete-project",
      "index_url": "plugins/delete-project/",
      "version": "2.9-SNAPSHOT"
    }
  }
----

[[plugin-options]]
==== Plugin Options
All(a)::
List all plugins including those that are disabled.

.Request
----
  GET /plugins/?all HTTP/1.0
----

.Response
----
  HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json; charset=UTF-8

  )]}'
  {
    "delete-project": {
      "id": "delete-project",
      "index_url": "plugins/delete-project/",
      "version": "2.9-SNAPSHOT"
    },
    "reviewers-by-blame": {
      "id": "reviewers-by-blame",
      "index_url": "plugins/reviewers-by-blame/",
      "version": "2.9-SNAPSHOT",
      "disabled": true
    }
  }
----

[[install-plugin]]
=== Install Plugin
--
'PUT /plugins/link:#plugin-id[\{plugin-id\}]'
--

Installs a new plugin on the Gerrit server. If a plugin with the
specified name already exists it is overwritten. Note: if the plugin
provides its own name in the MANIFEST file, then the plugin name from
the MANIFEST file has precedence over the \{plugin-id\} above.

The plugin jar can either be sent as binary data in the request body
or a URL to the plugin jar must be provided in the request body inside
a link:#plugin-input[PluginInput] entity.

.Request
----
  PUT /plugins/delete-project HTTP/1.0
  Content-Type: application/json; charset=UTF-8

  {
    "url": "file:///gerrit/plugins/delete-project/delete-project-2.8.jar"
  }
----

To provide the plugin jar as binary data in the request body the
following curl command can be used:

----
  curl --user admin:TNNuLkWsIV8w -X PUT --data-binary @delete-project-2.8.jar 'http://gerrit:8080/a/plugins/delete-project'
----

As response a link:#plugin-info[PluginInfo] entity is returned that
describes the plugin.

.Response
----
  HTTP/1.1 201 Created
  Content-Disposition: attachment
  Content-Type: application/json; charset=UTF-8

  )]}'
  {
    "id": "delete-project",
    "version": "2.8"
  }
----

If an existing plugin was overwritten the response is "`200 OK`".

[[get-plugin-status]]
=== Get Plugin Status
--
'GET /plugins/link:#plugin-id[\{plugin-id\}]/gerrit~status'
--

Retrieves the status of a plugin on the Gerrit server.

.Request
----
  GET /plugins/delete-project/gerrit~status HTTP/1.0
----

As response a link:#plugin-info[PluginInfo] entity is returned that
describes the plugin.

.Response
----
  HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json; charset=UTF-8

  )]}'
  {
    "id": "delete-project",
    "version": "2.8"
  }
----

[[enable-plugin]]
=== Enable Plugin
--
'POST /plugins/link:#plugin-id[\{plugin-id\}]/gerrit~enable'
--

Enables a plugin on the Gerrit server.

.Request
----
  POST /plugins/delete-project/gerrit~enable HTTP/1.0
----

As response a link:#plugin-info[PluginInfo] entity is returned that
describes the plugin.

.Response
----
  HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json; charset=UTF-8

  )]}'
  {
    "id": "delete-project",
    "version": "2.8"
  }
----

[[disable-plugin]]
=== Disable Plugin
--
'POST /plugins/link:#plugin-id[\{plugin-id\}]/gerrit~disable'
--

OR

--
'DELETE /plugins/link:#plugin-id[\{plugin-id\}]'
--

Disables a plugin on the Gerrit server.

.Request
----
  POST /plugins/delete-project/gerrit~disable HTTP/1.0
----

As response a link:#plugin-info[PluginInfo] entity is returned that
describes the plugin.

.Response
----
  HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json; charset=UTF-8

  )]}'
  {
    "id": "delete-project",
    "version": "2.8",
    "disabled": true
  }
----

[[reload-plugin]]
=== Reload Plugin
--
'POST /plugins/link:#plugin-id[\{plugin-id\}]/gerrit~reload'
--

Reloads a plugin on the Gerrit server.

.Request
----
  POST /plugins/delete-project/gerrit~reload HTTP/1.0
----

As response a link:#plugin-info[PluginInfo] entity is returned that
describes the plugin.

.Response
----
  HTTP/1.1 200 OK
  Content-Disposition: attachment
  Content-Type: application/json; charset=UTF-8

  )]}'
  {
    "id": "delete-project",
    "version": "2.8",
    "disabled": true
  }
----


[[ids]]
== IDs

[[plugin-id]]
=== \{plugin-id\}
The ID of the plugin.

[[json-entities]]
== JSON Entities

[[plugin-info]]
=== PluginInfo
The `PluginInfo` entity describes a plugin.

[options="header",cols="1,^2,4"]
|=======================
|Field Name ||Description
|`id`       ||The ID of the plugin.
|`version`  ||The version of the plugin.
|`index_url`|optional|URL of the plugin's default page.
|`disabled` |not set if `false`|Whether the plugin is disabled.
|=======================

[[plugin-input]]
=== PluginInput
The `PluginInput` entity describes a plugin that should be installed.

[options="header",cols="1,6"]
|======================
|Field Name|Description
|`url`     |URL to the plugin jar.
|======================


GERRIT
------
Part of link:index.html[Gerrit Code Review]

SEARCHBOX
---------