@@ -33,8 +33,8 @@ public PersonalAccessToken rotatePersonalAccessToken() throws GitLabApiException
33
33
}
34
34
35
35
/**
36
- * Rotates the given personal access token.
37
- * The token is revoked and a new one which will expire in one week is created to replace it.
36
+ * Rotates the personal access token used in the request header .
37
+ * The token is revoked and a new one which will expire at the given expiresAt-date is created to replace it.
38
38
* Only working with GitLab 16.0 and above.
39
39
*
40
40
* <pre><code>GitLab Endpoint: POST /personal_access_tokens/self/rotate</code></pre>
@@ -48,12 +48,13 @@ public PersonalAccessToken rotatePersonalAccessToken(Date expiresAt) throws GitL
48
48
}
49
49
50
50
/**
51
- * Rotates the given personal access token.
52
- * The token is revoked and a new one which will expire in one week is created to replace it.
51
+ * Rotates a specific personal access token.
52
+ * The token is revoked and a new one which will expire at the given expiresAt-date is created to replace it.
53
53
* Only working with GitLab 16.0 and above.
54
54
*
55
55
* <pre><code>GitLab Endpoint: POST /personal_access_tokens/:id/rotate</code></pre>
56
56
*
57
+ * @param id ID of the personal access token
57
58
* @param expiresAt Expiration date of the access token
58
59
* @return the newly created PersonalAccessToken.
59
60
* @throws GitLabApiException if any exception occurs
@@ -64,4 +65,32 @@ public PersonalAccessToken rotatePersonalAccessToken(String id, Date expiresAt)
64
65
Response response = post (Response .Status .OK , formData , "personal_access_tokens" , id , "rotate" );
65
66
return (response .readEntity (PersonalAccessToken .class ));
66
67
}
68
+
69
+ /**
70
+ * Get information about the personal access token used in the request header.
71
+ * Only working with GitLab 16.0 and above.
72
+ *
73
+ * <pre><code>GitLab Endpoint: GET /personal_access_tokens/self</code></pre>
74
+ *
75
+ * @return the specified PersonalAccessToken.
76
+ * @throws GitLabApiException if any exception occurs
77
+ */
78
+ public PersonalAccessToken getPersonalAccessToken () throws GitLabApiException {
79
+ return getPersonalAccessToken ("self" );
80
+ }
81
+
82
+ /**
83
+ * Get a specific personal access token.
84
+ * Only working with GitLab 16.0 and above.
85
+ *
86
+ * <pre><code>GitLab Endpoint: GET /personal_access_tokens/:id</code></pre>
87
+ *
88
+ * @param id ID of the personal access token
89
+ * @return the specified PersonalAccessToken.
90
+ * @throws GitLabApiException if any exception occurs
91
+ */
92
+ public PersonalAccessToken getPersonalAccessToken (String id ) throws GitLabApiException {
93
+ Response response = get (Response .Status .OK , null , "personal_access_tokens" , id );
94
+ return (response .readEntity (PersonalAccessToken .class ));
95
+ }
67
96
}
0 commit comments