Class BitbucketClient

    • Field Detail

      • API_BASE_URI

        protected static final URI API_BASE_URI
        Base URI of the Bitbucket API.
      • AUTHORIZATION_ENDPOINT_URI

        public static final URI AUTHORIZATION_ENDPOINT_URI
        Authorization endpoint URI.
      • TOKEN_ENDPOINT_URI

        public static final URI TOKEN_ENDPOINT_URI
        Token endpoint URI.
    • Constructor Detail

      • BitbucketClient

        public BitbucketClient()
        Constructs this object with a new ClientBuilder object.
    • Method Detail

      • getClientId

        public final String getClientId()
        Returns the client identifier for OAuth.
        Returns:
        the client identifier
      • setClientId

        public final void setClientId​(String newValue)
        Sets the client identifier for OAuth.
        Parameters:
        newValue - a new value of the client identifier
      • setClientSecret

        public final void setClientSecret​(String newValue)
        Sets the client secret for OAuth.
        Parameters:
        newValue - a new value of the client secret.
      • getAccessToken

        public final String getAccessToken()
        Returns the access token.
        Returns:
        the access token
      • setAccessToken

        public final void setAccessToken​(String newValue)
        Sets the access token.
        Parameters:
        newValue - new value of the access token
      • getRefreshToken

        public final String getRefreshToken()
        Returns the refresh token.
        Returns:
        the refresh token
      • setRefreshToken

        public final void setRefreshToken​(String newValue)
        Sets the refresh token.
        Parameters:
        newValue - a new value of the refresh token
      • getAccessTokenExpiry

        public final Instant getAccessTokenExpiry()
        Returns the time when the access token expires.
        Returns:
        the time when the access token expires
      • setAccessTokenExpiry

        public final void setAccessTokenExpiry​(Instant newValue)
        Sets the time when the access token expires.
        Parameters:
        newValue - new value of the time when the access token expires
      • addTokenRefreshListener

        public final void addTokenRefreshListener​(TokenRefreshListener listener)
        Adds a token refresh listener.
        Parameters:
        listener - a token refresh listener
      • removeTokenRefreshListener

        public final void removeTokenRefreshListener​(TokenRefreshListener listener)
        Removes a token refresh listener.
        Parameters:
        listener - a token refresh listener
      • loginWithAuthorizationCode

        public final void loginWithAuthorizationCode​(String code,
                                                     URI redirectionUri)
        Logs in with an authorization code.
        Parameters:
        code - an authorization code
        redirectionUri - a redirection URI
      • login

        public final void login​(String username,
                                String password)
        Logs in with resource owner password credentials.
        Parameters:
        username - a username
        password - a password
      • logout

        public final void logout()
        Logs out.
      • get

        public final JsonObject get​(URI link)
        Gets a JSON object by a link.
        Parameters:
        link - the URI for a link
        Returns:
        a JSON object if one was found; null otherwise
      • get

        public final <T> T get​(URI link,
                               String[] mediaTypes,
                               Class<T> type)
        Gets a media object by a link.
        Type Parameters:
        T - return type
        Parameters:
        link - the URI for a link
        mediaTypes - acceptable MIME media types
        type - the type of the media object to return
        Returns:
        media object if one was found; null otherwise
      • post

        public final JsonObject post​(URI uri,
                                     Entity<?> entity)
        Makes a (@code POST} request to a URI.
        Parameters:
        uri - a URI
        entity - an entity to post
        Returns:
        a JSON object
      • getResource

        public final JsonObject getResource​(String path,
                                            Map<String,​Object> values)
        Gets a JSON object from a resource.
        Parameters:
        path - path of the resource with templates
        values - template values, or null
        Returns:
        JSON object if found, null otherwise
      • getUser

        public final BitbucketAccount getUser​(String name)
        Returns an account resource for a user.

        This implementation gets the user resource remotely from Bitbucket Cloud.

        Specified by:
        getUser in interface Bitbucket
        Parameters:
        name - the name of a user
        Returns:
        an account resource for a user
      • getTeam

        public final BitbucketAccount getTeam​(String name)
        Returns an account resource for a team.

        This implementation gets the team resource remotely from Bitbucket Cloud.

        Specified by:
        getTeam in interface Bitbucket
        Parameters:
        name - the name of a team
        Returns:
        an account resource for a team
      • getRepository

        public final BitbucketRepository getRepository​(String ownerName,
                                                       String name)
        Returns a repository resource for a repository.

        This implementation gets the repository resource remotely from Bitbucket Cloud.

        Specified by:
        getRepository in interface Bitbucket
        Parameters:
        ownerName - the owner name of a repository
        name - the name of a repository
        Returns:
        a repository resource for a repository