summaryrefslogtreecommitdiffstats
path: root/Documentation/rest-api-groups.txt
blob: e800d569ee6d4b7639d1fd582441a17e8e697af5 (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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
Gerrit Code Review - /groups/ REST API
======================================

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

[[group-endpoints]]
Group Endpoints
---------------

[[list-groups]]
List Groups
~~~~~~~~~~~
[verse]
'GET /groups/'

Lists the groups accessible by the caller. This is the same as
using the link:cmd-ls-groups.html[ls-groups] command over SSH,
and accepts the same options as query parameters.

As result a map is returned that maps the group names to
link:#group-info[GroupInfo] entries. The entries in the map are sorted
by group name.

.Request
----
  GET /groups/ HTTP/1.0
----

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

  )]}'
  {
    "Administrators": {
      "kind": "gerritcodereview#group",
      "id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
      "url": "#/admin/groups/uuid-6a1e70e1a88782771a91808c8af9bbb7a9871389",
      "options": {
      },
      "description": "Gerrit Site Administrators",
      "group_id": 1,
      "owner": "Administrators",
      "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
    },
    "Anonymous Users": {
      "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": "Administrators",
      "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
    },
    "MyProject_Committers": {
      "kind": "gerritcodereview#group",
      "id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7",
      "url": "#/admin/groups/uuid-834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7",
      "options": {
        "visible_to_all": true,
      },
      "group_id": 6,
      "owner": "MyProject_Committers",
      "owner_id": "834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7"
    },
    "Non-Interactive Users": {
      "kind": "gerritcodereview#group",
      "id": "5057f3cbd3519d6ab69364429a89ffdffba50f73",
      "url": "#/admin/groups/uuid-5057f3cbd3519d6ab69364429a89ffdffba50f73",
      "options": {
      },
      "description": "Users who perform batch actions on Gerrit",
      "group_id": 4,
      "owner": "Administrators",
      "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
    },
    "Project Owners": {
      "kind": "gerritcodereview#group",
      "id": "global%3AProject-Owners",
      "url": "#/admin/groups/uuid-global%3AProject-Owners",
      "options": {
      },
      "description": "Any owner of the project",
      "group_id": 5,
      "owner": "Administrators",
      "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
    },
    "Registered Users": {
      "kind": "gerritcodereview#group",
      "id": "global%3ARegistered-Users",
      "url": "#/admin/groups/uuid-global%3ARegistered-Users",
      "options": {
      },
      "description": "Any signed-in user",
      "group_id": 3,
      "owner": "Administrators",
      "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
    }
  }
----

.Get all groups
****
get::/groups/
****

[[group-options]]
Group Options
^^^^^^^^^^^^^
Additional fields can be obtained by adding `o` parameters, each option
requires more lookups and slows down the query response time to the
client so they are generally disabled by default. Optional fields are:

[[includes]]
--
* `INCLUDES`: include list of directly included groups.
--

[[members]]
--
* `MEMBERS`: include list of direct group members.
--

Check if a group is owned by the calling user
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
By setting the option `owned` and specifying a group to inspect with
the option `q`, it is possible to find out, if this group is owned by
the calling user.

.Request
----
  GET /groups/?owned&q=MyProject-Committers HTTP/1.0
----

If the group is owned by the calling user, the returned map contains
this group. If the calling user doesn't own this group an empty map is
returned.

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

  )]}'
  {
    "MyProject-Committers": {
      "kind": "gerritcodereview#group",
      "id": "9999c971bb4ab872aab759d8c49833ee6b9ff320",
      "url": "#/admin/groups/uuid-9999c971bb4ab872aab759d8c49833ee6b9ff320",
      "options": {
        "visible_to_all": true
      },
      "description":"contains all committers for MyProject",
      "group_id": 551,
      "owner": "MyProject-Owners",
      "owner_id": "7ca042f4d5847936fcb90ca91057673157fd06fc"
    }
  }
----

[[get-group]]
Get Group
~~~~~~~~~
[verse]
'GET /groups/link:#group-id[\{group-id\}]'

Retrieves a group.

.Request
----
  GET /groups/6a1e70e1a88782771a91808c8af9bbb7a9871389 HTTP/1.0
----

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

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

  )]}'
  {
    "kind": "gerritcodereview#group",
    "id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
    "name": "Administrators",
    "url": "#/admin/groups/uuid-6a1e70e1a88782771a91808c8af9bbb7a9871389",
    "options": {
    },
    "description": "Gerrit Site Administrators",
    "group_id": 1,
    "owner": "Administrators",
    "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
  }
