Interface ApiEntity<T>

Type Parameters:
T - the type of the successful response
All Known Implementing Classes:
ApiEntity.Error, ApiEntity.Response, ApiEntity.Unknown

public interface ApiEntity<T>
Represents a possible response entity from the Orchestration Cluster REST API, either a successful response of type ApiEntity, or a ProblemDetail returned by the server.
  • Method Details

    • response

      T response()
      Returns:
      a successful response if any
      Throws:
      NoSuchElementException - if this is any other API entity
    • problem

      ProblemDetail problem()
      Returns:
      a problem returned by the server if any
      Throws:
      NoSuchElementException - if this is any other API entity
    • unknown

      ByteBuffer unknown()
      Returns:
      a raw byte buffer of the consumed body returned by the server, e.g. when it returns a body with unknown content type
      Throws:
      NoSuchElementException - if this is any other API entity
    • isResponse

      default boolean isResponse()
      Returns:
      true if there is a response, false otherwise; always returns the opposite of isProblem()
    • isProblem

      default boolean isProblem()
      Returns:
      true if there is a problem, false otherwise; always returns the opposite of isResponse()
    • isUnknown

      default boolean isUnknown()
      Returns:
      true if the response is neither a problem nor an expected JSON body
    • of

      static <T> ApiEntity<T> of(T response)
    • of

      static <T> ApiEntity<T> of(ProblemDetail error)
    • of

      static <T> ApiEntity<T> of(ByteBuffer body)