summaryrefslogtreecommitdiffstats
path: root/Documentation/rest-api-accounts.txt
blob: f17a741b5804d1224c5be9834d36312127b7c21f (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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
Gerrit Code Review - /accounts/ REST API
========================================

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

Endpoints
---------

[[get-account]]
Get Account
~~~~~~~~~~~
[verse]
'GET /accounts/link:#account-id[\{account-id\}]'

Returns an account as an link:#account-info[AccountInfo] entity.

.Request
----
  GET /accounts/self HTTP/1.0
----

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

  )]}'
  {
    "_account_id": 1000096,
    "name": "John Doe",
    "email": "john.doe@example.com"
  }
----

[[list-account-capabilities]]
List Account Capabilities
~~~~~~~~~~~~~~~~~~~~~~~~~
[verse]
'GET /accounts/link:#account-id[\{account-id\}]/capabilities'

Returns the global capabilities that are enabled for the specified
user.

If the global capabilities for the calling user should be listed,
`self` can be used as account-id. This can be used by UI tools to
discover if administrative features are available to the caller, so
they can hide (or show) relevant UI actions.

.Request
----
  GET /accounts/self/capabilities HTTP/1.0
----

As response the global capabilities of the user are returned as a
link:#capability-info[CapabilityInfo] entity.

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

  )]}'
  {
    "queryLimit": {
      "min": 0,
      "max": 500
    },
    "emailReviewers": true
  }
----

Administrator that has authenticated with digest authentication:

.Request
----
  GET /a/accounts/self/capabilities HTTP/1.0
  Authorization: Digest username="admin", realm="Gerrit Code Review", nonce="...
----

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

  )]}'
  {
    "administrateServer": true,
    "queryLimit": {
      "min": 0,
      "max": 500
    },
    "createAccount": true,
    "createGroup": true,
    "createProject": true,
    "emailReviewers": true,
    "killTask": true,
    "viewCaches": true,
    "flushCaches": true,
    "viewConnections": true,
    "viewQueue": true,
    "runGC": true,
    "startReplication": true
  }
----

.Get your own capabilities
****
get::/accounts/self/capabilities
****

To filter the set of global capabilities the `q` parameter can be used.
Filtering may decrease the response time by avoiding looking at every
possible alternative for the caller.

.Request
----
  GET /a/accounts/self/capabilities?q=createAccount&q=createGroup HTTP/1.0
  Authorization: Digest username="admin", realm="Gerrit Code Review", nonce="...
----

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

  )]}'
  {
    "createAccount": true,
    "createGroup": true
  }
----

.Check if you can create groups
****
get::/accounts/self/capabilities?q=createGroup
****

[[check-account-capability]]
Check Account Capability
~~~~~~~~~~~~~~~~~~~~~~~~
[verse]
'GET /accounts/link:#account-id[\{account-id\}]/capabilities/link:#capability-id[\{capability-id\}]'

Checks if a user has a certain global capability.

.Request
----
  GET /a/accounts/self/capabilities/createGroup HTTP/1.0
----

If the user has the global capability the string `ok` is returned.

.Response
----
  HTTP/1.1 200 OK

  ok
----

If the user doesn't have the global capability the response is
`404 Not Found`.

.Check if you can create groups
****
get::/accounts/self/capabilities/createGroup
****

[[list-groups]]
List Groups
~~~~~~~~~~~
[verse]
'GET /accounts/link:#account-id[\{account-id\}]/groups/'

Lists all groups that contain the specified user as a member.

.Request
----
  GET /a/accounts/self/groups/ HTTP/1.0
----

As result a list of link:rest-api-groups.html#group-info[GroupInfo]
entries is returned.

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

  )]}'
  [
    {
      "kind": "gerritcodereview#group",
      "id": "global%3AAnonymous-Users",
      "url": "#/admin/groups/uuid-global%3AAnonymous-Users",
      "options": {
      },
      "description": "Any user, signed-in or not",
      "group_id": 2,
      "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
    },
    {
      "kind": "gerritcodereview#group",
      "id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7",
      "url": "#/admin/groups/uuid-834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7",
      "options": {
        "visible_to_all": true,
      },
      "group_id": 6,
      "owner_id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7"
    },
    {
      "kind": "gerritcodereview#group",
      "id": "global%3ARegistered-Users",
      "url": "#/admin/groups/uuid-global%3ARegistered-Users",
      "options": {
      },
      "description": "Any signed-in user",
      "group_id": 3,
      "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
    }
  ]
----

.List all groups that contain you as a member
****
get::/accounts/self/groups/
****

[[get-avatar]]
Get Avatar
~~~~~~~~~~
[verse]
'GET /accounts/link:#account-id[\{account-id\}]/avatar'

Retrieves the avatar image of the user.

With the `size` option (alias `s`) you can specify the preferred size
in pixels (height and width).

