{-# 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.GetDistribution
(
GetDistribution (..),
newGetDistribution,
getDistribution_id,
GetDistributionResponse (..),
newGetDistributionResponse,
getDistributionResponse_eTag,
getDistributionResponse_distribution,
getDistributionResponse_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 GetDistribution = GetDistribution'
{
GetDistribution -> Text
id :: Prelude.Text
}
deriving (GetDistribution -> GetDistribution -> Bool
(GetDistribution -> GetDistribution -> Bool)
-> (GetDistribution -> GetDistribution -> Bool)
-> Eq GetDistribution
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDistribution -> GetDistribution -> Bool
$c/= :: GetDistribution -> GetDistribution -> Bool
== :: GetDistribution -> GetDistribution -> Bool
$c== :: GetDistribution -> GetDistribution -> Bool
Prelude.Eq, ReadPrec [GetDistribution]
ReadPrec GetDistribution
Int -> ReadS GetDistribution
ReadS [GetDistribution]
(Int -> ReadS GetDistribution)
-> ReadS [GetDistribution]
-> ReadPrec GetDistribution
-> ReadPrec [GetDistribution]
-> Read GetDistribution
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDistribution]
$creadListPrec :: ReadPrec [GetDistribution]
readPrec :: ReadPrec GetDistribution
$creadPrec :: ReadPrec GetDistribution
readList :: ReadS [GetDistribution]
$creadList :: ReadS [GetDistribution]
readsPrec :: Int -> ReadS GetDistribution
$creadsPrec :: Int -> ReadS GetDistribution
Prelude.Read, Int -> GetDistribution -> ShowS
[GetDistribution] -> ShowS
GetDistribution -> String
(Int -> GetDistribution -> ShowS)
-> (GetDistribution -> String)
-> ([GetDistribution] -> ShowS)
-> Show GetDistribution
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDistribution] -> ShowS
$cshowList :: [GetDistribution] -> ShowS
show :: GetDistribution -> String
$cshow :: GetDistribution -> String
showsPrec :: Int -> GetDistribution -> ShowS
$cshowsPrec :: Int -> GetDistribution -> ShowS
Prelude.Show, (forall x. GetDistribution -> Rep GetDistribution x)
-> (forall x. Rep GetDistribution x -> GetDistribution)
-> Generic GetDistribution
forall x. Rep GetDistribution x -> GetDistribution
forall x. GetDistribution -> Rep GetDistribution x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDistribution x -> GetDistribution
$cfrom :: forall x. GetDistribution -> Rep GetDistribution x
Prelude.Generic)
newGetDistribution ::
Prelude.Text ->
GetDistribution
newGetDistribution :: Text -> GetDistribution
newGetDistribution Text
pId_ = GetDistribution' :: Text -> GetDistribution
GetDistribution' {$sel:id:GetDistribution' :: Text
id = Text
pId_}
getDistribution_id :: Lens.Lens' GetDistribution Prelude.Text
getDistribution_id :: (Text -> f Text) -> GetDistribution -> f GetDistribution
getDistribution_id = (GetDistribution -> Text)
-> (GetDistribution -> Text -> GetDistribution)
-> Lens GetDistribution GetDistribution Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDistribution' {Text
id :: Text
$sel:id:GetDistribution' :: GetDistribution -> Text
id} -> Text
id) (\s :: GetDistribution
s@GetDistribution' {} Text
a -> GetDistribution
s {$sel:id:GetDistribution' :: Text
id = Text
a} :: GetDistribution)
instance Core.AWSRequest GetDistribution where
type
AWSResponse GetDistribution =
GetDistributionResponse
request :: GetDistribution -> Request GetDistribution
request = Service -> GetDistribution -> Request GetDistribution
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy GetDistribution
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDistribution)))
response =
(Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse GetDistribution))
-> Logger
-> Service
-> Proxy GetDistribution
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDistribution)))
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 -> Int -> GetDistributionResponse
GetDistributionResponse'
(Maybe Text
-> Maybe Distribution -> Int -> GetDistributionResponse)
-> Either String (Maybe Text)
-> Either
String (Maybe Distribution -> Int -> GetDistributionResponse)
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 -> Int -> GetDistributionResponse)
-> Either String (Maybe Distribution)
-> Either String (Int -> GetDistributionResponse)
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 (Int -> GetDistributionResponse)
-> Either String Int -> Either String GetDistributionResponse
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 GetDistribution
instance Prelude.NFData GetDistribution
instance Core.ToHeaders GetDistribution where
toHeaders :: GetDistribution -> ResponseHeaders
toHeaders = ResponseHeaders -> GetDistribution -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath GetDistribution where
toPath :: GetDistribution -> ByteString
toPath GetDistribution' {Text
id :: Text
$sel:id:GetDistribution' :: GetDistribution -> 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
id]
instance Core.ToQuery GetDistribution where
toQuery :: GetDistribution -> QueryString
toQuery = QueryString -> GetDistribution -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetDistributionResponse = GetDistributionResponse'
{
GetDistributionResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
GetDistributionResponse -> Maybe Distribution
distribution :: Prelude.Maybe Distribution,
GetDistributionResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetDistributionResponse -> GetDistributionResponse -> Bool
(GetDistributionResponse -> GetDistributionResponse -> Bool)
-> (GetDistributionResponse -> GetDistributionResponse -> Bool)
-> Eq GetDistributionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDistributionResponse -> GetDistributionResponse -> Bool
$c/= :: GetDistributionResponse -> GetDistributionResponse -> Bool
== :: GetDistributionResponse -> GetDistributionResponse -> Bool
$c== :: GetDistributionResponse -> GetDistributionResponse -> Bool
Prelude.Eq, Int -> GetDistributionResponse -> ShowS
[GetDistributionResponse] -> ShowS
GetDistributionResponse -> String
(Int -> GetDistributionResponse -> ShowS)
-> (GetDistributionResponse -> String)
-> ([GetDistributionResponse] -> ShowS)
-> Show GetDistributionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDistributionResponse] -> ShowS
$cshowList :: [GetDistributionResponse] -> ShowS
show :: GetDistributionResponse -> String
$cshow :: GetDistributionResponse -> String
showsPrec :: Int -> GetDistributionResponse -> ShowS
$cshowsPrec :: Int -> GetDistributionResponse -> ShowS
Prelude.Show, (forall x.
GetDistributionResponse -> Rep GetDistributionResponse x)
-> (forall x.
Rep GetDistributionResponse x -> GetDistributionResponse)
-> Generic GetDistributionResponse
forall x. Rep GetDistributionResponse x -> GetDistributionResponse
forall x. GetDistributionResponse -> Rep GetDistributionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDistributionResponse x -> GetDistributionResponse
$cfrom :: forall x. GetDistributionResponse -> Rep GetDistributionResponse x
Prelude.Generic)
newGetDistributionResponse ::
Prelude.Int ->
GetDistributionResponse
newGetDistributionResponse :: Int -> GetDistributionResponse
newGetDistributionResponse Int
pHttpStatus_ =
GetDistributionResponse' :: Maybe Text -> Maybe Distribution -> Int -> GetDistributionResponse
GetDistributionResponse'
{ $sel:eTag:GetDistributionResponse' :: Maybe Text
eTag = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:distribution:GetDistributionResponse' :: Maybe Distribution
distribution = Maybe Distribution
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetDistributionResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getDistributionResponse_eTag :: Lens.Lens' GetDistributionResponse (Prelude.Maybe Prelude.Text)
getDistributionResponse_eTag :: (Maybe Text -> f (Maybe Text))
-> GetDistributionResponse -> f GetDistributionResponse
getDistributionResponse_eTag = (GetDistributionResponse -> Maybe Text)
-> (GetDistributionResponse
-> Maybe Text -> GetDistributionResponse)
-> Lens
GetDistributionResponse
GetDistributionResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDistributionResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:GetDistributionResponse' :: GetDistributionResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: GetDistributionResponse
s@GetDistributionResponse' {} Maybe Text
a -> GetDistributionResponse
s {$sel:eTag:GetDistributionResponse' :: Maybe Text
eTag = Maybe Text
a} :: GetDistributionResponse)
getDistributionResponse_distribution :: Lens.Lens' GetDistributionResponse (Prelude.Maybe Distribution)
getDistributionResponse_distribution :: (Maybe Distribution -> f (Maybe Distribution))
-> GetDistributionResponse -> f GetDistributionResponse
getDistributionResponse_distribution = (GetDistributionResponse -> Maybe Distribution)
-> (GetDistributionResponse
-> Maybe Distribution -> GetDistributionResponse)
-> Lens
GetDistributionResponse
GetDistributionResponse
(Maybe Distribution)
(Maybe Distribution)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDistributionResponse' {Maybe Distribution
distribution :: Maybe Distribution
$sel:distribution:GetDistributionResponse' :: GetDistributionResponse -> Maybe Distribution
distribution} -> Maybe Distribution
distribution) (\s :: GetDistributionResponse
s@GetDistributionResponse' {} Maybe Distribution
a -> GetDistributionResponse
s {$sel:distribution:GetDistributionResponse' :: Maybe Distribution
distribution = Maybe Distribution
a} :: GetDistributionResponse)
getDistributionResponse_httpStatus :: Lens.Lens' GetDistributionResponse Prelude.Int
getDistributionResponse_httpStatus :: (Int -> f Int)
-> GetDistributionResponse -> f GetDistributionResponse
getDistributionResponse_httpStatus = (GetDistributionResponse -> Int)
-> (GetDistributionResponse -> Int -> GetDistributionResponse)
-> Lens GetDistributionResponse GetDistributionResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDistributionResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetDistributionResponse' :: GetDistributionResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetDistributionResponse
s@GetDistributionResponse' {} Int
a -> GetDistributionResponse
s {$sel:httpStatus:GetDistributionResponse' :: Int
httpStatus = Int
a} :: GetDistributionResponse)
instance Prelude.NFData GetDistributionResponse