Interface RestApi

    • Method Detail

      • get

        default <R,​T extends ApiOptionalResponse<R>> Single<T> get​(String path,
                                                                         ApiRequest<?> request,
                                                                         ApiOptionalResponse.BuilderBase<?,​T,​JsonObject,​R> responseBuilder)
        Get with an optional response. In case the call returns Http.Status.NOT_FOUND_404 this would return an empty optional entity, rather than fail. This may also be the case for requests that use If-Modified-Since that return a Http.Status.NOT_MODIFIED_304 response code.
        Type Parameters:
        R - type of the optional part of the response
        T - type of the response
        Parameters:
        path - path to invoke
        request - request to use
        responseBuilder - builder with appropriate response processor
        Returns:
        future with response if successful or not found, future with error otherwise
      • getPublisher

        default <R,​T extends ApiOptionalResponse<R>> Single<T> getPublisher​(String path,
                                                                                  ApiRequest<?> request,
                                                                                  ApiOptionalResponse.BuilderBase<?,​T,​Multi<DataChunk>,​R> responseBuilder)
        Get with a response consisting of a stream.
        Type Parameters:
        R - type of the optional part of the response
        T - type of the response
        Parameters:
        path - path to invoke
        request - request to use
        responseBuilder - builder with appropriate response processor
        Returns:
        future with response if successful or not found, future with error otherwise
      • post

        default <T extends ApiResponseSingle<T> post​(String path,
                                                       ApiRequest<?> request,
                                                       ApiResponse.Builder<?,​T> responseBuilder)
        Post without a response entity.
        Type Parameters:
        T - type of the response
        Parameters:
        path - path to invoke
        request - request to use, should be an instance of ApiJsonRequest if an entity is desired
        responseBuilder - builder to construct response from API call
        Returns:
        future with metadata if successful, future with error otherwise
      • put

        default <T extends ApiResponseSingle<T> put​(String path,
                                                      ApiRequest<?> request,
                                                      ApiResponse.Builder<?,​T> responseBuilder)
        Put without a response entity.
        Type Parameters:
        T - type of the response
        Parameters:
        path - path to invoke
        request - request to use, should be an instance of ApiJsonRequest if an entity is desired
        responseBuilder - builder to construct response from API call
        Returns:
        future with metadata if successful, future with error otherwise
      • delete

        default <T extends ApiResponseSingle<T> delete​(String path,
                                                         ApiRequest<?> request,
                                                         ApiResponse.Builder<?,​T> responseBuilder)
        Delete without a response entity.
        Type Parameters:
        T - type of the response
        Parameters:
        path - path to invoke
        request - request to use, should be an instance of ApiJsonRequest if an entity is desired
        responseBuilder - builder to construct response from API call
        Returns:
        future with metadata if successful, future with error otherwise
      • invoke

        <T extends ApiResponseSingle<T> invoke​(Http.RequestMethod method,
                                                 String path,
                                                 ApiRequest<?> request,
                                                 ApiResponse.Builder<?,​T> responseBuilder)
        Invoke a request that is not expected to yield an entity.
        Type Parameters:
        T - type of the response
        Parameters:
        method - HTTP method to invoke
        path - path to invoke
        request - request to use, should be an instance of ApiJsonRequest if and entity is desired
        responseBuilder - builder to construct response from API call
        Returns:
        future with metadata if successful. future with error otherwise
      • invokeWithResponse

        <T extends ApiEntityResponseSingle<T> invokeWithResponse​(Http.RequestMethod method,
                                                                   String path,
                                                                   ApiRequest<?> request,
                                                                   ApiEntityResponse.Builder<?,​T,​JsonObject> responseBuilder)
        Invoke a request that is expected to yield an entity.
        Type Parameters:
        T - type of the response
        Parameters:
        method - HTTP method to invoke
        path - path to invoke
        request - request to use, should be an instance of ApiJsonRequest if and entity is desired
        responseBuilder - builder to construct response from API call
        Returns:
        future with entity and metadata if successful, future with error otherwise
      • invokeBytesRequest

        <T extends ApiResponseSingle<T> invokeBytesRequest​(Http.RequestMethod method,
                                                             String path,
                                                             ApiRequest<?> request,
                                                             Flow.Publisher<DataChunk> byteRequest,
                                                             ApiResponse.Builder<?,​T> responseBuilder)
        The request media type should be provided in request, falls back to MediaType.APPLICATION_OCTET_STREAM.
        Type Parameters:
        T - type of the response
        Parameters:
        method - method to invoke
        path - path to invoke
        request - request used to configure query parameters and headers
        byteRequest - bytes of the entity
        responseBuilder - builder to construct response from API call
        Returns:
        future with the response or error
      • invokePublisherResponse

        <R,​T extends ApiOptionalResponse<R>> Single<T> invokePublisherResponse​(Http.RequestMethod method,
                                                                                     String path,
                                                                                     ApiRequest<?> request,
                                                                                     ApiOptionalResponse.BuilderBase<?,​T,​Multi<DataChunk>,​R> responseBuilder)
        Invoke API call that is expected to return bytes as a publisher. The accepted media type must be provided in request, falls back to MediaType.APPLICATION_OCTET_STREAM.
        Type Parameters:
        R - type of the optional part of the response
        T - type of the response
        Parameters:
        method - method to invoke
        path - path to invoke
        request - request used to configure query parameters and headers
        responseBuilder - builder to construct response from API call with appropriate processor to handle the returned publisher
        Returns:
        future with the response
      • invokeOptional

        <R,​T extends ApiOptionalResponse<R>> Single<T> invokeOptional​(Http.RequestMethod method,
                                                                            String path,
                                                                            ApiRequest<?> request,
                                                                            ApiOptionalResponse.BuilderBase<?,​T,​JsonObject,​R> responseBuilder)
        Invoke a request that may yield an entity. The entity is expected to be missing if Http.Status.NOT_FOUND_404 is returned by the API call (and for some other cases, such as not modified).
        Type Parameters:
        R - type of the optional part of the response
        T - type of the response
        Parameters:
        method - HTTP method to invoke
        path - path to invoke
        request - request to use, should be an instance of ApiJsonRequest if and entity is desired
        responseBuilder - response builder with appropriate processor to create the optional part
        Returns:
        future with optional entity, and metadata if successful; future with error otherwise