@@ -42,7 +42,7 @@ public class GroupScript implements Callable<Integer> {
42
42
Boolean logHttp ;
43
43
44
44
private static enum Action {
45
- GET_GROUP , GET_GROUP_LABELS , GET_GROUP_UPLOADS
45
+ GET_GROUP , GET_ALL_GROUPS , GET_SUB_GROUPS , GET_DESCENDANT_GROUPS , GET_GROUP_LABELS , GET_GROUP_UPLOADS
46
46
}
47
47
48
48
@ Override
@@ -58,7 +58,6 @@ public Integer call() throws Exception {
58
58
final String gitLabUrl = readProperty (prop , "GITLAB_URL" , "https://gitlab.com" );
59
59
final String gitLabAuthValue = readProperty (prop , "GITLAB_AUTH_VALUE" );
60
60
61
-
62
61
try (GitLabApi gitLabApi = createGitLabApi (gitLabUrl , gitLabAuthValue )) {
63
62
switch (action ) {
64
63
case GET_GROUP :
@@ -67,6 +66,32 @@ public Integer call() throws Exception {
67
66
.getGroup (idOrPath (group ));
68
67
System .out .println (groupResponse );
69
68
break ;
69
+ case GET_ALL_GROUPS :
70
+ var groups = gitLabApi .getGroupApi ()
71
+ .getGroups ();
72
+ groups .stream ()
73
+ .sorted (Comparator .comparing (Group ::getFullName ))
74
+ .forEach (g -> {
75
+ System .out .println (g .getFullName ());
76
+ });
77
+ break ;
78
+ case GET_SUB_GROUPS :
79
+ ensureExists (group , "group" );
80
+ var subGroups = gitLabApi .getGroupApi ()
81
+ .getSubGroups (idOrPath (group ));
82
+ for (Group g : subGroups ) {
83
+ System .out .println (g .getFullName ());
84
+ }
85
+ break ;
86
+ case GET_DESCENDANT_GROUPS :
87
+ ensureExists (group , "group" );
88
+ var descendantGroups = gitLabApi .getGroupApi ()
89
+ .getDescendantGroups (idOrPath (group ), new GroupFilter ()
90
+ .withAllAvailable (true ));
91
+ for (Group g : descendantGroups ) {
92
+ System .out .println (g .getFullName ());
93
+ }
94
+ break ;
70
95
case GET_GROUP_LABELS :
71
96
ensureExists (group , "group" );
72
97
var labelsResponse = gitLabApi .getLabelsApi ()
@@ -89,12 +114,11 @@ public Integer call() throws Exception {
89
114
private GitLabApi createGitLabApi (String gitLabUrl , String gitLabAuthValue ) {
90
115
if (logHttp != null && logHttp ) {
91
116
return new GitLabApi (gitLabUrl , gitLabAuthValue )
92
- .withRequestResponseLogging (java .util .logging .Level .INFO ) ;
117
+ .withRequestResponseLogging (java .util .logging .Level .INFO );
93
118
}
94
119
return new GitLabApi (gitLabUrl , gitLabAuthValue );
95
120
}
96
121
97
-
98
122
private void ensureExists (Object value , String optionName ) {
99
123
if (value == null ) {
100
124
throw new IllegalStateException ("--" + optionName + " must be set" );
0 commit comments