All Known Implementing Classes:
RestApiBase, VaultRestApi

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

    • get

      default <R, T extends ApiOptionalResponse<R>> T get(String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?,T,JsonObject,R> responseBuilder)
      Get with an optional response. In case the call returns 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 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:
      response
    • getEntityStream

      default <R, T extends ApiOptionalResponse<R>> T getEntityStream(String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?,T,InputStream,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:
      response
    • getBytes

      default <R, T extends ApiOptionalResponse<R>> 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:
      response, that may or may not contain an entity (for 404 the entity would be empty)
    • post

      default <T extends ApiResponse> 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:
      response
    • put

      default <T extends ApiResponse> 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:
      response
    • delete

      default <T extends ApiResponse> 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:
      response
    • invoke

      <T extends ApiResponse> T invoke(Method 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:
      response
    • invokeWithResponse

      <T extends ApiEntityResponse> T invokeWithResponse(Method 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> T invokeBytesRequest(Method method, String path, ApiRequest<?> request, InputStream is, ApiResponse.Builder<?,T> responseBuilder)
      The request media type should be provided in request, falls back to MediaTypes.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
      is - entity bytes
      responseBuilder - builder to construct response from API call
      Returns:
      future with the response or error
    • invokeEntityResponse

      <R, T extends ApiOptionalResponse<R>> T invokeEntityResponse(Method method, String path, ApiRequest<?> request, ApiOptionalResponse.BuilderBase<?,T,InputStream,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 MediaTypes.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>> T invokeBytesResponse(Method 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 invokeEntityResponse(io.helidon.http.Method, String, ApiRequest, BuilderBase).

      The accepted media type must be provided in request, falls back to MediaTypes.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:
      response
    • invokeOptional

      <R, T extends ApiOptionalResponse<R>> T invokeOptional(Method 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 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:
      response