module Network.AWS.Request.RestJSON
( get
, delete
, post
, put
) where
import Control.Applicative
import Control.Lens hiding (Action)
import Data.Aeson
import Data.Monoid
import Network.AWS.Data
import Network.AWS.Request.Internal
import Network.AWS.Types
import Network.HTTP.Types.Header
import Network.HTTP.Types.Method
get :: (ToPath a, ToQuery a, ToHeaders a) => a -> Request a
get = defaultRequest
delete :: (ToPath a, ToQuery a, ToHeaders a) => a -> Request a
delete x = get x & rqMethod .~ DELETE
post :: (AWSService (Sv a), ToQuery a, ToPath a, ToHeaders a, ToJSON a)
=> a
-> Request a
post x = put x & rqMethod .~ POST
put :: forall a. (AWSService (Sv a), ToQuery a, ToPath a, ToHeaders a, ToJSON a)
=> a
-> Request a
put x = get x
& rqMethod .~ PUT
& rqHeaders <>~ toHeader hContentType content
& rqBody .~ toBody (toJSON x)
where
content = ("application/x-amz-json-" <>) <$> _svcJSONVersion svc
svc :: Service (Sv a)
svc = service