public final class HttpBindingIndex extends java.lang.Object implements KnowledgeIndex
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 and Description |
---|
HttpBindingIndex(Model model) |
Modifier and Type | Method and Description |
---|---|
java.util.Optional<java.lang.String> |
determineRequestContentType(ToShapeId operation,
java.lang.String documentContentType)
Returns the expected request Content-Type of the given operation.
|
java.util.Optional<java.lang.String> |
determineRequestContentType(ToShapeId operation,
java.lang.String documentContentType,
java.lang.String eventStreamContentType)
Returns the expected request Content-Type of the given operation.
|
java.util.Optional<java.lang.String> |
determineResponseContentType(ToShapeId operationOrError,
java.lang.String documentContentType)
Returns the expected response Content-Type of the given operation
or error.
|
java.util.Optional<java.lang.String> |
determineResponseContentType(ToShapeId operationOrError,
java.lang.String documentContentType,
java.lang.String eventStreamContentType)
Returns the expected response Content-Type of the given operation
or error.
|
TimestampFormatTrait.Format |
determineTimestampFormat(ToShapeId member,
HttpBinding.Location location,
TimestampFormatTrait.Format defaultFormat)
Determines the appropriate timestamp format for a member shape bound to
a specific location.
|
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.
|
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.
|
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.
|
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.
|
int |
getResponseCode(ToShapeId shapeOrId)
Gets the computed status code of an operation or error structure.
|
static boolean |
hasHttpRequestBindings(Shape shape)
Returns true if a shape has any HTTP request trait bindings.
|
static boolean |
hasHttpResponseBindings(Shape shape)
Returns true if a shape has any HTTP response trait bindings.
|
static HttpBindingIndex |
of(Model model) |
public HttpBindingIndex(Model model)
public static HttpBindingIndex of(Model model)
public static boolean hasHttpRequestBindings(Shape shape)
shape
- Shape to check.public static boolean hasHttpResponseBindings(Shape shape)
shape
- Shape to check.public int getResponseCode(ToShapeId shapeOrId)
shapeOrId
- Operation or error structure shape ID.java.lang.IllegalArgumentException
- if the given shape is not an operation
or an error structure.public java.util.Map<java.lang.String,HttpBinding> getRequestBindings(ToShapeId operationShapeOrId)
operationShapeOrId
- Operation to get the request bindings for.public java.util.List<HttpBinding> getRequestBindings(ToShapeId operationShapeOrId, HttpBinding.Location requestLocation)
operationShapeOrId
- Operation to get the request bindings for.requestLocation
- Location of the binding.public java.util.Map<java.lang.String,HttpBinding> getResponseBindings(ToShapeId shapeOrId)
shapeOrId
- Operation or error structure shape or ID.public java.util.List<HttpBinding> getResponseBindings(ToShapeId shapeOrId, HttpBinding.Location bindingLocation)
shapeOrId
- Operation or error structure shape or ID.bindingLocation
- Binding location type.java.lang.IllegalArgumentException
- if the given shape is not an operation
or error structure.public TimestampFormatTrait.Format determineTimestampFormat(ToShapeId member, HttpBinding.Location location, TimestampFormatTrait.Format defaultFormat)
member
- Member to derive the timestamp format.location
- Location the member is bound to.defaultFormat
- The format to use for the body or a default.public java.util.Optional<java.lang.String> determineRequestContentType(ToShapeId operation, java.lang.String documentContentType)
See determineRequestContentType(ToShapeId, String, String)
for documentation on how the content-type is resolved.
operation
- Operation to determine the content-type of.documentContentType
- Content-Type to use for protocol documents.public java.util.Optional<java.lang.String> determineRequestContentType(ToShapeId operation, java.lang.String documentContentType, java.lang.String eventStreamContentType)
If members are sent in the "document" body, then the default
documentContentType
value is returned. If a member is bound
to the payload, then the following checks are made:
StreamingTrait
, then the
eventStreamContentType
is returned.documentContentType
is returned.MediaTypeTrait
, then
the value of the trait is returned.If no members are sent in the payload, an empty Optional is returned.
operation
- Operation to determine the content-type of.documentContentType
- Content-Type to use for protocol documents.eventStreamContentType
- Content-Type to use for event streams.public java.util.Optional<java.lang.String> determineResponseContentType(ToShapeId operationOrError, java.lang.String documentContentType)
See determineResponseContentType(ToShapeId, String, String)
for documentation on how the content-type is resolved.
operationOrError
- Operation or error to determine the content-type of.documentContentType
- Content-Type to use for protocol documents.public java.util.Optional<java.lang.String> determineResponseContentType(ToShapeId operationOrError, java.lang.String documentContentType, java.lang.String eventStreamContentType)
If members are sent in the "document" body, then the default
documentContentType
value is returned. If a member is bound
to the payload, then the following checks are made:
StreamingTrait
, then the
eventStreamContentType
is returned.documentContentType
is returned.MediaTypeTrait
, then
the value of the trait is returned.If no members are sent in the payload, an empty Optional is returned.
operationOrError
- Operation or error to determine the content-type of.documentContentType
- Content-Type to use for protocol documents.eventStreamContentType
- Content-Type used for event streams.