blob: dfa42404c8e4785a7162f6be62bb1e7aac61d9af [file] [log] [blame] [view]
Edwin Kempinf79cd7c2019-03-26 11:10:50 +01001# @PLUGIN@ - /plugins/@PLUGIN@/checkers/ REST API
Dave Borowitz540ee6d2019-02-21 16:03:17 -08002
3This page describes the checker-related REST endpoints that are added by the
4@PLUGIN@ plugin.
5
6Please also take note of the general information on the
7[REST API](../../../Documentation/rest-api.html).
8
9## <a id="checker-endpoints"> Checker Endpoints
10
11### <a id="get-checker"> Get Checker
Edwin Kempinf79cd7c2019-03-26 11:10:50 +010012_'GET /plugins/@PLUGIN@/checkers/[\{checker-id\}](#checker-id)'_
Dave Borowitz540ee6d2019-02-21 16:03:17 -080013
14Retrieves a checker.
15
16Note that only users with the [Administrate
17Checkers](access-control.md#capability_administrateCheckers) global capability
18are permitted to retrieve checkers.
19
20#### Request
21
22```
Edwin Kempin9ae9e162019-03-26 11:19:08 +010023 GET /plugins/@PLUGIN@/checkers/test%3Amy-checker HTTP/1.0
Dave Borowitz540ee6d2019-02-21 16:03:17 -080024```
25
26As response a [CheckerInfo](#checker-info) entity is returned that describes the
27checker.
28
29#### Response
30
31```
32 HTTP/1.1 200 OK
33 Content-Disposition: attachment
34 Content-Type: application/json; charset=UTF-8
35 )]}'
36 {
Dave Borowitz3c43c322019-02-28 15:27:14 -080037 "uuid": "test:my-checker",
Dave Borowitz540ee6d2019-02-21 16:03:17 -080038 "name": "MyChecker",
39 "repository": "examples/Foo",
Dave Borowitzb8a3e7a2019-02-14 14:02:22 -080040 "blocking": [],
Dave Borowitz540ee6d2019-02-21 16:03:17 -080041 "description": "A simple checker.",
42 "created_on": "2019-01-31 09:59:32.126000000"
43 }
44```
45
46### <a id="create-checker"> Create Checker
Edwin Kempinf79cd7c2019-03-26 11:10:50 +010047_'POST /plugins/@PLUGIN@/checkers/'_
Dave Borowitz540ee6d2019-02-21 16:03:17 -080048
49Creates a new checker.
50
51In the request body the data for the checker must be provided as a
52[CheckerInput](#checker-input) entity.
53
54Note that only users with the [Administrate
55Checkers](access-control.md#capability_administrateCheckers) global capability
56are permitted to create checkers.
57
58#### Request
59
60```
Edwin Kempinf79cd7c2019-03-26 11:10:50 +010061 POST /plugins/@PLUGIN@/checkers/ HTTP/1.0
Dave Borowitz540ee6d2019-02-21 16:03:17 -080062 Content-Type: application/json; charset=UTF-8
63 {
Dave Borowitz3c43c322019-02-28 15:27:14 -080064 "uuid": "test:my-checker",
Dave Borowitz540ee6d2019-02-21 16:03:17 -080065 "name": "MyChecker",
66 "description": "A simple checker.",
67 "repository": "examples/Foo",
68 }
69```
70
71As response the [CheckerInfo](#checker-info) entity is returned that describes
72the created checker.
73
74#### Response
75
76```
77 HTTP/1.1 201 Created
78 Content-Disposition: attachment
79 Content-Type: application/json; charset=UTF-8
80 )]}'
81 {
Dave Borowitz3c43c322019-02-28 15:27:14 -080082 "uuid": "test:my-checker",
Dave Borowitz540ee6d2019-02-21 16:03:17 -080083 "name": "MyChecker",
84 "description": "A simple checker.",
85 "repository": "examples/Foo",
86 "created_on": "2019-01-31 09:59:32.126000000",
87 "updated_on": "2019-01-31 09:59:32.126000000"
88 }
89```
90
91### <a id="update-checker"> Update Checker
Edwin Kempinf79cd7c2019-03-26 11:10:50 +010092_'POST /plugins/@PLUGIN@/checkers/[\{checker-id\}](#checker-id)'_
Dave Borowitz540ee6d2019-02-21 16:03:17 -080093
94Updates a checker.
95
96The new property values must be set in the request body in a
97[CheckerInput](#checker-input) entity.
98
99This REST endpoint supports partial updates of the checker property set. Only
100properties that are set in the [CheckerInput](#checker-input) entity are
101updated. Properties that are not set in the input (or that have `null` as value)
102are not touched.
103
104Unsetting properties:
105
Dave Borowitz3c43c322019-02-28 15:27:14 -0800106* `uuid`: Cannot be unset or otherwise modified.
107* `name`: Can be unset by setting an empty string ("") for it.
Dave Borowitz540ee6d2019-02-21 16:03:17 -0800108* `description`: Can be unset by setting an empty string ("") for it.
109* `url`: Can be unset by setting an empty string ("") for it.
110* '`repository`: Cannot be unset. Attempting to set it to an empty string ("")
111 or a string that is empty after trim is rejected as `400 Bad Request`.
112* `status`: Cannot be unset.
Dave Borowitzb8a3e7a2019-02-14 14:02:22 -0800113* `blocking`: Can be unset by setting an empty list (\[\]) for it.
Dave Borowitz67629ae2019-02-21 16:55:53 -0800114* `query`: Can be unset by setting an empty string ("") for it. Note that the
115 default for newly-created checkers is not empty; see [below](#query).
Dave Borowitz540ee6d2019-02-21 16:03:17 -0800116
117Note that only users with the [Administrate
118Checkers](access-control.md#capability_administrateCheckers) global capability
119are permitted to update checkers.
120
121#### Request
122
123```
Edwin Kempin9ae9e162019-03-26 11:19:08 +0100124 POST /plugins/@PLUGIN@/checkers/test%3Amy-checker HTTP/1.0
Dave Borowitz540ee6d2019-02-21 16:03:17 -0800125 Content-Type: application/json; charset=UTF-8
126 {
127 "description": "A simple checker."
128 }
129```
130
131As response the [CheckerInfo](#checker-info) entity is returned that describes
132the updated checker.
133
134#### Response
135
136```
137 HTTP/1.1 200 OK
138 Content-Disposition: attachment
139 Content-Type: application/json; charset=UTF-8
140 )]}'
141 {
Dave Borowitz3c43c322019-02-28 15:27:14 -0800142 "uuid": "test:my-checker",
Dave Borowitz540ee6d2019-02-21 16:03:17 -0800143 "name": "MyChecker",
144 "description": "A simple checker.",
145 "repository": "examples/Foo",
146 "status": "ENABLED",
147 "created_on": "2019-01-31 09:59:32.126000000",
148 "updated_on": "2019-02-01 07:23:44.158000000"
149 }
150```
151
152## <a id="ids"> IDs
153
154### <a id="checker-id"> \{checker-id\}
155
156The UUID of a checker.
157
Dave Borowitz3c43c322019-02-28 15:27:14 -0800158UUIDs are of the form `SCHEME ':' ID`. The scheme and ID portions may only
159contain alphanumeric characters (`a-z`, `A-Z`, `0-9`) plus the punctuation
160characters `.`, `_`, and `-`. Thus UUIDs are URL-safe without escaping.
161
Dave Borowitzc7e597c2019-03-07 11:04:45 -0800162The scheme is by convention a short string (max 100 chars) associated with the
163external system that created the checker, for example `jenkins`. The scheme must
164also be a valid ref name component according to
165[`git-check-ref-format`](https://git-scm.com/docs/git-check-ref-format), for
166example it may not start or end with a period.
167
168The ID is an arbitrary identifier that may have meaning to the external system.
Dave Borowitz3c43c322019-02-28 15:27:14 -0800169
170UUIDs must be unique and are immutable after creation.
171
172Checker names cannot be used as identifiers in the REST API since checker names
Dave Borowitz540ee6d2019-02-21 16:03:17 -0800173may be ambiguous.
174
Edwin Kempin52b84182019-03-13 09:40:59 +0100175## <a id="json-entities"> JSON Entities
Dave Borowitz540ee6d2019-02-21 16:03:17 -0800176
177### <a id="checker-info"> CheckerInfo
178The `CheckerInfo` entity describes a checker.
179
180| Field Name | | Description |
181| --------------- | -------- | ----------- |
Dave Borowitz3c43c322019-02-28 15:27:14 -0800182| `uuid` | | The [UUID](#checker-id) of the checker.
Dave Borowitz540ee6d2019-02-21 16:03:17 -0800183| `name` | | The name of the checker, may not be unique.
184| `description` | optional | The description of the checker.
185| `url` | optional | The URL of the checker.
186| `repository` | | The (exact) name of the repository for which the checker applies.
187| `status` | | The status of the checker; one of `ENABLED` or `DISABLED`.
Dave Borowitzb8a3e7a2019-02-14 14:02:22 -0800188| `blocking` | | A list of [conditions](#blocking-conditions) that describe when the checker should block change submission.
Dave Borowitz67629ae2019-02-21 16:55:53 -0800189| `query` | optional | A [query](#query) that limits changes for which the checker is relevant.
Dave Borowitz540ee6d2019-02-21 16:03:17 -0800190| `created_on` | | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the checker was created.
191| `updated_on` | | The [timestamp](../../../Documentation/rest-api.html#timestamp) of when the checker was last updated.
192
193### <a id="checker-input"> CheckerInput
194The `CheckerInput` entity contains information for creating a checker.
195
196| Field Name | | Description |
197| --------------- | -------- | ----------- |
198| `name` | optional | The name of the checker. Must be specified for checker creation.
199| `description` | optional | The description of the checker.
200| `url` | optional | The URL of the checker.
201| `repository` | optional | The (exact) name of the repository for which the checker applies.
202| `status` | optional | The status of the checker; one of `ENABLED` or `DISABLED`.
Dave Borowitzb8a3e7a2019-02-14 14:02:22 -0800203| `blocking` | optional | A list of [conditions](#blocking-conditions) that describe when the checker should block change submission.
Dave Borowitz67629ae2019-02-21 16:55:53 -0800204| `query` | optional | A [query](#query) that limits changes for which the checker is relevant.
Dave Borowitzb8a3e7a2019-02-14 14:02:22 -0800205
206## <a id="blocking-conditions"> Blocking Conditions
207
208Blocking conditions allow checkers to specify the conditions under which checks
209will block change submission. The conditions configured for a checker are
210represented as a list of enum values. When there are multiple blocking
211conditions, any one of them is sufficient to block submission; in other words,
212conditions are ORed together.
213
214There is currently only a single type of blocking condition:
215`STATE_NOT_PASSING`. Intuitively, if a checker sets this blocking condition,
216that means that users need to wait for all checks, for example build and test,
217to pass before submitting the change. In other words, we might say the checker
218is _required_.
219
220Technically, `STATE_NOT_PASSING` requires the combined check state on the change
Dave Borowitz80220032019-03-18 12:44:13 -0700221to be either `SUCCESSFUL`, `WARNING`, or `NOT_RELEVANT`.
Dave Borowitz540ee6d2019-02-21 16:03:17 -0800222
Dave Borowitz67629ae2019-02-21 16:55:53 -0800223## <a id="query"> Query
224
225If the `query` field is specified in the checker config, then the checker is
226only considered relevant for changes matching that query. The query field is
227interpreted as a [change query](../../../Documentation/user-search.html), with a
228limited subset of supported operators. By default, the query for newly-created
229checkers is `status:open`. An empty query matches all changes.
230
231In order to determine the relevant checkers for a given change, Gerrit first
232looks up all enabled checkers matching that change's repository, then executes
233the query for each checker in sequence. Because of this algorithm, there are
234restrictions on which operators can be supported in checker queries:
235
236* Operators related to projects are not supported, since the algorithm already
237 only considers checkers with a matching repository.
238* Full-text operators (e.g. `message`) are not supported, since these cannot be
239 efficiently evaluated sequentially.
240* Operators with an explicit or implied `self` user are not supported, since the
241 algorithm must return the same set of relevant checkers regardless of the end
242 user looking at the change.
243
244Currently, the set of allowed query operators is:
245
246`added, after, age, assignee, author, before, branch, committer, deleted, delta,
247destination, dir, directory, ext, extension, f, file, footer, hashtag, intopic,
248label, onlyextensions, onlyexts, ownerin, path, r, ref, reviewer, reviewerin,
249size, status, submittable, topic, unresolved, wip`
250
Dave Borowitz540ee6d2019-02-21 16:03:17 -0800251---
252
253Part of [Gerrit Code Review](../../../Documentation/index.html)