{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.CloudFront.CreateInvalidation
(
CreateInvalidation (..),
newCreateInvalidation,
createInvalidation_distributionId,
createInvalidation_invalidationBatch,
CreateInvalidationResponse (..),
newCreateInvalidationResponse,
createInvalidationResponse_invalidation,
createInvalidationResponse_location,
createInvalidationResponse_httpStatus,
)
where
import Amazonka.CloudFront.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateInvalidation = CreateInvalidation'
{
CreateInvalidation -> Text
distributionId :: Prelude.Text,
CreateInvalidation -> InvalidationBatch
invalidationBatch :: InvalidationBatch
}
deriving (CreateInvalidation -> CreateInvalidation -> Bool
(CreateInvalidation -> CreateInvalidation -> Bool)
-> (CreateInvalidation -> CreateInvalidation -> Bool)
-> Eq CreateInvalidation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateInvalidation -> CreateInvalidation -> Bool
$c/= :: CreateInvalidation -> CreateInvalidation -> Bool
== :: CreateInvalidation -> CreateInvalidation -> Bool
$c== :: CreateInvalidation -> CreateInvalidation -> Bool
Prelude.Eq, ReadPrec [CreateInvalidation]
ReadPrec CreateInvalidation
Int -> ReadS CreateInvalidation
ReadS [CreateInvalidation]
(Int -> ReadS CreateInvalidation)
-> ReadS [CreateInvalidation]
-> ReadPrec CreateInvalidation
-> ReadPrec [CreateInvalidation]
-> Read CreateInvalidation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateInvalidation]
$creadListPrec :: ReadPrec [CreateInvalidation]
readPrec :: ReadPrec CreateInvalidation
$creadPrec :: ReadPrec CreateInvalidation
readList :: ReadS [CreateInvalidation]
$creadList :: ReadS [CreateInvalidation]
readsPrec :: Int -> ReadS CreateInvalidation
$creadsPrec :: Int -> ReadS CreateInvalidation
Prelude.Read, Int -> CreateInvalidation -> ShowS
[CreateInvalidation] -> ShowS
CreateInvalidation -> String
(Int -> CreateInvalidation -> ShowS)
-> (CreateInvalidation -> String)
-> ([CreateInvalidation] -> ShowS)
-> Show CreateInvalidation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateInvalidation] -> ShowS
$cshowList :: [CreateInvalidation] -> ShowS
show :: CreateInvalidation -> String
$cshow :: CreateInvalidation -> String
showsPrec :: Int -> CreateInvalidation -> ShowS
$cshowsPrec :: Int -> CreateInvalidation -> ShowS
Prelude.Show, (forall x. CreateInvalidation -> Rep CreateInvalidation x)
-> (forall x. Rep CreateInvalidation x -> CreateInvalidation)
-> Generic CreateInvalidation
forall x. Rep CreateInvalidation x -> CreateInvalidation
forall x. CreateInvalidation -> Rep CreateInvalidation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateInvalidation x -> CreateInvalidation
$cfrom :: forall x. CreateInvalidation -> Rep CreateInvalidation x
Prelude.Generic)
newCreateInvalidation ::
Prelude.Text ->
InvalidationBatch ->
CreateInvalidation
newCreateInvalidation :: Text -> InvalidationBatch -> CreateInvalidation
newCreateInvalidation
Text
pDistributionId_
InvalidationBatch
pInvalidationBatch_ =
CreateInvalidation' :: Text -> InvalidationBatch -> CreateInvalidation
CreateInvalidation'
{ $sel:distributionId:CreateInvalidation' :: Text
distributionId =
Text
pDistributionId_,
$sel:invalidationBatch:CreateInvalidation' :: InvalidationBatch
invalidationBatch = InvalidationBatch
pInvalidationBatch_
}
createInvalidation_distributionId :: Lens.Lens' CreateInvalidation Prelude.Text
createInvalidation_distributionId :: (Text -> f Text) -> CreateInvalidation -> f CreateInvalidation
createInvalidation_distributionId = (CreateInvalidation -> Text)
-> (CreateInvalidation -> Text -> CreateInvalidation)
-> Lens CreateInvalidation CreateInvalidation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInvalidation' {Text
distributionId :: Text
$sel:distributionId:CreateInvalidation' :: CreateInvalidation -> Text
distributionId} -> Text
distributionId) (\s :: CreateInvalidation
s@CreateInvalidation' {} Text
a -> CreateInvalidation
s {$sel:distributionId:CreateInvalidation' :: Text
distributionId = Text
a} :: CreateInvalidation)
createInvalidation_invalidationBatch :: Lens.Lens' CreateInvalidation InvalidationBatch
createInvalidation_invalidationBatch :: (InvalidationBatch -> f InvalidationBatch)
-> CreateInvalidation -> f CreateInvalidation
createInvalidation_invalidationBatch = (CreateInvalidation -> InvalidationBatch)
-> (CreateInvalidation -> InvalidationBatch -> CreateInvalidation)
-> Lens
CreateInvalidation
CreateInvalidation
InvalidationBatch
InvalidationBatch
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInvalidation' {InvalidationBatch
invalidationBatch :: InvalidationBatch
$sel:invalidationBatch:CreateInvalidation' :: CreateInvalidation -> InvalidationBatch
invalidationBatch} -> InvalidationBatch
invalidationBatch) (\s :: CreateInvalidation
s@CreateInvalidation' {} InvalidationBatch
a -> CreateInvalidation
s {$sel:invalidationBatch:CreateInvalidation' :: InvalidationBatch
invalidationBatch = InvalidationBatch
a} :: CreateInvalidation)
instance Core.AWSRequest CreateInvalidation where
type
AWSResponse CreateInvalidation =
CreateInvalidationResponse
request :: CreateInvalidation -> Request CreateInvalidation
request = Service -> CreateInvalidation -> Request CreateInvalidation
forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.postXML Service
defaultService
response :: Logger
-> Service
-> Proxy CreateInvalidation
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateInvalidation)))
response =
(Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse CreateInvalidation))
-> Logger
-> Service
-> Proxy CreateInvalidation
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateInvalidation)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
( \Int
s ResponseHeaders
h [Node]
x ->
Maybe Invalidation
-> Maybe Text -> Int -> CreateInvalidationResponse
CreateInvalidationResponse'
(Maybe Invalidation
-> Maybe Text -> Int -> CreateInvalidationResponse)
-> Either String (Maybe Invalidation)
-> Either String (Maybe Text -> Int -> CreateInvalidationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node] -> Either String (Maybe Invalidation)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
Either String (Maybe Text -> Int -> CreateInvalidationResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateInvalidationResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (ResponseHeaders
h ResponseHeaders -> HeaderName -> Either String (Maybe Text)
forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Core..#? HeaderName
"Location")
Either String (Int -> CreateInvalidationResponse)
-> Either String Int -> Either String CreateInvalidationResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreateInvalidation
instance Prelude.NFData CreateInvalidation
instance Core.ToElement CreateInvalidation where
toElement :: CreateInvalidation -> Element
toElement CreateInvalidation' {Text
InvalidationBatch
invalidationBatch :: InvalidationBatch
distributionId :: Text
$sel:invalidationBatch:CreateInvalidation' :: CreateInvalidation -> InvalidationBatch
$sel:distributionId:CreateInvalidation' :: CreateInvalidation -> Text
..} =
Name -> InvalidationBatch -> Element
forall a. ToXML a => Name -> a -> Element
Core.mkElement
Name
"{http://cloudfront.amazonaws.com/doc/2020-05-31/}InvalidationBatch"
InvalidationBatch
invalidationBatch
instance Core.ToHeaders CreateInvalidation where
toHeaders :: CreateInvalidation -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateInvalidation -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath CreateInvalidation where
toPath :: CreateInvalidation -> ByteString
toPath CreateInvalidation' {Text
InvalidationBatch
invalidationBatch :: InvalidationBatch
distributionId :: Text
$sel:invalidationBatch:CreateInvalidation' :: CreateInvalidation -> InvalidationBatch
$sel:distributionId:CreateInvalidation' :: CreateInvalidation -> Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/2020-05-31/distribution/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
distributionId,
ByteString
"/invalidation"
]
instance Core.ToQuery CreateInvalidation where
toQuery :: CreateInvalidation -> QueryString
toQuery = QueryString -> CreateInvalidation -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateInvalidationResponse = CreateInvalidationResponse'
{
CreateInvalidationResponse -> Maybe Invalidation
invalidation :: Prelude.Maybe Invalidation,
CreateInvalidationResponse -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
CreateInvalidationResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateInvalidationResponse -> CreateInvalidationResponse -> Bool
(CreateInvalidationResponse -> CreateInvalidationResponse -> Bool)
-> (CreateInvalidationResponse
-> CreateInvalidationResponse -> Bool)
-> Eq CreateInvalidationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateInvalidationResponse -> CreateInvalidationResponse -> Bool
$c/= :: CreateInvalidationResponse -> CreateInvalidationResponse -> Bool
== :: CreateInvalidationResponse -> CreateInvalidationResponse -> Bool
$c== :: CreateInvalidationResponse -> CreateInvalidationResponse -> Bool
Prelude.Eq, ReadPrec [CreateInvalidationResponse]
ReadPrec CreateInvalidationResponse
Int -> ReadS CreateInvalidationResponse
ReadS [CreateInvalidationResponse]
(Int -> ReadS CreateInvalidationResponse)
-> ReadS [CreateInvalidationResponse]
-> ReadPrec CreateInvalidationResponse
-> ReadPrec [CreateInvalidationResponse]
-> Read CreateInvalidationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateInvalidationResponse]
$creadListPrec :: ReadPrec [CreateInvalidationResponse]
readPrec :: ReadPrec CreateInvalidationResponse
$creadPrec :: ReadPrec CreateInvalidationResponse
readList :: ReadS [CreateInvalidationResponse]
$creadList :: ReadS [CreateInvalidationResponse]
readsPrec :: Int -> ReadS CreateInvalidationResponse
$creadsPrec :: Int -> ReadS CreateInvalidationResponse
Prelude.Read, Int -> CreateInvalidationResponse -> ShowS
[CreateInvalidationResponse] -> ShowS
CreateInvalidationResponse -> String
(Int -> CreateInvalidationResponse -> ShowS)
-> (CreateInvalidationResponse -> String)
-> ([CreateInvalidationResponse] -> ShowS)
-> Show CreateInvalidationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateInvalidationResponse] -> ShowS
$cshowList :: [CreateInvalidationResponse] -> ShowS
show :: CreateInvalidationResponse -> String
$cshow :: CreateInvalidationResponse -> String
showsPrec :: Int -> CreateInvalidationResponse -> ShowS
$cshowsPrec :: Int -> CreateInvalidationResponse -> ShowS
Prelude.Show, (forall x.
CreateInvalidationResponse -> Rep CreateInvalidationResponse x)
-> (forall x.
Rep CreateInvalidationResponse x -> CreateInvalidationResponse)
-> Generic CreateInvalidationResponse
forall x.
Rep CreateInvalidationResponse x -> CreateInvalidationResponse
forall x.
CreateInvalidationResponse -> Rep CreateInvalidationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateInvalidationResponse x -> CreateInvalidationResponse
$cfrom :: forall x.
CreateInvalidationResponse -> Rep CreateInvalidationResponse x
Prelude.Generic)
newCreateInvalidationResponse ::
Prelude.Int ->
CreateInvalidationResponse
newCreateInvalidationResponse :: Int -> CreateInvalidationResponse
newCreateInvalidationResponse Int
pHttpStatus_ =
CreateInvalidationResponse' :: Maybe Invalidation
-> Maybe Text -> Int -> CreateInvalidationResponse
CreateInvalidationResponse'
{ $sel:invalidation:CreateInvalidationResponse' :: Maybe Invalidation
invalidation =
Maybe Invalidation
forall a. Maybe a
Prelude.Nothing,
$sel:location:CreateInvalidationResponse' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateInvalidationResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createInvalidationResponse_invalidation :: Lens.Lens' CreateInvalidationResponse (Prelude.Maybe Invalidation)
createInvalidationResponse_invalidation :: (Maybe Invalidation -> f (Maybe Invalidation))
-> CreateInvalidationResponse -> f CreateInvalidationResponse
createInvalidationResponse_invalidation = (CreateInvalidationResponse -> Maybe Invalidation)
-> (CreateInvalidationResponse
-> Maybe Invalidation -> CreateInvalidationResponse)
-> Lens
CreateInvalidationResponse
CreateInvalidationResponse
(Maybe Invalidation)
(Maybe Invalidation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInvalidationResponse' {Maybe Invalidation
invalidation :: Maybe Invalidation
$sel:invalidation:CreateInvalidationResponse' :: CreateInvalidationResponse -> Maybe Invalidation
invalidation} -> Maybe Invalidation
invalidation) (\s :: CreateInvalidationResponse
s@CreateInvalidationResponse' {} Maybe Invalidation
a -> CreateInvalidationResponse
s {$sel:invalidation:CreateInvalidationResponse' :: Maybe Invalidation
invalidation = Maybe Invalidation
a} :: CreateInvalidationResponse)
createInvalidationResponse_location :: Lens.Lens' CreateInvalidationResponse (Prelude.Maybe Prelude.Text)
createInvalidationResponse_location :: (Maybe Text -> f (Maybe Text))
-> CreateInvalidationResponse -> f CreateInvalidationResponse
createInvalidationResponse_location = (CreateInvalidationResponse -> Maybe Text)
-> (CreateInvalidationResponse
-> Maybe Text -> CreateInvalidationResponse)
-> Lens
CreateInvalidationResponse
CreateInvalidationResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInvalidationResponse' {Maybe Text
location :: Maybe Text
$sel:location:CreateInvalidationResponse' :: CreateInvalidationResponse -> Maybe Text
location} -> Maybe Text
location) (\s :: CreateInvalidationResponse
s@CreateInvalidationResponse' {} Maybe Text
a -> CreateInvalidationResponse
s {$sel:location:CreateInvalidationResponse' :: Maybe Text
location = Maybe Text
a} :: CreateInvalidationResponse)
createInvalidationResponse_httpStatus :: Lens.Lens' CreateInvalidationResponse Prelude.Int
createInvalidationResponse_httpStatus :: (Int -> f Int)
-> CreateInvalidationResponse -> f CreateInvalidationResponse
createInvalidationResponse_httpStatus = (CreateInvalidationResponse -> Int)
-> (CreateInvalidationResponse
-> Int -> CreateInvalidationResponse)
-> Lens
CreateInvalidationResponse CreateInvalidationResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInvalidationResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateInvalidationResponse' :: CreateInvalidationResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateInvalidationResponse
s@CreateInvalidationResponse' {} Int
a -> CreateInvalidationResponse
s {$sel:httpStatus:CreateInvalidationResponse' :: Int
httpStatus = Int
a} :: CreateInvalidationResponse)
instance Prelude.NFData CreateInvalidationResponse