@@ -60,6 +60,9 @@ public class ProjectAccessTokenScript implements Callable<Integer> {
6060 @ Option (names = { "-c" , "--config" }, description = "configuration file location" )
6161 String configFile ;
6262
63+ @ Option (names = { "-v" , "--verbose" }, description = "log http trafic" )
64+ Boolean logHttp ;
65+
6366 private static enum Action {
6467 LIST_PROJECT_ACCESS_TOKEN , GET_PROJECT_ACCESS_TOKEN , CREATE_PROJECT_ACCESS_TOKEN , ROTATE_PROJECT_ACCESS_TOKEN , REVOKE_PROJECT_ACCESS_TOKEN
6568 }
@@ -79,7 +82,7 @@ public Integer call() throws Exception {
7982
8083 ensureExists (project , "project" );
8184
82- try (GitLabApi gitLabApi = new GitLabApi (gitLabUrl , gitLabAuthValue )) {
85+ try (GitLabApi gitLabApi = createGitLabApi (gitLabUrl , gitLabAuthValue )) {
8386 switch (action ) {
8487 case LIST_PROJECT_ACCESS_TOKEN :
8588 var tokens = gitLabApi .getProjectApi ()
@@ -93,6 +96,7 @@ public Integer call() throws Exception {
9396 System .out .println (token );
9497 break ;
9598 case CREATE_PROJECT_ACCESS_TOKEN :
99+ ensureExists (tokenName , "tokenName" );
96100 var createdToken = gitLabApi .getProjectApi ()
97101 .createProjectAccessToken (idOrPath (project ), tokenName , scopes , expiresAt , accessLevelValue (accessLevel ));
98102 System .out .println (createdToken );
@@ -113,6 +117,14 @@ public Integer call() throws Exception {
113117 return 0 ;
114118 }
115119
120+ private GitLabApi createGitLabApi (String gitLabUrl , String gitLabAuthValue ) {
121+ if (logHttp != null && logHttp ) {
122+ return new GitLabApi (gitLabUrl , gitLabAuthValue )
123+ .withRequestResponseLogging (java .util .logging .Level .INFO );
124+ }
125+ return new GitLabApi (gitLabUrl , gitLabAuthValue );
126+ }
127+
116128 private static Long accessLevelValue (AccessLevel value ) {
117129 if (value == null ) {
118130 return null ;
0 commit comments