----

[[create-group]]
Create Group
~~~~~~~~~~~~
[verse]
'PUT /groups/link:#group-name[\{group-name\}]'

Creates a new Gerrit internal group.

In the request body additional data for the group can be provided as
link:#group-input[GroupInput].

.Request
----
  PUT /groups/MyProject-Committers HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "description": "contains all committers for MyProject",
    "visible_to_all": true,
    "owner": "MyProject-Owners",
    "owner_id": "7ca042f4d5847936fcb90ca91057673157fd06fc"
  }
----

As response the link:#group-info[GroupInfo] entity is returned that
describes the created group.

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

  )]}'
  {
    "kind": "gerritcodereview#group",
    "id": "9999c971bb4ab872aab759d8c49833ee6b9ff320",
    "name": "MyProject-Committers",
    "url": "#/admin/groups/uuid-9999c971bb4ab872aab759d8c49833ee6b9ff320",
    "options": {
      "visible_to_all": true
    },
    "description":"contains all committers for MyProject",
    "group_id": 551,
    "owner": "MyProject-Owners",
    "owner_id": "7ca042f4d5847936fcb90ca91057673157fd06fc"
  }
----

If the group creation fails because the name is already in use the
response is "`409 Conflict`".

[[get-group-detail]]
Get Group Detail
~~~~~~~~~~~~~~~~
[verse]
'GET /groups/link:#group-id[\{group-id\}]/detail'

Retrieves a group with the direct link:#members[members] and the
directly link:#includes[included groups].

.Request
----
  GET /groups/6a1e70e1a88782771a91808c8af9bbb7a9871389/detail HTTP/1.0
----

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

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

  )]}'
  {
    "kind": "gerritcodereview#group",
    "id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
    "name": "Administrators",
    "url": "#/admin/groups/uuid-6a1e70e1a88782771a91808c8af9bbb7a9871389",
    "options": {
    },
    "description": "Gerrit Site Administrators",
    "group_id": 1,
    "owner": "Administrators",
    "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
    "members": [
      {
        "_account_id": 1000097,
        "name": "Jane Roe",
        "email": "jane.roe@example.com"
      },
      {
        "_account_id": 1000096,
        "name": "John Doe",
        "email": "john.doe@example.com"
      }
    ],
    "includes": []
  }
----

[[get-group-name]]
Get Group Name
~~~~~~~~~~~~~~
[verse]
'GET /groups/link:#group-id[\{group-id\}]/name'

Retrieves the name of a group.

.Request
----
  GET /groups/9999c971bb4ab872aab759d8c49833ee6b9ff320/name HTTP/1.0
----

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

  )]}'
  "MyProject-Committers"
----

[[rename-group]]
Rename Group
~~~~~~~~~~~~
[verse]
'PUT /groups/link:#group-id[\{group-id\}]/name'

Renames a Gerrit internal group.

The new group name must be provided in the request body.

.Request
----
  PUT /groups/MyProject-Committers/name HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "name": "My-Project-Committers"
  }
----

As response the new group name is returned.

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

  )]}'
  "My-Project-Committers"
----

If renaming the group fails because the new name is already in use the
response is "`409 Conflict`".

[[get-group-description]]
Get Group Description
~~~~~~~~~~~~~~~~~~~~~
[verse]
'GET /groups/link:#group-id[\{group-id\}]/description'

Retrieves the description of a group.

.Request
----
  GET /groups/9999c971bb4ab872aab759d8c49833ee6b9ff320/description HTTP/1.0
----

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

  )]}'
  "contains all committers for MyProject"
----

If the group does not have a description an empty string is returned.

[[set-group-description]]
Set Group Description
~~~~~~~~~~~~~~~~~~~~~
[verse]
'PUT /groups/link:#group-id[\{group-id\}]/description'

Sets the description of a Gerrit internal group.

The new group description must be provided in the request body.

.Request
----
  PUT /groups/9999c971bb4ab872aab759d8c49833ee6b9ff320/description HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "description": "The committers of MyProject."
  }
----

As response the new group description is returned.

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

  )]}'
  "The committers of MyProject."
----

If the description was deleted the response is "`204 No Content`".

[[delete-group-description]]
Delete Group Description
~~~~~~~~~~~~~~~~~~~~~~~~
[verse]
'DELETE /groups/link:#group-id[\{group-id\}]/description'

