gerrit/Documentation/rest-api-plugins.txt

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

480 lines
9.6 KiB
Plaintext
Raw Normal View History

= 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/",
"filename": "delete-project.jar",
"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/",
"filename": "delete-project.jar",
"version": "2.9-SNAPSHOT"
},
"reviewers-by-blame": {
"id": "reviewers-by-blame",
"index_url": "plugins/reviewers-by-blame/",
"filename": "reviewers-by-blame.jar",
"version": "2.9-SNAPSHOT",
"disabled": true
}
}
----
Limit(n)::
Limit the number of plugins to be included in the results.
+
Query the first plugin in the plugin list:
+
.Request
----
GET /plugins/?n=1 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/",
"filename": "delete-project.jar",
"version": "2.9-SNAPSHOT"
}
}
----
Prefix(p)::
Limit the results to those plugins that start with the specified
prefix.
+
The match is case sensitive. May not be used together with `m` or `r`.
+
List all plugins that start with `delete`:
+
.Request
----
GET /plugins/?p=delete 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/",
"filename": "delete-project.jar",
"version": "2.9-SNAPSHOT"
}
}
----
+
E.g. this feature can be used by suggestion client UI's to limit results.
Regex(r)::
Limit the results to those plugins that match the specified regex.
+
Boundary matchers '^' and '$' are implicit. For example: the regex 'test.*' will
match any plugins that start with 'test' and regex '.*test' will match any
project that end with 'test'.
+
The match is case sensitive. May not be used together with `m` or `p`.
+
List all plugins that match regex `some.*plugin`:
+
.Request
----
GET /plugins/?r=some.*plugin HTTP/1.0
----
+
.Response
----
HTTP/1.1 200 OK
Content-Disposition: attachment
Content-Type: application/json; charset=UTF-8
)]}'
{
"some-plugin": {
"id": "some-plugin",
"index_url": "plugins/some-plugin/",
"filename": "some-plugin.jar",
"version": "2.9-SNAPSHOT"
},
"some-other-plugin": {
"id": "some-other-plugin",
"index_url": "plugins/some-other-plugin/",
"filename": "some-other-plugin.jar",
"version": "2.9-SNAPSHOT"
}
}
----
Skip(S)::
Skip the given number of plugins from the beginning of the list.
+
Query the second plugin in the plugin list:
+
.Request
----
GET /plugins/?all&n=1&S=1 HTTP/1.0
----
+
.Response
----
HTTP/1.1 200 OK
Content-Disposition: attachment
Content-Type: application/json; charset=UTF-8
)]}'
{
"reviewers-by-blame": {
"id": "reviewers-by-blame",
"index_url": "plugins/reviewers-by-blame/",
"filename": "reviewers-by-blame.jar",
"version": "2.9-SNAPSHOT",
"disabled": true
}
}
----
Substring(m)::
Limit the results to those plugins that match the specified substring.
+
The match is case insensitive. May not be used together with `r` or `p`.
+
List all plugins that match substring `project`:
+
.Request
----
GET /plugins/?m=project 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/",
"filename": "delete-project.jar",
"version": "2.9-SNAPSHOT"
}
}
----
[[install-plugin]]
=== Install Plugin
--
'PUT /plugins/link:#plugin-id[\{plugin-id\}]'
--
Installs a new plugin on the Gerrit server. If a plugin with the
Allow plugins to provide their own name Plugin name is an important part for plugin developers and users: it drives SSH command names, REST API endpoints, used as a prefix in project.config for plugin-owned capabilities and can be used in project.config sections for project specific configuration. Currently there is no way for a plugin to provide its own name. When a new version of a plugin is released and it is copied to $site/plugins folders with unchanged name: replication-2.8.SNAPSHOT.jar then the plugin name in all places mentioned above is changed. With this change plugin name can be optionally provided by plugins, instead of deriving it from the plugin file name. To provide its own plugin name, plugin has to put the following line in the manifest file: Gerrit-PluginName: replication This is especially useful for plugins that contribute plugin-owned capabilities that are stored in project.config file as [plugin-name]-[capability-name] Other use case is to be able to put project specific plugin configuration section in project.config. In this case it is advantageous to reserve the plugin name to access the configuration section in project.config file. Multiple versions of the same plugin with different file names can not be deployed on one Gerrit installation site: only the first plugin can be successful deployed. All other plugins with the same name are disabled. If plugin provides its own name, it has some implications for SSH install command and PUT /plugins/plugin-name REST endpoint. In both cases a name of the plugin to install is passed from the user. If the plugin provides its own name in MANIFEST file, the plugin name from the MANIFEST file has precedence over the name passed to the SSH command or REST endpoint. Change-Id: If28349e95be2e90c6ee8169a72ba8cd642b49b98
2013-09-05 19:59:09 +02:00
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
}
----
Disabling of a link:config-gerrit.html#plugins.mandatory[mandatory plugin]
is rejected:
.Request
----
DELETE /plugins/replication HTTP/1.0
----
.Response
----
HTTP/1.1 405 Method Not Allowed
Content-Disposition: attachment
Content-Type: application/json; charset=UTF-8
)]}'
Plugin replication is mandatory
----
[[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.
|`filename` |optional|The plugin's filename.
|`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
---------