Class ApiTokensImpl

java.lang.Object
io.mailtrap.api.apiresource.ApiResource
io.mailtrap.api.apitokens.ApiTokensImpl
All Implemented Interfaces:
ApiTokens

public class ApiTokensImpl extends ApiResource implements ApiTokens
  • Constructor Details

  • Method Details

    • getAllApiTokens

      public List<ApiToken> getAllApiTokens(long accountId)
      Description copied from interface: ApiTokens
      List all API tokens visible to the current API token.
      Specified by:
      getAllApiTokens in interface ApiTokens
      Parameters:
      accountId - unique account ID
      Returns:
      list of API tokens
    • createApiToken

      public ApiTokenWithToken createApiToken(long accountId, CreateApiTokenRequest request)
      Description copied from interface: ApiTokens
      Create a new API token for the account with the given name and resource permissions. The full token value is returned only on creation. Without an explicit expiration in the request the server assigns its default lifetime (currently 1 year); use TokenExpiration.never() for a token that never expires.
      Specified by:
      createApiToken in interface ApiTokens
      Parameters:
      accountId - unique account ID
      request - token name and resource permissions
      Returns:
      created token, including the full token value
    • getApiToken

      public ApiToken getApiToken(long accountId, long id)
      Description copied from interface: ApiTokens
      Get a single API token by id.
      Specified by:
      getApiToken in interface ApiTokens
      Parameters:
      accountId - unique account ID
      id - API token ID
      Returns:
      API token
    • deleteApiToken

      public void deleteApiToken(long accountId, long id)
      Description copied from interface: ApiTokens
      Permanently delete an API token.
      Specified by:
      deleteApiToken in interface ApiTokens
      Parameters:
      accountId - unique account ID
      id - API token ID
    • resetApiToken

      public ApiTokenWithToken resetApiToken(long accountId, long id)
      Description copied from interface: ApiTokens
      Reset an API token. Expires the requested token and creates a new one with the same permissions; the new token value is returned only once. The new token gets the server default lifetime (currently 1 year); use ApiTokens.resetApiToken(long, long, ResetApiTokenRequest) to set the expiration explicitly, including a token that never expires.
      Specified by:
      resetApiToken in interface ApiTokens
      Parameters:
      accountId - unique account ID
      id - API token ID
      Returns:
      new token, including the full token value
    • resetApiToken

      public ApiTokenWithToken resetApiToken(long accountId, long id, ResetApiTokenRequest request)
      Description copied from interface: ApiTokens
      Reset an API token. Expires the requested token and creates a new one with the same permissions; the new token value is returned only once. The request can set the new token expiration; omit it for the server default.
      Specified by:
      resetApiToken in interface ApiTokens
      Parameters:
      accountId - unique account ID
      id - API token ID
      request - optional new token expiration
      Returns:
      new token, including the full token value