module Network.AWS.CloudFront.UpdateDistribution
(
UpdateDistribution
, updateDistribution
, udDistributionConfig
, udId
, udIfMatch
, UpdateDistributionResponse
, updateDistributionResponse
, udrDistribution
, udrETag
) where
import Network.AWS.Prelude
import Network.AWS.Request.RestXML
import Network.AWS.CloudFront.Types
import qualified GHC.Exts
data UpdateDistribution = UpdateDistribution
{ _udDistributionConfig :: DistributionConfig
, _udId :: Text
, _udIfMatch :: Maybe Text
} deriving (Eq, Show)
updateDistribution :: DistributionConfig
-> Text
-> UpdateDistribution
updateDistribution p1 p2 = UpdateDistribution
{ _udDistributionConfig = p1
, _udId = p2
, _udIfMatch = Nothing
}
udDistributionConfig :: Lens' UpdateDistribution DistributionConfig
udDistributionConfig =
lens _udDistributionConfig (\s a -> s { _udDistributionConfig = a })
udId :: Lens' UpdateDistribution Text
udId = lens _udId (\s a -> s { _udId = a })
udIfMatch :: Lens' UpdateDistribution (Maybe Text)
udIfMatch = lens _udIfMatch (\s a -> s { _udIfMatch = a })
data UpdateDistributionResponse = UpdateDistributionResponse
{ _udrDistribution :: Maybe Distribution
, _udrETag :: Maybe Text
} deriving (Eq, Show)
updateDistributionResponse :: UpdateDistributionResponse
updateDistributionResponse = UpdateDistributionResponse
{ _udrDistribution = Nothing
, _udrETag = Nothing
}
udrDistribution :: Lens' UpdateDistributionResponse (Maybe Distribution)
udrDistribution = lens _udrDistribution (\s a -> s { _udrDistribution = a })
udrETag :: Lens' UpdateDistributionResponse (Maybe Text)
udrETag = lens _udrETag (\s a -> s { _udrETag = a })
instance ToPath UpdateDistribution where
toPath UpdateDistribution{..} = mconcat
[ "/2014-05-31/distribution/"
, toText _udId
, "/config"
]
instance ToQuery UpdateDistribution where
toQuery = const mempty
instance ToHeaders UpdateDistribution where
toHeaders UpdateDistribution{..} = mconcat
[ "If-Match" =: _udIfMatch
]
instance ToXMLRoot UpdateDistribution where
toXMLRoot UpdateDistribution{..} = namespaced ns "UpdateDistribution"
[ "DistributionConfig" =@ _udDistributionConfig
]
instance ToXML UpdateDistribution
instance AWSRequest UpdateDistribution where
type Sv UpdateDistribution = CloudFront
type Rs UpdateDistribution = UpdateDistributionResponse
request = put
response = xmlHeaderResponse $ \h x -> UpdateDistributionResponse
<$> x .@? "Distribution"
<*> h ~:? "ETag"