.Request
----
  GET /a/accounts/john.doe@example.com/avatar?s=20 HTTP/1.0
----

The response redirects to the URL of the avatar image.

.Response
----
  HTTP/1.1 302 Found
  Location: https://profiles/avatar/john_doe.jpeg?s=20x20
----

[[get-avatar-change-url]]
Get Avatar Change URL
~~~~~~~~~~~~~~~~~~~~~
[verse]
'GET /accounts/link:#account-id[\{account-id\}]/avatar.change.url'

Retrieves the URL where the user can change the avatar image.

.Request
----
  GET /a/accounts/self/avatar.change.url HTTP/1.0
----

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

  https://profiles/pictures/john.doe
----

[[get-diff-preferences]]
Get Diff Preferences
~~~~~~~~~~~~~~~~~~~~
[verse]
'GET /accounts/link:#account-id[\{account-id\}]/preferences.diff'

Retrieves the diff preferences of a user.

.Request
----
  GET /a/accounts/self/preferences.diff HTTP/1.0
----

As result the diff preferences of the user are returned as a
link:#diff-preferences-info[DiffPreferencesInfo] entity.

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

  )]}'
  {
    "context": 10,
    "ignore_whitespace": "IGNORE_ALL_SPACE",
    "intraline_difference": true,
    "line_length": 100,
    "show_tabs": true,
    "show_whitespace_errors": true,
    "syntax_highlighting": true,
    "tab_size": 8
  }
----

[[set-diff-preferences]]
Set Diff Preferences
~~~~~~~~~~~~~~~~~~~~
[verse]
'PUT /accounts/link:#account-id[\{account-id\}]/preferences.diff'

Sets the diff preferences of a user.

The new diff preferences must be provided in the request body as a
link:#diff-preferences-input[DiffPreferencesInput] entity.

.Request
----
  GET /a/accounts/self/preferences.diff HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "context": 10,
    "ignore_whitespace": "IGNORE_ALL_SPACE",
    "intraline_difference": true,
    "line_length": 100,
    "show_line_endings": true,
    "show_tabs": true,
    "show_whitespace_errors": true,
    "syntax_highlighting": true,
    "tab_size": 8
  }
----

As result the new diff preferences of the user are returned as a
link:#diff-preferences-info[DiffPreferencesInfo] entity.

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

  )]}'
  {
    "context": 10,
    "ignore_whitespace": "IGNORE_ALL_SPACE",
    "intraline_difference": true,
    "line_length": 100,
    "show_line_endings": true,
    "show_tabs": true,
    "show_whitespace_errors": true,
    "syntax_highlighting": true,
    "tab_size": 8
  }
----


[[ids]]
IDs
---

[[account-id]]
\{account-id\}
~~~~~~~~~~~~~~
Identifier that uniquely identifies one account.

This can be:

* a string of the format "Full Name <email@example.com>"
* just the email address ("email@example")
* a full name if it is unique ("Full Name")
* an account ID ("18419")
* a user name ("username")
* `self` for the calling user

[[capability-id]]
\{capability-id\}
~~~~~~~~~~~~~~~~~
Identifier of a global capability. Valid values are all field names of
the link:#capability-info[CapabilityInfo] entity.


[[json-entities]]
JSON Entities
-------------

[[account-info]]
AccountInfo
~~~~~~~~~~~
The `AccountInfo` entity contains information about an account.

[options="header",width="50%",cols="1,^1,5"]
|===========================
|Field Name    ||Description
|`_account_id` ||The numeric ID of the account.
|`name`        |optional|The full name of the user. +
Only set if detailed account information is requested.
|`email`       |optional|
The email address the user prefers to be contacted through. +
Only set if detailed account information is requested.
|===========================

[[capability-info]]
CapabilityInfo
~~~~~~~~~~~~~~
The `CapabilityInfo` entity contains information about the global
capabilities of a user.

[options="header",width="50%",cols="1,^1,5"]
|=================================
|Field Name          ||Description
|`administrateServer`|not set if `false`|Whether the user has the
link:access-control.html#capability_administrateServer[Administrate
Server] capability.
|`queryLimit`||The link:access-control.html#capability_queryLimit[Query
Limit] of the user as link:#query-limit-info[QueryLimitInfo].
|`createAccount`     |not set if `false`|Whether the user has the
link:access-control.html#capability_createAccount[Create Account]
capability.
|`createGroup`       |not set if `false`|Whether the user has the
link:access-control.html#capability_createGroup[Create Group]
capability.
|`createProject`     |not set if `false`|Whether the user has the
link:access-control.html#capability_createProject[Create Project]
capability.
|`emailReviewers`    |not set if `false`|Whether the user has the
link:access-control.html#capability_emailReviewers[Email Reviewers]
capability.
|`killTask`          |not set if `false`|Whether the user has the
link:access-control.html#capability_kill[Kill Task] capability.
|`viewCaches`        |not set if `false`|Whether the user has the
link:access-control.html#capability_viewCaches[View Caches] capability.
|`flushCaches`       |not set if `false`|Whether the user has the
link:access-control.html#capability_flushCaches[Flush Caches]
capability.
|`viewConnections`   |not set if `false`|Whether the user has the
link:access-control.html#capability_viewConnections[View Connections]
capability.
|`viewQueue`         |not set if `false`|Whether the user has the
link:access-control.html#capability_viewQueue[View Queue] capability.
|`runGC`  |not set if `false`|Whether the user has the
link:access-control.html#capability_runGC[Run Garbage Collection]
capability.
|`startReplication`  |not set if `false`|Whether the user has the
link:access-control.html#capability_startReplication[Start Replication]
capability.
|=================================

