1
1
///usr/bin/env jbang "$0" "$@" ; exit $?
2
2
3
3
//DEPS info.picocli:picocli:4.6.3
4
- //DEPS https://github.com/unblu/gitlab-workitem-graphql-client/commit/b93a9f97e53e2647a0531c33b2dc67be940fd80c
4
+ //DEPS https://github.com/unblu/gitlab-workitem-graphql-client/commit/96673d87850c148ef174fbf4c5d163db745ae3ea
5
5
//DEPS io.smallrye:smallrye-graphql-client-implementation-vertx:2.11.0
6
6
//DEPS org.jboss.logmanager:jboss-logmanager:3.1.1.Final
7
7
//JAVA 17
25
25
import graphql .gitlab .model .WorkItemID ;
26
26
import graphql .gitlab .model .WorkItemUpdateInput ;
27
27
import graphql .gitlab .model .WorkItemUpdatePayload ;
28
- import graphql .gitlab .model .WorkItemWidgetHierarchyUpdateInput ;
28
+ import graphql .gitlab .model .WorkItemWidgetHierarchyUpdateInputWithChildren ;
29
+ import graphql .gitlab .model .WorkItemWidgetHierarchyUpdateInputWithParent ;
29
30
import io .smallrye .graphql .client .typesafe .api .TypesafeGraphQLClientBuilder ;
30
31
import picocli .CommandLine ;
31
32
import picocli .CommandLine .Command ;
@@ -52,7 +53,10 @@ public class WorkItemScript implements Callable<Integer> {
52
53
@ Option (names = { "-p" , "--parentId" }, description = "workitem parentId" )
53
54
private String parentId ;
54
55
55
- @ Option (names = { "-r" , "--ref" , "--reference" }, description = "references in the namespace" )
56
+ @ Option (names = { "-s" , "--childId" }, description = "workitem childrenIds" )
57
+ private List <String > childrenIds ;
58
+
59
+ @ Option (names = { "-r" , "--h" , "--reference" }, description = "references in the namespace" )
56
60
private List <String > refs ;
57
61
58
62
@ Option (names = { "-c" , "--config" }, description = "configuration file location" )
@@ -62,7 +66,7 @@ public class WorkItemScript implements Callable<Integer> {
62
66
Boolean logHttp ;
63
67
64
68
private static enum Action {
65
- GET_WORKITEM , DELETE_WORKITEM , ADD_PARENT , REMOVE_PARENT
69
+ GET_WORKITEM , DELETE_WORKITEM , ADD_PARENT , REMOVE_PARENT , ADD_CHILDREN
66
70
}
67
71
68
72
@ Override
@@ -93,6 +97,9 @@ public Integer call() throws Exception {
93
97
case REMOVE_PARENT :
94
98
deleteParent (api );
95
99
break ;
100
+ case ADD_CHILDREN :
101
+ addChildren (api );
102
+ break ;
96
103
default :
97
104
throw new IllegalArgumentException ("Unexpected value: " + action );
98
105
}
@@ -120,7 +127,7 @@ private void addParent(WorkitemClientApi api) {
120
127
ensureExists (parentId , "parentId" );
121
128
WorkItemUpdatePayload response = api .workItemUpdate (new WorkItemUpdateInput ()
122
129
.setId (new WorkItemID (id ))
123
- .setHierarchyWidget (new WorkItemWidgetHierarchyUpdateInput () //
130
+ .setHierarchyWidget (new WorkItemWidgetHierarchyUpdateInputWithParent () //
124
131
.setParentId (new WorkItemID (parentId )) //
125
132
) //
126
133
);
@@ -131,7 +138,21 @@ private void deleteParent(WorkitemClientApi api) {
131
138
ensureExists (id , "id" );
132
139
WorkItemUpdatePayload response = api .workItemUpdate (new WorkItemUpdateInput ()
133
140
.setId (new WorkItemID (id ))
134
- .setHierarchyWidget (new WorkItemWidgetHierarchyUpdateInput ().setParentId (null )));
141
+ .setHierarchyWidget (new WorkItemWidgetHierarchyUpdateInputWithParent ().setParentId (null )));
142
+ System .out .println (response );
143
+ }
144
+
145
+ private void addChildren (WorkitemClientApi api ) {
146
+ ensureExists (id , "id" );
147
+ ensureExists (childrenIds , "childId" );
148
+ WorkItemUpdatePayload response = api .workItemUpdate (new WorkItemUpdateInput ()
149
+ .setId (new WorkItemID (id ))
150
+ .setHierarchyWidget (new WorkItemWidgetHierarchyUpdateInputWithChildren () //
151
+ .setChildrenIds (childrenIds .stream ()
152
+ .map (WorkItemID ::new )
153
+ .toList ()) //
154
+ ) //
155
+ );
135
156
System .out .println (response );
136
157
}
137
158
0 commit comments