Interface B2WebApiClient

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface B2WebApiClient
    extends java.lang.AutoCloseable
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Closes this object and its underlying resources.
      void getContent​(java.lang.String url, B2Headers headersOrNull, B2ContentSink handler)
      GETs from a web service that returns content.
      B2Headers head​(java.lang.String url, B2Headers headersOrNull)
      HEADSs to a web service that returns content, and returns the headers.
      <ResponseType>
      ResponseType
      postDataReturnJson​(java.lang.String url, B2Headers headersOrNull, java.io.InputStream contentSource, long contentLength, java.lang.Class<ResponseType> responseClass)
      POSTs to a web service that takes content and returns JSON.
      <ResponseType>
      ResponseType
      postJsonReturnJson​(java.lang.String url, B2Headers headersOrNull, java.lang.Object request, java.lang.Class<ResponseType> responseClass)
      POSTs to a web service that takes JSON and returns JSON.
    • Method Detail

      • postJsonReturnJson

        <ResponseType> ResponseType postJsonReturnJson​(java.lang.String url,
                                                       B2Headers headersOrNull,
                                                       java.lang.Object request,
                                                       java.lang.Class<ResponseType> responseClass)
                                                throws B2Exception
        POSTs to a web service that takes JSON and returns JSON.
        Type Parameters:
        ResponseType - the class
        Parameters:
        url - the url to post to
        headersOrNull - if non-null, some headers to include in the post
        request - the object to be converted to json (with B2Json) and posted as the body of the request
        responseClass - the class to convert the response body into (with B2Json)
        Returns:
        the response object (converted from json by B2Json)
        Throws:
        B2Exception - if there's any trouble
      • postDataReturnJson

        <ResponseType> ResponseType postDataReturnJson​(java.lang.String url,
                                                       B2Headers headersOrNull,
                                                       java.io.InputStream contentSource,
                                                       long contentLength,
                                                       java.lang.Class<ResponseType> responseClass)
                                                throws B2Exception
        POSTs to a web service that takes content and returns JSON.
        Type Parameters:
        ResponseType - the class
        Parameters:
        url - the url to post to
        headersOrNull - if non-null, some headers to include in the post
        contentSource - the content to post as the body of the request
        contentLength - the number of bytes in the content to post
        responseClass - the class to convert the response body into (with B2Json)
        Returns:
        the response object (converted from json by B2Json)
        Throws:
        B2Exception - if there's any trouble
      • getContent

        void getContent​(java.lang.String url,
                        B2Headers headersOrNull,
                        B2ContentSink handler)
                 throws B2Exception
        GETs from a web service that returns content.
        Parameters:
        url - the url to post to
        headersOrNull - if non-null, some headers to include in the post
        handler - the object which will be called with the response's headers and content
        Throws:
        B2Exception - if there's any trouble
      • head

        B2Headers head​(java.lang.String url,
                       B2Headers headersOrNull)
                throws B2Exception
        HEADSs to a web service that returns content, and returns the headers.
        Parameters:
        url - the url to head to
        headersOrNull - the headers, if any.
        Returns:
        the headers of the response.
        Throws:
        B2Exception - if there's any trouble
      • close

        void close()
        Closes this object and its underlying resources. This is overridden from AutoCloseable to declare that it can't throw any exception.
        Specified by:
        close in interface java.lang.AutoCloseable