Deletes the description of a Gerrit internal group.

.Request
----
  DELETE /groups/9999c971bb4ab872aab759d8c49833ee6b9ff320/description HTTP/1.0
----

.Response
----
  HTTP/1.1 204 No Content
----

[[get-group-options]]
Get Group Options
~~~~~~~~~~~~~~~~~
[verse]
'GET /groups/link:#group-id[\{group-id\}]/options'

Retrieves the options of a group.

.Request
----
  GET /groups/9999c971bb4ab872aab759d8c49833ee6b9ff320/options HTTP/1.0
----

As response a link:#group-options-info[GroupOptionsInfo] entity is
returned that describes the options of the group.

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

  )]}'
  {
    "visible_to_all": true
  }
----

[[set-group-options]]
Set Group Options
~~~~~~~~~~~~~~~~~
[verse]
'PUT /groups/link:#group-id[\{group-id\}]/options'

Sets the options of a Gerrit internal group.

The new group options must be provided in the request body as a
link:#group-options-input[GroupOptionsInput] entity.

.Request
----
  PUT /groups/9999c971bb4ab872aab759d8c49833ee6b9ff320/options HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "visible_to_all": true
  }
----

As response the new group options are returned as a
link:#group-options-info[GroupOptionsInfo] entity.

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

  )]}'
  {
    "visible_to_all": true
  }
----

[[get-group-owner]]
Get Group Owner
~~~~~~~~~~~~~~~
[verse]
'GET /groups/link:#group-id[\{group-id\}]/owner'

Retrieves the owner group of a Gerrit internal group.

.Request
----
  GET /groups/9999c971bb4ab872aab759d8c49833ee6b9ff320/owner HTTP/1.0
----

As response a link:#group-info[GroupInfo] entity is returned that
describes the owner group.

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

  )]}'
  {
    "kind": "gerritcodereview#group",
    "id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
    "name": "Administrators",
    "url": "#/admin/groups/uuid-6a1e70e1a88782771a91808c8af9bbb7a9871389",
    "options": {
    },
    "description": "Gerrit Site Administrators",
    "group_id": 1,
    "owner": "Administrators",
    "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
  }
----

[[set-group-owner]]
Set Group Owner
~~~~~~~~~~~~~~~
[verse]
'PUT /groups/link:#group-id[\{group-id\}]/owner'

Sets the owner group of a Gerrit internal group.

The new owner group must be provided in the request body.

The new owner can be specified by name, by group UUID or by the legacy
numeric group ID.

.Request
----
  PUT /groups/9999c971bb4ab872aab759d8c49833ee6b9ff320/description HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "owner": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
  }
----

As response a link:#group-info[GroupInfo] entity is returned that
describes the new owner group.

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

  )]}'
  {
    "kind": "gerritcodereview#group",
    "id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
    "name": "Administrators",
    "url": "#/admin/groups/uuid-6a1e70e1a88782771a91808c8af9bbb7a9871389",
    "options": {
    },
    "description": "Gerrit Site Administrators",
    "group_id": 1,
    "owner": "Administrators",
    "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
  }
----

[[group-member-endpoints]]
Group Member Endpoints
----------------------

[[group-members]]
List Group Members
~~~~~~~~~~~~~~~~~~
[verse]
'GET /groups/link:#group-id[\{group-id\}]/members/'

Lists the direct members of a Gerrit internal group.

As result a list of detailed link:rest-api-accounts.html#account-info[
AccountInfo] entries is returned. The entries in the list are sorted by
full name, preferred email and id.

.Request
----
  GET /groups/834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7/members/ HTTP/1.0
----

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

  )]}'
  [
    {
      "_account_id": 1000097,
      "name": "Jane Roe",
      "email": "jane.roe@example.com"
    },
    {
      "_account_id": 1000096,
      "name": "John Doe",
      "email": "john.doe@example.com"
    }
  ]
----

.Get all members of the 'Administrators' group (normally group id = 1)
****
get::/groups/1/members/
****

To resolve the included groups of a group recursively and to list all
members the parameter `recursive` can be set.

Members from included external groups and from included groups which
are not visible to the calling user are ignored.

.Request
----
  GET /groups/834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7/members/?recursive HTTP/1.0
----

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

  )]}'
  [
    {
      "_account_id": 1000097,
      "name": "Jane Roe",
      "email": "jane.roe@example.com"
    },
    {
      "_account_id": 1000096,
      "name": "John Doe",
      "email": "john.doe@example.com"
    },
    {
      "_account_id": 1000098,
      "name": "Richard Roe",
      "email": "richard.roe@example.com"
    }
  ]
