module Network.AWS.CloudFront.CreateInvalidation
(
CreateInvalidation
, createInvalidation
, ciDistributionId
, ciInvalidationBatch
, CreateInvalidationResponse
, createInvalidationResponse
, cirInvalidation
, cirLocation
) where
import Network.AWS.Prelude
import Network.AWS.Request.RestXML
import Network.AWS.CloudFront.Types
import qualified GHC.Exts
data CreateInvalidation = CreateInvalidation
{ _ciDistributionId :: Text
, _ciInvalidationBatch :: InvalidationBatch
} deriving (Eq, Show)
createInvalidation :: Text
-> InvalidationBatch
-> CreateInvalidation
createInvalidation p1 p2 = CreateInvalidation
{ _ciDistributionId = p1
, _ciInvalidationBatch = p2
}
ciDistributionId :: Lens' CreateInvalidation Text
ciDistributionId = lens _ciDistributionId (\s a -> s { _ciDistributionId = a })
ciInvalidationBatch :: Lens' CreateInvalidation InvalidationBatch
ciInvalidationBatch =
lens _ciInvalidationBatch (\s a -> s { _ciInvalidationBatch = a })
data CreateInvalidationResponse = CreateInvalidationResponse
{ _cirInvalidation :: Maybe Invalidation
, _cirLocation :: Maybe Text
} deriving (Eq, Show)
createInvalidationResponse :: CreateInvalidationResponse
createInvalidationResponse = CreateInvalidationResponse
{ _cirLocation = Nothing
, _cirInvalidation = Nothing
}
cirInvalidation :: Lens' CreateInvalidationResponse (Maybe Invalidation)
cirInvalidation = lens _cirInvalidation (\s a -> s { _cirInvalidation = a })
cirLocation :: Lens' CreateInvalidationResponse (Maybe Text)
cirLocation = lens _cirLocation (\s a -> s { _cirLocation = a })
instance ToPath CreateInvalidation where
toPath CreateInvalidation{..} = mconcat
[ "/2014-10-21/distribution/"
, toText _ciDistributionId
, "/invalidation"
]
instance ToQuery CreateInvalidation where
toQuery = const mempty
instance ToHeaders CreateInvalidation
instance ToXMLRoot CreateInvalidation where
toXMLRoot CreateInvalidation{..} = namespaced ns "CreateInvalidation"
[ "InvalidationBatch" =@ _ciInvalidationBatch
]
instance ToXML CreateInvalidation
instance AWSRequest CreateInvalidation where
type Sv CreateInvalidation = CloudFront
type Rs CreateInvalidation = CreateInvalidationResponse
request = post
response = xmlHeaderResponse $ \h x -> CreateInvalidationResponse
<$> x .@? "Invalidation"
<*> h ~:? "Location"