Class HttpBindingIndex

  • All Implemented Interfaces:
    KnowledgeIndex

    public final class HttpBindingIndex
    extends java.lang.Object
    implements KnowledgeIndex
    Computes and indexes the explicit and implicit HTTP bindings of a model.

    This index makes it easy to understand how members of the input or output of a request/response are bound to an HTTP message by providing all of the bindings in the model as a normalized HttpBinding object. This can be used to validate the bindings of an operation, generate code to [de]serialize shapes, diff models to ensure backward compatibility at the wire level, etc.

    This index does not perform validation of the underlying model.

    • Constructor Detail

      • HttpBindingIndex

        public HttpBindingIndex​(Model model)
    • Method Detail

      • hasHttpRequestBindings

        public static boolean hasHttpRequestBindings​(Shape shape)
        Returns true if a shape has any HTTP request trait bindings.
        Parameters:
        shape - Shape to check.
        Returns:
        Returns true if the shape is bound to an HTTP header, payload, prefix headers, query string, or label.
      • hasHttpResponseBindings

        public static boolean hasHttpResponseBindings​(Shape shape)
        Returns true if a shape has any HTTP response trait bindings.
        Parameters:
        shape - Shape to check.
        Returns:
        Returns true if the shape is bound to an HTTP header, payload, of prefix headers.
      • getResponseCode

        public int getResponseCode​(ToShapeId shapeOrId)
        Gets the computed status code of an operation or error structure.
        Parameters:
        shapeOrId - Operation or error structure shape ID.
        Returns:
        Returns the computed HTTP status code.
        Throws:
        java.lang.IllegalArgumentException - if the given shape is not an operation or an error structure.
      • getRequestBindings

        public java.util.Map<java.lang.String,​HttpBinding> getRequestBindings​(ToShapeId operationShapeOrId)
        Gets the request bindings of an operation as a map of member name to the binding.
        Parameters:
        operationShapeOrId - Operation to get the request bindings for.
        Returns:
        Map of unmodifiable bindings.
        Throws:
        java.lang.IllegalArgumentException - if the given shape is not an operation.
      • getRequestBindings

        public java.util.List<HttpBinding> getRequestBindings​(ToShapeId operationShapeOrId,
                                                              HttpBinding.Location requestLocation)
        Gets the request bindings of an operation as a map of member name to the binding for a specific location type.
        Parameters:
        operationShapeOrId - Operation to get the request bindings for.
        requestLocation - Location of the binding.
        Returns:
        Map of unmodifiable bindings.
        Throws:
        java.lang.IllegalArgumentException - if the given shape is not an operation.
      • getResponseBindings

        public java.util.Map<java.lang.String,​HttpBinding> getResponseBindings​(ToShapeId shapeOrId)
        Gets the computed HTTP message response bindings for an operation or structure with an error trait.
        Parameters:
        shapeOrId - Operation or error structure shape or ID.
        Returns:
        Map of unmodifiable bindings.
        Throws:
        java.lang.IllegalArgumentException - if the given shape is not an operation or error structure.
      • getResponseBindings

        public java.util.List<HttpBinding> getResponseBindings​(ToShapeId shapeOrId,
                                                               HttpBinding.Location bindingLocation)
        Gets the computed HTTP message response bindings for an operation or structure with an error trait for a specific binding type.
        Parameters:
        shapeOrId - Operation or error structure shape or ID.
        bindingLocation - Binding location type.
        Returns:
        List of found bindings.
        Throws:
        java.lang.IllegalArgumentException - if the given shape is not an operation or error structure.