----

[[get-group-member]]
Get Group Member
~~~~~~~~~~~~~~~~
[verse]
'GET /groups/link:#group-id[\{group-id\}]/members/link:rest-api-accounts.html#account-id[\{account-id\}]'

Retrieves a group member.

.Request
----
  GET /groups/834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7/members/1000096 HTTP/1.0
----

As response a detailed link:rest-api-accounts.html#account-info[
AccountInfo] entity is returned that describes the group member.

.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"
  }
----

[[add-group-member]]
Add Group Member
~~~~~~~~~~~~~~~~
[verse]
'PUT /groups/link:#group-id[\{group-id\}]/members/link:rest-api-accounts.html#account-id[\{account-id\}]'

Adds a user as member to a Gerrit internal group.

.Request
----
  PUT /groups/MyProject-Committers/members/John%20Doe HTTP/1.0
----

As response a detailed link:rest-api-accounts.html#account-info[
AccountInfo] entity is returned that describes the group member.

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

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

The request also succeeds if the user is already a member of this
group, but then the HTTP response code is `200 OK`.

Add Group Members
~~~~~~~~~~~~~~~~~
[verse]
'POST /groups/link:#group-id[\{group-id\}]/members'

OR

[verse]
'POST /groups/link:#group-id[\{group-id\}]/members.add'

Adds one or several users to a Gerrit internal group.

The users to be added to the group must be provided in the request body
as a link:#members-input[MembersInput] entity.

.Request
----
  POST /groups/MyProject-Committers/members.add HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "members": {
      "jane.roe@example.com",
      "john.doe@example.com"
    }
  }
----

As response a list of detailed link:rest-api-accounts.html#account-info[
AccountInfo] entities is returned that describes the group members that
were specified in the link:#members-input[MembersInput]. An
link:rest-api-accounts.html#account-info[AccountInfo] entity
is returned for each user specified in the input, independently of
whether the user was newly added to the group or whether the user was
already a member of the group.

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

  )]}'
  [
    {
      "_account_id": 1000057,
      "name": "Jane Roe",
      "email": "jane.roe@example.com"
    },
    {
      "_account_id": 1000037,
      "name": "John Doe",
      "email": "john.doe@example.com"
    }
  ]
----

[[delete-group-member]]
Delete Group Member
~~~~~~~~~~~~~~~~~~~
[verse]
'DELETE /groups/link:#group-id[\{group-id\}]/members/link:rest-api-accounts.html#account-id[\{account-id\}]'

Deletes a user from a Gerrit internal group.

.Request
----
  DELETE /groups/MyProject-Committers/members/John%20Doe HTTP/1.0
----

.Response
----
  HTTP/1.1 204 No Content
----

[[delete-group-members]]
Delete Group Members
~~~~~~~~~~~~~~~~~~~~
[verse]
'POST /groups/link:#group-id[\{group-id\}]/members.delete'

Delete one or several users from a Gerrit internal group.

The users to be deleted from the group must be provided in the request
body as a link:#members-input[MembersInput] entity.

.Request
----
  POST /groups/MyProject-Committers/members.delete HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "members": {
      "jane.roe@example.com",
      "john.doe@example.com"
    }
  }
----

.Response
----
  HTTP/1.1 204 No Content
----

[[group-include-endpoints]]
Group Include Endpoints
-----------------------

[[included-groups]]
List Included Groups
~~~~~~~~~~~~~~~~~~~~
[verse]
'GET /groups/link:#group-id[\{group-id\}]/groups/'

Lists the directly included groups of a group.

As result a list of link:#group-info[GroupInfo] entries is returned.
The entries in the list are sorted by group name and UUID.

.Request
----
  GET /groups/834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7/groups/ HTTP/1.0
----

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

  )]}'
  [
    {
      "kind": "gerritcodereview#group",
      "id": "7ca042f4d5847936fcb90ca91057673157fd06fc",
      "name": "MyProject-Verifiers",
      "url": "#/admin/groups/uuid-7ca042f4d5847936fcb90ca91057673157fd06fc",
      "options": {
      },
      "group_id": 38,
      "owner": "MyProject-Verifiers",
      "owner_id": "7ca042f4d5847936fcb90ca91057673157fd06fc"
    }
  ]
----

