Skip to content

Commit eb66036

Browse files
committed
Merge remote-tracking branch 'origin/main' into 6.x
2 parents b0e731a + 5805b41 commit eb66036

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

src/main/java/org/gitlab4j/api/PersonalAccessTokenApi.java

+33-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public PersonalAccessToken rotatePersonalAccessToken() throws GitLabApiException
3333
}
3434

3535
/**
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.
3838
* Only working with GitLab 16.0 and above.
3939
*
4040
* <pre><code>GitLab Endpoint: POST /personal_access_tokens/self/rotate</code></pre>
@@ -48,12 +48,13 @@ public PersonalAccessToken rotatePersonalAccessToken(Date expiresAt) throws GitL
4848
}
4949

5050
/**
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.
5353
* Only working with GitLab 16.0 and above.
5454
*
5555
* <pre><code>GitLab Endpoint: POST /personal_access_tokens/:id/rotate</code></pre>
5656
*
57+
* @param id ID of the personal access token
5758
* @param expiresAt Expiration date of the access token
5859
* @return the newly created PersonalAccessToken.
5960
* @throws GitLabApiException if any exception occurs
@@ -64,4 +65,32 @@ public PersonalAccessToken rotatePersonalAccessToken(String id, Date expiresAt)
6465
Response response = post(Response.Status.OK, formData, "personal_access_tokens", id, "rotate");
6566
return (response.readEntity(PersonalAccessToken.class));
6667
}
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+
}
6796
}

0 commit comments

Comments
 (0)