Module bus.gitlab

Class PersonalAccessTokenApi

java.lang.Object
org.miaixz.bus.gitlab.AbstractApi
org.miaixz.bus.gitlab.PersonalAccessTokenApi
All Implemented Interfaces:
Constants

public class PersonalAccessTokenApi extends AbstractApi
This class provides an entry point to all the GitLab API personal access token calls.
See Also:
  • Constructor Details

    • PersonalAccessTokenApi

      public PersonalAccessTokenApi(GitLabApi gitLabApi)
  • Method Details

    • rotatePersonalAccessToken

      public PersonalAccessToken rotatePersonalAccessToken() throws GitLabApiException
      Rotates the given personal access token. The token is revoked and a new one which will expire in one week is created to replace it. Only working with GitLab 16.0 and above.
       GitLab Endpoint: POST /personal_access_tokens/self/rotate
       
      Returns:
      the newly created PersonalAccessToken.
      Throws:
      GitLabApiException - if any exception occurs
    • rotatePersonalAccessToken

      public PersonalAccessToken rotatePersonalAccessToken(Date expiresAt) throws GitLabApiException
      Rotates the personal access token used in the request header. The token is revoked and a new one which will expire at the given expiresAt-date is created to replace it. Only working with GitLab 16.0 and above.
       GitLab Endpoint: POST /personal_access_tokens/self/rotate
       
      Parameters:
      expiresAt - Expiration date of the access token
      Returns:
      the newly created PersonalAccessToken.
      Throws:
      GitLabApiException - if any exception occurs
    • rotatePersonalAccessToken

      public PersonalAccessToken rotatePersonalAccessToken(String id, Date expiresAt) throws GitLabApiException
      Rotates a specific personal access token. The token is revoked and a new one which will expire at the given expiresAt-date is created to replace it. Only working with GitLab 16.0 and above.
       GitLab Endpoint: POST /personal_access_tokens/:id/rotate
       
      Parameters:
      id - ID of the personal access token
      expiresAt - Expiration date of the access token
      Returns:
      the newly created PersonalAccessToken.
      Throws:
      GitLabApiException - if any exception occurs
    • getPersonalAccessTokens

      public List<PersonalAccessToken> getPersonalAccessTokens() throws GitLabApiException
      Get information about the personal access token used in the request header. Only working with GitLab 16.0 and above.
       GitLab Endpoint: GET /personal_access_tokens
       
      Returns:
      the specified PersonalAccessToken.
      Throws:
      GitLabApiException - if any exception occurs
    • getPersonalAccessToken

      public PersonalAccessToken getPersonalAccessToken() throws GitLabApiException
      Get information about the personal access token used in the request header. Only working with GitLab 16.0 and above.
       GitLab Endpoint: GET /personal_access_tokens/self
       
      Returns:
      the specified PersonalAccessToken.
      Throws:
      GitLabApiException - if any exception occurs
    • getPersonalAccessToken

      public PersonalAccessToken getPersonalAccessToken(String id) throws GitLabApiException
      Get a specific personal access token. Only working with GitLab 16.0 and above.
       GitLab Endpoint: GET /personal_access_tokens/:id
       
      Parameters:
      id - ID of the personal access token
      Returns:
      the specified PersonalAccessToken.
      Throws:
      GitLabApiException - if any exception occurs
    • revokePersonalAccessToken

      public void revokePersonalAccessToken(Long tokenId) throws GitLabApiException
      Revokes a personal access token. Available only for admin users.
       GitLab Endpoint: DELETE /personal_access_tokens/:token_id
       
      Parameters:
      tokenId - the personal access token ID to revoke
      Throws:
      GitLabApiException - if any exception occurs