[[get-included-group]]
Get Included Group
~~~~~~~~~~~~~~~~~~
[verse]
'GET /groups/link:#group-id[\{group-id\}]/groups/link:#group-id[\{group-id\}]'

Retrieves an included group.

.Request
----
  GET /groups/834ec36dd5e0ed21a2ff5d7e2255da082d63bbd7/groups/7ca042f4d5847936fcb90ca91057673157fd06fc HTTP/1.0
----

As response a link:#group-info[GroupInfo] entity is returned that
describes the included group.

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

  )]}'
  {
    "kind": "gerritcodereview#group",
    "id": "7ca042f4d5847936fcb90ca91057673157fd06fc",
    "name": "MyProject-Verifiers",
    "url": "#/admin/groups/uuid-7ca042f4d5847936fcb90ca91057673157fd06fc",
    "options": {
    },
    "group_id": 38,
    "owner": "Administrators",
    "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
  }
----

[[include-group]]
Include Group
~~~~~~~~~~~~~
[verse]
'PUT /groups/link:#group-id[\{group-id\}]/groups/link:#group-id[\{group-id\}]'

Includes a group into a Gerrit internal group.

.Request
----
  PUT /groups/MyProject-Committers/groups/MyGroup HTTP/1.0
----

As response a link:#group-info[GroupInfo] entity is returned that
describes the included group.

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

  )]}'
  {
    "kind": "gerritcodereview#group",
    "id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
    "name": "MyGroup",
    "url": "#/admin/groups/uuid-6a1e70e1a88782771a91808c8af9bbb7a9871389",
    "options": {
    },
    "group_id": 8,
    "owner": "Administrators",
    "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
  }
----

The request also succeeds if the group is already included in this
group, but then the HTTP response code is `200 OK`.

[[include-groups]]
Include Groups
~~~~~~~~~~~~~~
[verse]
'POST /groups/link:#group-id[\{group-id\}]/groups'

OR

[verse]
'POST /groups/link:#group-id[\{group-id\}]/groups.add'

Includes one or several groups into a Gerrit internal group.

The groups to be included into the group must be provided in the
request body as a link:#groups-input[GroupsInput] entity.

.Request
----
  POST /groups/MyProject-Committers/groups.add HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "groups": {
      "MyGroup",
      "MyOtherGroup"
    }
  }
----

As response a list of link:#group-info[GroupInfo] entities is
returned that describes the groups that were specified in the
link:#groups-input[GroupsInput]. A link:#group-info[GroupInfo] entity
is returned for each group specified in the input, independently of
whether the group was newly included into the group or whether the
group was already included in the group.

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

  )]}'
  [
    {
      "kind": "gerritcodereview#group",
      "id": "6a1e70e1a88782771a91808c8af9bbb7a9871389",
      "name": "MyGroup",
      "url": "#/admin/groups/uuid-6a1e70e1a88782771a91808c8af9bbb7a9871389",
      "options": {
      },
      "group_id": 8,
      "owner": "Administrators",
      "owner_id": "6a1e70e1a88782771a91808c8af9bbb7a9871389"
    },
    {
      "kind": "gerritcodereview#group",
      "id": "5057f3cbd3519d6ab69364429a89ffdffba50f73",
      "name": "MyOtherGroup",
      "url": "#/admin/groups/uuid-5057f3cbd3519d6ab69364429a89ffdffba50f73",
      "options": {
      },
      "group_id": 10,
      "owner": "MyOtherGroup",
      "owner_id": "5057f3cbd3519d6ab69364429a89ffdffba50f73"
    }
  ]
----

[[delete-included-group]]
Delete Included Group
~~~~~~~~~~~~~~~~~~~~~
[verse]
'DELETE /groups/link:#group-id[\{group-id\}]/groups/link:#group-id[\{group-id\}]'

Deletes an included group from a Gerrit internal group.

.Request
----
  DELETE /groups/MyProject-Committers/groups/MyGroup HTTP/1.0
----

.Response
----
  HTTP/1.1 204 No Content
----

[[delete-included-groups]]
Delete Included Groups
~~~~~~~~~~~~~~~~~~~~~~
[verse]
'POST /groups/link:#group-id[\{group-id\}]/groups.delete'

Delete one or several included groups from a Gerrit internal group.

The groups to be deleted from the group must be provided in the request
body as a link:#groups-input[GroupsInput] entity.

