Handling of HTTP requests to AWS Services.
send : AWS.Internal.Service.Service -> AWS.Credentials.Credentials -> Request err a -> Task (Error err) a
Signs and sends a Request
to a Service
.
sendUnsigned : AWS.Internal.Service.Service -> Request err a -> Task (Error err) a
Sends a Request
to a Service
without signing it.
HTTP request methods.
String
Request path.
AWS.Internal.Request.Request err a
Holds an unsigned AWS HTTP request.
request : String -> Method -> Path -> Body -> ResponseDecoder a -> AWS.Internal.Request.ErrorDecoder err -> Request err a
Creates an unsigned HTTP request to an AWS service.
AWS.Internal.Body.Body
Holds a request body.
String
MIME type.
See https://en.wikipedia.org/wiki/Media_type
emptyBody : Body
Create an empty body.
stringBody : MimeType -> String -> Body
Create a body with a custom MIME type and the given string as content.
stringBody "text/html" "<html><body><h1>Hello</h1></body></html>"
jsonBody : Json.Encode.Value -> Body
Create a body containing a JSON value.
This will automatically add the Content-Type: application/json
header.
addHeaders : List ( String, String ) -> Request err a -> Request err a
Appends headers to an AWS HTTP unsigned request.
See the AWS.KVEncode
for encoder functions to build the headers with.
addQuery : List ( String, String ) -> Request err a -> Request err a
Appends query arguments to an AWS HTTP unsigned request.
See the AWS.KVEncode
for encoder functions to build the query parameters with.
AWS.Internal.Request.ResponseDecoder a
Decoders that interpret responses.
fullDecoder : (Http.Metadata -> String -> Result String a) -> ResponseDecoder a
A full decoder for the response that can look at the status code, metadata
including headers and so on. The body is presented as a String
for parsing.
It is possible to report an error as a String when interpreting the response, and
this will be mapped onto Http.BadBody
when present.
jsonFullDecoder : (Http.Metadata -> Json.Decode.Decoder a) -> ResponseDecoder a
A full JSON decoder for the response that can look at the status code, metadata
including headers and so on. The body is presented as a JSON Value
for decoding.
Any decoder error is mapped onto Http.BadBody
as a String
when present using
Decode.errorToString
.
stringBodyDecoder : (String -> Result String a) -> ResponseDecoder a
A decoder for the response that uses only the body presented as a String
for parsing.
It is possible to report an error as a String when interpreting the response, and
this will be mapped onto Http.BadBody
when present.
Note that this decoder is only used when the response is Http.GoodStatus_. An Http.BadStatus_ is always mapped to Http.BadStatus without attempting to decode the body. If you need to handle things that Elm HTTP regards as BadStatus_, use one of the 'full' decoders.
jsonBodyDecoder : Json.Decode.Decoder a -> ResponseDecoder a
A decoder for the response that uses only the body presented as a JSON Value
for decoding.
Any decoder error is mapped onto Http.BadBody
as a String
when present using
Decode.errorToString
.
Note that this decoder is only used when the response is Http.GoodStatus_. An Http.BadStatus_ is always mapped to Http.BadStatus without attempting to decode the body. If you need to handle things that Elm HTTP regards as BadStatus_, use one of the 'full' decoders.
constantDecoder : a -> ResponseDecoder a
Not all AWS service produce a response that contains useful information.
The constantDecoder
is helpful in those situations and just produces whatever
value you give it once AWS has responded.
Note that this decoder is only used when the response is Http.GoodStatus_. An Http.BadStatus_ is always mapped to Http.BadStatus without attempting to decode the body. If you need to handle things that Elm HTTP regards as BadStatus_, use one of the 'full' decoders.
The HTTP calls made to AWS can produce errors in two ways. The first is the
normal Http.Error
responses. The second is an error message at the application
level from one of the AWS service endpoints.
Only some endpoints can produce application level errors, in which case their error
type can be given as Never
.
{ type_ : String
, message : Maybe String
, statusCode : Basics.Int
}
AWS application level errors consist of a 'type' giving the name of an 'exception' and possibly a message string.
awsAppErrDecoder : Http.Metadata -> String -> Result String AWSAppError
The default decoder for the standard AWS application level errors.
Use this, or define your own decoder to interpret these errors.
neverAppErrDecoder : Http.Metadata -> String -> Result String Basics.Never
The never error decoder for AWS endpoints that are not expected to produce any application level errors.
If this decoder were to be called, it will simply return the body undecoded as an error and this should be mapped onto Http.BadBody.