{-# 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.CreateDistribution
(
CreateDistribution (..),
newCreateDistribution,
createDistribution_distributionConfig,
CreateDistributionResponse (..),
newCreateDistributionResponse,
createDistributionResponse_eTag,
createDistributionResponse_distribution,
createDistributionResponse_location,
createDistributionResponse_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 CreateDistribution = CreateDistribution'
{
CreateDistribution -> DistributionConfig
distributionConfig :: DistributionConfig
}
deriving (CreateDistribution -> CreateDistribution -> Bool
(CreateDistribution -> CreateDistribution -> Bool)
-> (CreateDistribution -> CreateDistribution -> Bool)
-> Eq CreateDistribution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDistribution -> CreateDistribution -> Bool
$c/= :: CreateDistribution -> CreateDistribution -> Bool
== :: CreateDistribution -> CreateDistribution -> Bool
$c== :: CreateDistribution -> CreateDistribution -> Bool
Prelude.Eq, Int -> CreateDistribution -> ShowS
[CreateDistribution] -> ShowS
CreateDistribution -> String
(Int -> CreateDistribution -> ShowS)
-> (CreateDistribution -> String)
-> ([CreateDistribution] -> ShowS)
-> Show CreateDistribution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDistribution] -> ShowS
$cshowList :: [CreateDistribution] -> ShowS
show :: CreateDistribution -> String
$cshow :: CreateDistribution -> String
showsPrec :: Int -> CreateDistribution -> ShowS
$cshowsPrec :: Int -> CreateDistribution -> ShowS
Prelude.Show, (forall x. CreateDistribution -> Rep CreateDistribution x)
-> (forall x. Rep CreateDistribution x -> CreateDistribution)
-> Generic CreateDistribution
forall x. Rep CreateDistribution x -> CreateDistribution
forall x. CreateDistribution -> Rep CreateDistribution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDistribution x -> CreateDistribution
$cfrom :: forall x. CreateDistribution -> Rep CreateDistribution x
Prelude.Generic)
newCreateDistribution ::
DistributionConfig ->
CreateDistribution
newCreateDistribution :: DistributionConfig -> CreateDistribution
newCreateDistribution DistributionConfig
pDistributionConfig_ =
CreateDistribution' :: DistributionConfig -> CreateDistribution
CreateDistribution'
{ $sel:distributionConfig:CreateDistribution' :: DistributionConfig
distributionConfig =
DistributionConfig
pDistributionConfig_
}
createDistribution_distributionConfig :: Lens.Lens' CreateDistribution DistributionConfig
createDistribution_distributionConfig :: (DistributionConfig -> f DistributionConfig)
-> CreateDistribution -> f CreateDistribution
createDistribution_distributionConfig = (CreateDistribution -> DistributionConfig)
-> (CreateDistribution -> DistributionConfig -> CreateDistribution)
-> Lens
CreateDistribution
CreateDistribution
DistributionConfig
DistributionConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDistribution' {DistributionConfig
distributionConfig :: DistributionConfig
$sel:distributionConfig:CreateDistribution' :: CreateDistribution -> DistributionConfig
distributionConfig} -> DistributionConfig
distributionConfig) (\s :: CreateDistribution
s@CreateDistribution' {} DistributionConfig
a -> CreateDistribution
s {$sel:distributionConfig:CreateDistribution' :: DistributionConfig
distributionConfig = DistributionConfig
a} :: CreateDistribution)
instance Core.AWSRequest CreateDistribution where
type
AWSResponse CreateDistribution =
CreateDistributionResponse
request :: CreateDistribution -> Request CreateDistribution
request = Service -> CreateDistribution -> Request CreateDistribution
forall a. (ToRequest a, ToElement a) => Service -> a -> Request a
Request.postXML Service
defaultService
response :: Logger
-> Service
-> Proxy CreateDistribution
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateDistribution)))
response =
(Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse CreateDistribution))
-> Logger
-> Service
-> Proxy CreateDistribution
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse CreateDistribution)))
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 Text
-> Maybe Distribution
-> Maybe Text
-> Int
-> CreateDistributionResponse
CreateDistributionResponse'
(Maybe Text
-> Maybe Distribution
-> Maybe Text
-> Int
-> CreateDistributionResponse)
-> Either String (Maybe Text)
-> Either
String
(Maybe Distribution
-> Maybe Text -> Int -> CreateDistributionResponse)
forall (f :: * -> *) a b. Functor 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 Distribution
-> Maybe Text -> Int -> CreateDistributionResponse)
-> Either String (Maybe Distribution)
-> Either String (Maybe Text -> Int -> CreateDistributionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node] -> Either String (Maybe Distribution)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
Either String (Maybe Text -> Int -> CreateDistributionResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateDistributionResponse)
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 -> CreateDistributionResponse)
-> Either String Int -> Either String CreateDistributionResponse
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 CreateDistribution
instance Prelude.NFData CreateDistribution
instance Core.ToElement CreateDistribution where
toElement :: CreateDistribution -> Element
toElement CreateDistribution' {DistributionConfig
distributionConfig :: DistributionConfig
$sel:distributionConfig:CreateDistribution' :: CreateDistribution -> DistributionConfig
..} =
Name -> DistributionConfig -> Element
forall a. ToXML a => Name -> a -> Element
Core.mkElement
Name
"{http://cloudfront.amazonaws.com/doc/2020-05-31/}DistributionConfig"
DistributionConfig
distributionConfig
instance Core.ToHeaders CreateDistribution where
toHeaders :: CreateDistribution -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateDistribution -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath CreateDistribution where
toPath :: CreateDistribution -> ByteString
toPath = ByteString -> CreateDistribution -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/2020-05-31/distribution"
instance Core.ToQuery CreateDistribution where
toQuery :: CreateDistribution -> QueryString
toQuery = QueryString -> CreateDistribution -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateDistributionResponse = CreateDistributionResponse'
{
CreateDistributionResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
CreateDistributionResponse -> Maybe Distribution
distribution :: Prelude.Maybe Distribution,
CreateDistributionResponse -> Maybe Text
location :: Prelude.Maybe Prelude.Text,
CreateDistributionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateDistributionResponse -> CreateDistributionResponse -> Bool
(CreateDistributionResponse -> CreateDistributionResponse -> Bool)
-> (CreateDistributionResponse
-> CreateDistributionResponse -> Bool)
-> Eq CreateDistributionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDistributionResponse -> CreateDistributionResponse -> Bool
$c/= :: CreateDistributionResponse -> CreateDistributionResponse -> Bool
== :: CreateDistributionResponse -> CreateDistributionResponse -> Bool
$c== :: CreateDistributionResponse -> CreateDistributionResponse -> Bool
Prelude.Eq, Int -> CreateDistributionResponse -> ShowS
[CreateDistributionResponse] -> ShowS
CreateDistributionResponse -> String
(Int -> CreateDistributionResponse -> ShowS)
-> (CreateDistributionResponse -> String)
-> ([CreateDistributionResponse] -> ShowS)
-> Show CreateDistributionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDistributionResponse] -> ShowS
$cshowList :: [CreateDistributionResponse] -> ShowS
show :: CreateDistributionResponse -> String
$cshow :: CreateDistributionResponse -> String
showsPrec :: Int -> CreateDistributionResponse -> ShowS
$cshowsPrec :: Int -> CreateDistributionResponse -> ShowS
Prelude.Show, (forall x.
CreateDistributionResponse -> Rep CreateDistributionResponse x)
-> (forall x.
Rep CreateDistributionResponse x -> CreateDistributionResponse)
-> Generic CreateDistributionResponse
forall x.
Rep CreateDistributionResponse x -> CreateDistributionResponse
forall x.
CreateDistributionResponse -> Rep CreateDistributionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDistributionResponse x -> CreateDistributionResponse
$cfrom :: forall x.
CreateDistributionResponse -> Rep CreateDistributionResponse x
Prelude.Generic)
newCreateDistributionResponse ::
Prelude.Int ->
CreateDistributionResponse
newCreateDistributionResponse :: Int -> CreateDistributionResponse
newCreateDistributionResponse Int
pHttpStatus_ =
CreateDistributionResponse' :: Maybe Text
-> Maybe Distribution
-> Maybe Text
-> Int
-> CreateDistributionResponse
CreateDistributionResponse'
{ $sel:eTag:CreateDistributionResponse' :: Maybe Text
eTag = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:distribution:CreateDistributionResponse' :: Maybe Distribution
distribution = Maybe Distribution
forall a. Maybe a
Prelude.Nothing,
$sel:location:CreateDistributionResponse' :: Maybe Text
location = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateDistributionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createDistributionResponse_eTag :: Lens.Lens' CreateDistributionResponse (Prelude.Maybe Prelude.Text)
createDistributionResponse_eTag :: (Maybe Text -> f (Maybe Text))
-> CreateDistributionResponse -> f CreateDistributionResponse
createDistributionResponse_eTag = (CreateDistributionResponse -> Maybe Text)
-> (CreateDistributionResponse
-> Maybe Text -> CreateDistributionResponse)
-> Lens
CreateDistributionResponse
CreateDistributionResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDistributionResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:CreateDistributionResponse' :: CreateDistributionResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: CreateDistributionResponse
s@CreateDistributionResponse' {} Maybe Text
a -> CreateDistributionResponse
s {$sel:eTag:CreateDistributionResponse' :: Maybe Text
eTag = Maybe Text
a} :: CreateDistributionResponse)
createDistributionResponse_distribution :: Lens.Lens' CreateDistributionResponse (Prelude.Maybe Distribution)
createDistributionResponse_distribution :: (Maybe Distribution -> f (Maybe Distribution))
-> CreateDistributionResponse -> f CreateDistributionResponse
createDistributionResponse_distribution = (CreateDistributionResponse -> Maybe Distribution)
-> (CreateDistributionResponse
-> Maybe Distribution -> CreateDistributionResponse)
-> Lens
CreateDistributionResponse
CreateDistributionResponse
(Maybe Distribution)
(Maybe Distribution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDistributionResponse' {Maybe Distribution
distribution :: Maybe Distribution
$sel:distribution:CreateDistributionResponse' :: CreateDistributionResponse -> Maybe Distribution
distribution} -> Maybe Distribution
distribution) (\s :: CreateDistributionResponse
s@CreateDistributionResponse' {} Maybe Distribution
a -> CreateDistributionResponse
s {$sel:distribution:CreateDistributionResponse' :: Maybe Distribution
distribution = Maybe Distribution
a} :: CreateDistributionResponse)
createDistributionResponse_location :: Lens.Lens' CreateDistributionResponse (Prelude.Maybe Prelude.Text)
createDistributionResponse_location :: (Maybe Text -> f (Maybe Text))
-> CreateDistributionResponse -> f CreateDistributionResponse
createDistributionResponse_location = (CreateDistributionResponse -> Maybe Text)
-> (CreateDistributionResponse
-> Maybe Text -> CreateDistributionResponse)
-> Lens
CreateDistributionResponse
CreateDistributionResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDistributionResponse' {Maybe Text
location :: Maybe Text
$sel:location:CreateDistributionResponse' :: CreateDistributionResponse -> Maybe Text
location} -> Maybe Text
location) (\s :: CreateDistributionResponse
s@CreateDistributionResponse' {} Maybe Text
a -> CreateDistributionResponse
s {$sel:location:CreateDistributionResponse' :: Maybe Text
location = Maybe Text
a} :: CreateDistributionResponse)
createDistributionResponse_httpStatus :: Lens.Lens' CreateDistributionResponse Prelude.Int
createDistributionResponse_httpStatus :: (Int -> f Int)
-> CreateDistributionResponse -> f CreateDistributionResponse
createDistributionResponse_httpStatus = (CreateDistributionResponse -> Int)
-> (CreateDistributionResponse
-> Int -> CreateDistributionResponse)
-> Lens
CreateDistributionResponse CreateDistributionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDistributionResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateDistributionResponse' :: CreateDistributionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateDistributionResponse
s@CreateDistributionResponse' {} Int
a -> CreateDistributionResponse
s {$sel:httpStatus:CreateDistributionResponse' :: Int
httpStatus = Int
a} :: CreateDistributionResponse)
instance Prelude.NFData CreateDistributionResponse