All Known Implementing Classes:
RestApiBase, VaultRestApi

public interface RestApi
JSON based REST API operations.
  • Method Details

    • 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
    • getBytes

      default <R, T extends ApiOptionalResponse<R>> Single<T> getBytes(String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?,T,byte[],R> responseBuilder)
      Get bytes with an optional response.
      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 ApiOptionalResponse.BuilderBase.entityProcessor(java.util.function.Function)
      Returns:
      future with the response, that may or may not contain an entity (for 404 the entity would be empty)
    • post

      default <T extends ApiResponse> Single<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 ApiResponse> Single<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 ApiResponse> Single<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 ApiResponse> Single<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 ApiEntityResponse> Single<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 ApiResponse> Single<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
    • invokeBytesResponse

      <R, T extends ApiOptionalResponse<R>> Single<T> invokeBytesResponse(Http.RequestMethod method, String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?,T,byte[],R> responseBuilder)
      Invoke API call that is expected to return bytes. This method collects all bytes in memory, so it cannot be used for large data. See invokePublisherResponse(io.helidon.common.http.Http.RequestMethod, String, ApiRequest, io.helidon.integrations.common.rest.ApiOptionalResponse.BuilderBase). 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 bytes
      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