.Request
----
  POST /groups/MyProject-Committers/groups.delete HTTP/1.0
  Content-Type: application/json;charset=UTF-8

  {
    "members": {
      "MyGroup",
      "MyOtherGroup"
    }
  }
----

.Response
----
  HTTP/1.1 204 No Content
----


[[ids]]
IDs
---

[[account-id]]
link:rest-api-accounts.html#account-id[\{account-id\}]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
--

[[group-id]]
\{group-id\}
~~~~~~~~~~~~
Identifier for a group.

This can be:

* the UUID of the group
* the legacy numeric ID of the group
* the name of the group if it is unique

[[group-name]]
\{group-name\}
~~~~~~~~~~~~~~
Group name that uniquely identifies one group.


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

[[group-info]]
GroupInfo
~~~~~~~~~
The `GroupInfo` entity contains information about a group. This can be
a Gerrit internal group, or an external group that is known to Gerrit.

[options="header",width="50%",cols="1,^1,5"]
|===========================
|Field Name    ||Description
|`kind`        ||`gerritcodereview#group`
|`id`          ||The URL encoded UUID of the group.
|`name`        |
not set if returned in a map where the group name is used as map key|
The name of the group.
|`url`         |optional|
URL to information about the group. Typically a URL to a web page that
permits users to apply to join the group, or manage their membership.
|`options`     ||link:#group-options-info[Options of the group]
|`description` |only for internal groups|The description of the group.
|`group_id`    |only for internal groups|The numeric ID of the group.
|`owner`       |only for internal groups|The name of the owner group.
|`owner_id`    |only for internal groups|The URL encoded UUID of the owner group.
|`members`     |optional, only for internal groups|
A list of link:rest-api-accounts.html#account-info[AccountInfo]
entities describing the direct members. +
Only set if link:#members[members] are requested.
|`includes`    |optional, only for internal groups|
A list of link:#group-info[GroupInfo] entities describing the directly
included groups. +
Only set if link:#includes[included groups] are requested.
|===========================

The type of a group can be deduced from the group's UUID:
[width="50%"]
|============
|UUID matches "^[0-9a-f]\{40\}$"|Gerrit internal group
|UUID starts with "global:"|Gerrit system group
|UUID starts with "ldap:"|LDAP group
|UUID starts with "<prefix>:"|other external group
|============

[[group-input]]
GroupInput
~~~~~~~~~~
The 'GroupInput' entity contains information for the creation of
a new internal group.

[options="header",width="50%",cols="1,^1,5"]
|===========================
|Field Name      ||Description
|`name`          |optional|The name of the group (not encoded). +
If set, must match the group name in the URL.
|`description`   |optional|The description of the group.
|`visible_to_all`|optional|
Whether the group is visible to all registered users. +
`false` if not set.
|`owner_id`|optional|The URL encoded ID of the owner group. +
This can be a group UUID, a legacy numeric group ID or a unique group
name. +
If not set, the new group will be self-owned.
|===========================

[[groups-input]]
GroupsInput
~~~~~~~~~~~
The `GroupsInput` entity contains information about groups that should
be included into a group or that should be deleted from a group.

[options="header",width="50%",cols="1,^1,5"]
|==========================
|Field Name   ||Description
|`_one_group` |optional|
The link:#group-id[id] of one group that should be included or deleted.
|`groups`     |optional|
A list of link:#group-id[group ids] that identify the groups that
should be included or deleted.
|==========================

[[group-options-info]]
GroupOptionsInfo
~~~~~~~~~~~~~~~~
Options of the group.

[options="header",width="50%",cols="1,^1,5"]
|=============================
|Field Name      ||Description
|`visible_to_all`|not set if `false`|
Whether the group is visible to all registered users.
|=============================

[[group-options-input]]
GroupOptionsInput
~~~~~~~~~~~~~~~~~
New options for a group.

[options="header",width="50%",cols="1,^1,5"]
|=============================
|Field Name      ||Description
|`visible_to_all`|not set if `false`|
Whether the group is visible to all registered users.
|=============================

[[members-input]]
MembersInput
~~~~~~~~~~~
The `MembersInput` entity contains information about accounts that should
be added as members to a group or that should be deleted from the group.

[options="header",width="50%",cols="1,^1,5"]
|==========================
|Field Name   ||Description
|`_one_member`|optional|
The link:#account-id[id] of one account that should be added or
deleted.
|`members`    |optional|
A list of link:#account-id[account ids] that identify the accounts that
should be added or deleted.
|==========================


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