{-# 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.CreateCachePolicy
(
CreateCachePolicy (..),
newCreateCachePolicy,
createCachePolicy_cachePolicyConfig,
CreateCachePolicyResponse (..),
newCreateCachePolicyResponse,
createCachePolicyResponse_cachePolicy,
createCachePolicyResponse_eTag,
createCachePolicyResponse_location,
createCachePolicyResponse_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 CreateCachePolicy = CreateCachePolicy'
{
CreateCachePolicy -> CachePolicyConfig
cachePolicyConfig :: CachePolicyConfig
}
deriving (CreateCachePolicy -> CreateCachePolicy -> Bool
(CreateCachePolicy -> CreateCachePolicy -> Bool)
-> (CreateCachePolicy -> CreateCachePolicy -> Bool)
-> Eq CreateCachePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCachePolicy -> CreateCachePolicy -> Bool
$c/= :: CreateCachePolicy -> CreateCachePolicy -> Bool
== :: CreateCachePolicy -> CreateCachePolicy -> Bool
$c== :: CreateCachePolicy -> CreateCachePolicy -> Bool
Prelude.Eq, ReadPrec [CreateCachePolicy]
ReadPrec CreateCachePolicy
Int -> ReadS CreateCachePolicy
ReadS [CreateCachePolicy]
(Int -> ReadS CreateCachePolicy)
-> ReadS [CreateCachePolicy]
-> ReadPrec CreateCachePolicy
-> ReadPrec [CreateCachePolicy]
-> Read CreateCachePolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCachePolicy]
$creadListPrec :: ReadPrec [CreateCachePolicy]
readPrec :: ReadPrec CreateCachePolicy
$creadPrec :: ReadPrec CreateCachePolicy
readList :: ReadS [CreateCachePolicy]
$creadList :: ReadS [CreateCachePolicy]
readsPrec :: Int -> ReadS CreateCachePolicy
$creadsPrec :: Int -> ReadS CreateCachePolicy
Prelude.Read, Int -> CreateCachePolicy -> ShowS
[CreateCachePolicy] -> ShowS
CreateCachePolicy -> String
(Int -> CreateCachePolicy -> ShowS)
-> (CreateCachePolicy -> String)
-> ([CreateCachePolicy] -> ShowS)
-> Show CreateCachePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCachePolicy] -> ShowS
$cshowList :: [CreateCachePolicy] -> ShowS
show :: CreateCachePolicy -> String
$cshow :: CreateCachePolicy -> String
showsPrec :: Int -> CreateCachePolicy -> ShowS
$cshowsPrec :: Int -> CreateCachePolicy -> ShowS
Prelude.Show, (forall x. CreateCachePolicy -> Rep CreateCachePolicy x)
-> (forall x. Rep CreateCachePolicy x -> CreateCachePolicy)
-> Generic CreateCachePolicy
forall x. Rep CreateCachePolicy x -> CreateCachePolicy
forall x. CreateCachePolicy -> Rep CreateCachePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateCachePolicy x -> CreateCachePolicy
$cfrom :: forall x. CreateCachePolicy -> Rep CreateCachePolicy x
Prelude.Generic)
newCreateCachePolicy ::
CachePolicyConfig ->
CreateCachePolicy
newCreateCachePolicy :: CachePolicyConfig -> CreateCachePolicy
newCreateCachePolicy CachePolicyConfig
pCachePolicyConfig_ =
CreateCachePolicy' :: CachePolicyConfig -> CreateCachePolicy
CreateCachePolicy'
{ $sel:cachePolicyConfig:CreateCachePolicy' :: CachePolicyConfig
cachePolicyConfig =
CachePolicyConfig
pCachePolicyConfig_
}
createCachePolicy_cachePolicyConfig :: Lens.Lens' CreateCachePolicy CachePolicyConfig
createCachePolicy_cachePolicyConfig :: (CachePolicyConfig -> f CachePolicyConfig)
-> CreateCachePolicy -> f CreateCachePolicy
createCachePolicy_cachePolicyConfig = (CreateCachePolicy -> CachePolicyConfig)
-> (CreateCachePolicy -> CachePolicyConfig -> CreateCachePolicy)
-> Lens
CreateCachePolicy
CreateCachePolicy
CachePolicyConfig
CachePolicyConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCachePolicy' {CachePolicyConfig
cachePolicyConfig :: CachePolicyConfig
$sel:cachePolicyConfig:CreateCachePolicy' :: CreateCachePolicy -> CachePolicyConfig
cachePolicyConfig} -> CachePolicyConfig
cachePolicyConfig) (\s :: CreateCachePolicy
s@CreateCachePolicy' {} CachePolicyConfig
a -> CreateCachePolicy
s {$sel:cachePolicyConfig:CreateCachePolicy' :: CachePolicyConfig
cachePolicyConfig = CachePolicyConfig
a} :: CreateCachePolicy)
instance Core.AWSRequest CreateCachePolicy where
type
AWSResponse CreateCachePolicy =
CreateCachePolicyResponse
request :: CreateCachePolicy -> Request CreateCachePolicy
request = Service -> CreateCachePolicy -> Request CreateCachePolicy
forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.postXML Service
defaultService
response :: Logger
-> Service
-> Proxy CreateCachePolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateCachePolicy)))
response =
(Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse CreateCachePolicy))
-> Logger
-> Service
-> Proxy CreateCachePolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateCachePolicy)))
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 CachePolicy
-> Maybe Text -> Maybe Text -> Int -> CreateCachePolicyResponse
CreateCachePolicyResponse'
(Maybe CachePolicy
-> Maybe Text -> Maybe Text -> Int -> CreateCachePolicyResponse)
-> Either String (Maybe CachePolicy)
-> Either
String
(Maybe Text -> Maybe Text -> Int -> CreateCachePolicyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node] -> Either String (Maybe CachePolicy)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
Either
String
(Maybe Text -> Maybe Text -> Int -> CreateCachePolicyResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateCachePolicyResponse)
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
"ETag")
Either String (Maybe Text -> Int -> CreateCachePolicyResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateCachePolicyResponse)
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 -> CreateCachePolicyResponse)
-> Either String Int -> Either String CreateCachePolicyResponse
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 CreateCachePolicy
instance Prelude.NFData CreateCachePolicy
instance Core.ToElement CreateCachePolicy where
toElement :: CreateCachePolicy -> Element
toElement CreateCachePolicy' {CachePolicyConfig
cachePolicyConfig :: CachePolicyConfig
$sel:cachePolicyConfig:CreateCachePolicy' :: CreateCachePolicy -> CachePolicyConfig
..} =
Name -> CachePolicyConfig -> Element
forall a. ToXML a => Name -> a -> Element
Core.mkElement
Name
"{http://cloudfront.amazonaws.com/doc/2020-05-31/}CachePolicyConfig"
CachePolicyConfig
cachePolicyConfig
instance Core.ToHeaders CreateCachePolicy where
toHeaders :: CreateCachePolicy -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateCachePolicy -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath CreateCachePolicy where
toPath :: CreateCachePolicy -> ByteString
toPath = ByteString -> CreateCachePolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/2020-05-31/cache-policy"
instance Core.ToQuery CreateCachePolicy where
toQuery :: CreateCachePolicy -> QueryString
toQuery = QueryString -> CreateCachePolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateCachePolicyResponse = CreateCachePolicyResponse'
{
CreateCachePolicyResponse -> Maybe CachePolicy
cachePolicy :: Prelude.Maybe CachePolicy,
CreateCachePolicyResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
CreateCachePolicyResponse -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
CreateCachePolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateCachePolicyResponse -> CreateCachePolicyResponse -> Bool
(CreateCachePolicyResponse -> CreateCachePolicyResponse -> Bool)
-> (CreateCachePolicyResponse -> CreateCachePolicyResponse -> Bool)
-> Eq CreateCachePolicyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateCachePolicyResponse -> CreateCachePolicyResponse -> Bool
$c/= :: CreateCachePolicyResponse -> CreateCachePolicyResponse -> Bool
== :: CreateCachePolicyResponse -> CreateCachePolicyResponse -> Bool
$c== :: CreateCachePolicyResponse -> CreateCachePolicyResponse -> Bool
Prelude.Eq, ReadPrec [CreateCachePolicyResponse]
ReadPrec CreateCachePolicyResponse
Int -> ReadS CreateCachePolicyResponse
ReadS [CreateCachePolicyResponse]
(Int -> ReadS CreateCachePolicyResponse)
-> ReadS [CreateCachePolicyResponse]
-> ReadPrec CreateCachePolicyResponse
-> ReadPrec [CreateCachePolicyResponse]
-> Read CreateCachePolicyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateCachePolicyResponse]
$creadListPrec :: ReadPrec [CreateCachePolicyResponse]
readPrec :: ReadPrec CreateCachePolicyResponse
$creadPrec :: ReadPrec CreateCachePolicyResponse
readList :: ReadS [CreateCachePolicyResponse]
$creadList :: ReadS [CreateCachePolicyResponse]
readsPrec :: Int -> ReadS CreateCachePolicyResponse
$creadsPrec :: Int -> ReadS CreateCachePolicyResponse
Prelude.Read, Int -> CreateCachePolicyResponse -> ShowS
[CreateCachePolicyResponse] -> ShowS
CreateCachePolicyResponse -> String
(Int -> CreateCachePolicyResponse -> ShowS)
-> (CreateCachePolicyResponse -> String)
-> ([CreateCachePolicyResponse] -> ShowS)
-> Show CreateCachePolicyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateCachePolicyResponse] -> ShowS
$cshowList :: [CreateCachePolicyResponse] -> ShowS
show :: CreateCachePolicyResponse -> String
$cshow :: CreateCachePolicyResponse -> String
showsPrec :: Int -> CreateCachePolicyResponse -> ShowS
$cshowsPrec :: Int -> CreateCachePolicyResponse -> ShowS
Prelude.Show, (forall x.
CreateCachePolicyResponse -> Rep CreateCachePolicyResponse x)
-> (forall x.
Rep CreateCachePolicyResponse x -> CreateCachePolicyResponse)
-> Generic CreateCachePolicyResponse
forall x.
Rep CreateCachePolicyResponse x -> CreateCachePolicyResponse
forall x.
CreateCachePolicyResponse -> Rep CreateCachePolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateCachePolicyResponse x -> CreateCachePolicyResponse
$cfrom :: forall x.
CreateCachePolicyResponse -> Rep CreateCachePolicyResponse x
Prelude.Generic)
newCreateCachePolicyResponse ::
Prelude.Int ->
CreateCachePolicyResponse
newCreateCachePolicyResponse :: Int -> CreateCachePolicyResponse
newCreateCachePolicyResponse Int
pHttpStatus_ =
CreateCachePolicyResponse' :: Maybe CachePolicy
-> Maybe Text -> Maybe Text -> Int -> CreateCachePolicyResponse
CreateCachePolicyResponse'
{ $sel:cachePolicy:CreateCachePolicyResponse' :: Maybe CachePolicy
cachePolicy =
Maybe CachePolicy
forall a. Maybe a
Prelude.Nothing,
$sel:eTag:CreateCachePolicyResponse' :: Maybe Text
eTag = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:location:CreateCachePolicyResponse' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateCachePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createCachePolicyResponse_cachePolicy :: Lens.Lens' CreateCachePolicyResponse (Prelude.Maybe CachePolicy)
createCachePolicyResponse_cachePolicy :: (Maybe CachePolicy -> f (Maybe CachePolicy))
-> CreateCachePolicyResponse -> f CreateCachePolicyResponse
createCachePolicyResponse_cachePolicy = (CreateCachePolicyResponse -> Maybe CachePolicy)
-> (CreateCachePolicyResponse
-> Maybe CachePolicy -> CreateCachePolicyResponse)
-> Lens
CreateCachePolicyResponse
CreateCachePolicyResponse
(Maybe CachePolicy)
(Maybe CachePolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCachePolicyResponse' {Maybe CachePolicy
cachePolicy :: Maybe CachePolicy
$sel:cachePolicy:CreateCachePolicyResponse' :: CreateCachePolicyResponse -> Maybe CachePolicy
cachePolicy} -> Maybe CachePolicy
cachePolicy) (\s :: CreateCachePolicyResponse
s@CreateCachePolicyResponse' {} Maybe CachePolicy
a -> CreateCachePolicyResponse
s {$sel:cachePolicy:CreateCachePolicyResponse' :: Maybe CachePolicy
cachePolicy = Maybe CachePolicy
a} :: CreateCachePolicyResponse)
createCachePolicyResponse_eTag :: Lens.Lens' CreateCachePolicyResponse (Prelude.Maybe Prelude.Text)
createCachePolicyResponse_eTag :: (Maybe Text -> f (Maybe Text))
-> CreateCachePolicyResponse -> f CreateCachePolicyResponse
createCachePolicyResponse_eTag = (CreateCachePolicyResponse -> Maybe Text)
-> (CreateCachePolicyResponse
-> Maybe Text -> CreateCachePolicyResponse)
-> Lens
CreateCachePolicyResponse
CreateCachePolicyResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCachePolicyResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:CreateCachePolicyResponse' :: CreateCachePolicyResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: CreateCachePolicyResponse
s@CreateCachePolicyResponse' {} Maybe Text
a -> CreateCachePolicyResponse
s {$sel:eTag:CreateCachePolicyResponse' :: Maybe Text
eTag = Maybe Text
a} :: CreateCachePolicyResponse)
createCachePolicyResponse_location :: Lens.Lens' CreateCachePolicyResponse (Prelude.Maybe Prelude.Text)
createCachePolicyResponse_location :: (Maybe Text -> f (Maybe Text))
-> CreateCachePolicyResponse -> f CreateCachePolicyResponse
createCachePolicyResponse_location = (CreateCachePolicyResponse -> Maybe Text)
-> (CreateCachePolicyResponse
-> Maybe Text -> CreateCachePolicyResponse)
-> Lens
CreateCachePolicyResponse
CreateCachePolicyResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCachePolicyResponse' {Maybe Text
location :: Maybe Text
$sel:location:CreateCachePolicyResponse' :: CreateCachePolicyResponse -> Maybe Text
location} -> Maybe Text
location) (\s :: CreateCachePolicyResponse
s@CreateCachePolicyResponse' {} Maybe Text
a -> CreateCachePolicyResponse
s {$sel:location:CreateCachePolicyResponse' :: Maybe Text
location = Maybe Text
a} :: CreateCachePolicyResponse)
createCachePolicyResponse_httpStatus :: Lens.Lens' CreateCachePolicyResponse Prelude.Int
createCachePolicyResponse_httpStatus :: (Int -> f Int)
-> CreateCachePolicyResponse -> f CreateCachePolicyResponse
createCachePolicyResponse_httpStatus = (CreateCachePolicyResponse -> Int)
-> (CreateCachePolicyResponse -> Int -> CreateCachePolicyResponse)
-> Lens CreateCachePolicyResponse CreateCachePolicyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateCachePolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateCachePolicyResponse' :: CreateCachePolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateCachePolicyResponse
s@CreateCachePolicyResponse' {} Int
a -> CreateCachePolicyResponse
s {$sel:httpStatus:CreateCachePolicyResponse' :: Int
httpStatus = Int
a} :: CreateCachePolicyResponse)
instance Prelude.NFData CreateCachePolicyResponse