Class HttpBindingIndex
- java.lang.Object
- 
- software.amazon.smithy.model.knowledge.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 HttpBindingobject. 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 SummaryConstructors Constructor Description HttpBindingIndex(Model model)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.FormatdetermineTimestampFormat(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.intgetResponseCode(ToShapeId shapeOrId)Gets the computed status code of an operation or error structure.static booleanhasHttpRequestBindings(Shape shape)Returns true if a shape has any HTTP request trait bindings.static booleanhasHttpResponseBindings(Shape shape)Returns true if a shape has any HTTP response trait bindings.booleanhasRequestBody(ToShapeId operation)Returns true if the request has a modeled body.booleanhasResponseBody(ToShapeId operation)Returns true if the response has a modeled body.static HttpBindingIndexof(Model model)
 
- 
- 
- 
Constructor Detail- 
HttpBindingIndexpublic HttpBindingIndex(Model model) 
 
- 
 - 
Method Detail- 
ofpublic static HttpBindingIndex of(Model model) 
 - 
hasHttpRequestBindingspublic 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.
 
 - 
hasHttpResponseBindingspublic 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.
 
 - 
getResponseCodepublic 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.
 
 - 
getRequestBindingspublic 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.
 
 - 
getRequestBindingspublic 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.
 
 - 
getResponseBindingspublic 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.
 
 - 
getResponseBindingspublic 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.
 
 - 
determineTimestampFormatpublic 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.- Parameters:
- 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.
- Returns:
- Returns the determined timestamp format.
 
 - 
determineRequestContentTypepublic java.util.Optional<java.lang.String> determineRequestContentType(ToShapeId operation, java.lang.String documentContentType) Returns the expected request Content-Type of the given operation.See determineRequestContentType(ToShapeId, String, String)for documentation on how the content-type is resolved.- Parameters:
- operation- Operation to determine the content-type of.
- documentContentType- Content-Type to use for protocol documents.
- Returns:
- Returns the optionally resolved content-type of the request.
 
 - 
determineRequestContentTypepublic 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.If members are sent in the "document" body, then the default documentContentTypevalue is returned. If a member is bound to the payload, then the following checks are made:- If the payload has the StreamingTrait, then theeventStreamContentTypeis returned.
- If the targeted shape is a structure or document type, then
     the documentContentTypeis returned.
- If the targeted shape has the MediaTypeTrait, then the value of the trait is returned.
- If the targeted shape is a blob, then "application/octet-stream" is returned.
- If the targeted shape is a string, then "text/plain" is returned.
 If no members are sent in the payload, an empty Optional is returned. - Parameters:
- operation- Operation to determine the content-type of.
- documentContentType- Content-Type to use for protocol documents.
- eventStreamContentType- Content-Type to use for event streams.
- Returns:
- Returns the optionally resolved content-type of the request.
 
- If the payload has the 
 - 
determineResponseContentTypepublic 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.See determineResponseContentType(ToShapeId, String, String)for documentation on how the content-type is resolved.- Parameters:
- operationOrError- Operation or error to determine the content-type of.
- documentContentType- Content-Type to use for protocol documents.
- Returns:
- Returns the optionally resolved content-type of the response.
 
 - 
determineResponseContentTypepublic 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.If members are sent in the "document" body, then the default documentContentTypevalue is returned. If a member is bound to the payload, then the following checks are made:- If the payload has the StreamingTrait, then theeventStreamContentTypeis returned.
- If the targeted shape is a structure or document type, then
     the documentContentTypeis returned.
- If the targeted shape has the MediaTypeTrait, then the value of the trait is returned.
- If the targeted shape is a blob, then "application/octet-stream" is returned.
- If the targeted shape is a string, then "text/plain" is returned.
 If no members are sent in the payload, an empty Optional is returned. - Parameters:
- 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.
- Returns:
- Returns the optionally resolved content-type of the response.
 
- If the payload has the 
 - 
hasRequestBodypublic boolean hasRequestBody(ToShapeId operation) Returns true if the request has a modeled body.- Parameters:
- operation- Operation to check.
- Returns:
- Returns true if the operation has document or payload bindings.
 
 - 
hasResponseBodypublic boolean hasResponseBody(ToShapeId operation) Returns true if the response has a modeled body.- Parameters:
- operation- Operation to check.
- Returns:
- Returns true if the operation has document or payload bindings.
 
 
- 
 
-