Class AuthenticatedAPIHandler

  • Direct Known Subclasses:
    AppAPI, AuthAPI, GraphAPI

    public abstract class AuthenticatedAPIHandler
    extends AbstractAPIHandler
    This class is the basis of all authenticated API handlers that make use of the different sections of the HIRO API.
    • Field Detail

      • apiName

        protected final java.lang.String apiName
      • apiPath

        protected final java.lang.String apiPath
      • apiUri

        protected java.net.URI apiUri
    • Constructor Detail

      • AuthenticatedAPIHandler

        protected AuthenticatedAPIHandler​(AuthenticatedAPIHandler.Conf<?> builder)
        Create this APIHandler by using its Builder.
        Parameters:
        builder - The builder to use.
    • Method Detail

      • getEndpointUri

        public java.net.URI getEndpointUri​(URIPath path,
                                           java.util.Map<java.lang.String,​java.lang.String> query,
                                           java.lang.String fragment)
                                    throws java.io.IOException,
                                           java.lang.InterruptedException,
                                           HiroException
        Construct my URI with query parameters and fragment. This method will query /api/version once to construct the URI unless apiPath is set.
        Parameters:
        path - The path to append to the API path.
        query - Map of query parameters for this URI. Can be null for no query parameters.
        fragment - The fragment to add to the URI.
        Returns:
        The URI with query parameters and fragment.
        Throws:
        java.io.IOException - On a failed call to /api/version
        java.lang.InterruptedException - Call got interrupted
        HiroException - When calling /api/version responds with an error
      • addToHeaders

        public void addToHeaders​(java.util.Map<java.lang.String,​java.lang.String> headers)
                          throws java.lang.InterruptedException,
                                 java.io.IOException,
                                 HiroException
        Add Authorization.
        Specified by:
        addToHeaders in class AbstractAPIHandler
        Parameters:
        headers - Map of headers with initial values.
        Throws:
        java.lang.InterruptedException - When a call (possibly of an overwritten method) gets interrupted.
        java.io.IOException - On IO errors.
        HiroException - On internal errors regarding hiro data processing.
      • getOrBuildClient

        protected java.net.http.HttpClient getOrBuildClient()
        Redirect the HttpClient to the one provided in tokenAPIHandler.
        Specified by:
        getOrBuildClient in class AbstractAPIHandler
        Returns:
        The HttpClient to use with this class.