module Network.AWS.Request.S3
( get
, head
, delete
, post
, put
, stream
) where
import Control.Lens
import Network.AWS.Data
import Network.AWS.Request.Internal
import Network.AWS.Types
import Network.HTTP.Types.Method
import Prelude hiding (head)
get :: (ToPath a, ToQuery a, ToHeaders a) => a -> Request a
get = content . defaultRequest
delete :: (ToPath a, ToQuery a, ToHeaders a) => a -> Request a
delete x = get x & rqMethod .~ DELETE
head :: (ToPath a, ToQuery a, ToHeaders a) => a -> Request a
head x = get x & rqMethod .~ HEAD
post :: (ToPath a, ToQuery a, ToHeaders a, ToXMLRoot a) => a -> Request a
post x = put x & rqMethod .~ POST
put :: (ToPath a, ToQuery a, ToHeaders a, ToXMLRoot a) => a -> Request a
put x = content $ get x & rqMethod .~ PUT & rqBody .~ toBody (encodeXML x)
stream :: (ToPath a, ToQuery a, ToHeaders a, ToBody a)
=> StdMethod
-> a
-> Request a
stream m x = content $ get x & rqMethod .~ m & rqBody .~ toBody x
content :: Request a -> Request a
content rq = rq & rqHeaders %~ hdr hAMZContentSHA256 (bodyHash (rq ^. rqBody))