[[diff-preferences-info]]
DiffPreferencesInfo
~~~~~~~~~~~~~~~~~~~
The `DiffPreferencesInfo` entity contains information about the diff
preferences of a user.

[options="header",width="50%",cols="1,^1,5"]
|=====================================
|Field Name              ||Description
|`context`               ||
The number of lines of context when viewing a patch.
|`expand_all_comments`   |not set if `false`|
Whether all inline comments should be automatically expanded.
|`ignore_whitespace`     ||
Whether whitespace changes should be ignored and if yes, which
whitespace changes should be ignored. +
Allowed values are `IGNORE_NONE`, `IGNORE_SPACE_AT_EOL`,
`IGNORE_SPACE_CHANGE`, `IGNORE_ALL_SPACE`.
|`intraline_difference`  |not set if `false`|
Whether intraline differences should be highlighted.
|`line_length`           ||
Number of characters that should be displayed in one line.
|`manual_review`         |not set if `false`|
Whether the 'Reviewed' flag should not be set automatically on a patch
when it is viewed.
|`retain_header`         |not set if `false`|
Whether the header that is displayed above the patch (that either shows
the commit message, the diff preferences, the patch sets or the files)
should be retained on file switch.
|`show_line_endings`     |not set if `false`|
Whether Windows EOL/Cr-Lf should be displayed as '\r' in a dotted-line
box.
|`show_tabs`             |not set if `false`|
Whether tabs should be shown.
|`show_whitespace_errors`|not set if `false`|
Whether whitespace errors should be shown.
|`skip_deleted`          |not set if `false`|
Whether deleted files should be skipped on file switch.
|`skip_uncommented`      |not set if `false`|
Whether uncommented files should be skipped on file switch.
|`syntax_highlighting`   |not set if `false`|
Whether syntax highlighting should be enabled.
|`tab_size`              ||
Number of spaces that should be used to display one tab.
|=====================================

[[diff-preferences-input]]
DiffPreferencesInput
~~~~~~~~~~~~~~~~~~~~
The `DiffPreferencesInput` entity contains information for setting the
diff preferences of a user. Fields which are not set will not be
updated.

[options="header",width="50%",cols="1,^1,5"]
|=====================================
|Field Name              ||Description
|`context`               |optional|
The number of lines of context when viewing a patch.
|`expand_all_comments`   |optional|
Whether all inline comments should be automatically expanded.
|`ignore_whitespace`     |optional|
Whether whitespace changes should be ignored and if yes, which
whitespace changes should be ignored. +
Allowed values are `IGNORE_NONE`, `IGNORE_SPACE_AT_EOL`,
`IGNORE_SPACE_CHANGE`, `IGNORE_ALL_SPACE`.
|`intraline_difference`  |optional|
Whether intraline differences should be highlighted.
|`line_length`           |optional|
Number of characters that should be displayed in one line.
|`manual_review`         |optional|
Whether the 'Reviewed' flag should not be set automatically on a patch
when it is viewed.
|`retain_header`         |optional|
Whether the header that is displayed above the patch (that either shows
the commit message, the diff preferences, the patch sets or the files)
should be retained on file switch.
|`show_line_endings`     |optional|
Whether Windows EOL/Cr-Lf should be displayed as '\r' in a dotted-line
box.
|`show_tabs`             |optional|
Whether tabs should be shown.
|`show_whitespace_errors`|optional|
Whether whitespace errors should be shown.
|`skip_deleted`          |optional|
Whether deleted files should be skipped on file switch.
|`skip_uncommented`      |optional|
Whether uncommented files should be skipped on file switch.
|`syntax_highlighting`   |optional|
Whether syntax highlighting should be enabled.
|`tab_size`              |optional|
Number of spaces that should be used to display one tab.
|=====================================

[[query-limit-info]]
QueryLimitInfo
~~~~~~~~~~~~~~
The `QueryLimitInfo` entity contains information about the
link:access-control.html#capability_queryLimit[Query Limit] of a user.

[options="header",width="50%",cols="1,6"]
|================================
|Field Name          |Description
|`min`               |Lower limit.
|`max`               |Upper limit.
|================================


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