{-# 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.ListDistributions
(
ListDistributions (..),
newListDistributions,
listDistributions_marker,
listDistributions_maxItems,
ListDistributionsResponse (..),
newListDistributionsResponse,
listDistributionsResponse_httpStatus,
listDistributionsResponse_distributionList,
)
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 ListDistributions = ListDistributions'
{
ListDistributions -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
ListDistributions -> Maybe Text
maxItems :: Prelude.Maybe Prelude.Text
}
deriving (ListDistributions -> ListDistributions -> Bool
(ListDistributions -> ListDistributions -> Bool)
-> (ListDistributions -> ListDistributions -> Bool)
-> Eq ListDistributions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDistributions -> ListDistributions -> Bool
$c/= :: ListDistributions -> ListDistributions -> Bool
== :: ListDistributions -> ListDistributions -> Bool
$c== :: ListDistributions -> ListDistributions -> Bool
Prelude.Eq, ReadPrec [ListDistributions]
ReadPrec ListDistributions
Int -> ReadS ListDistributions
ReadS [ListDistributions]
(Int -> ReadS ListDistributions)
-> ReadS [ListDistributions]
-> ReadPrec ListDistributions
-> ReadPrec [ListDistributions]
-> Read ListDistributions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDistributions]
$creadListPrec :: ReadPrec [ListDistributions]
readPrec :: ReadPrec ListDistributions
$creadPrec :: ReadPrec ListDistributions
readList :: ReadS [ListDistributions]
$creadList :: ReadS [ListDistributions]
readsPrec :: Int -> ReadS ListDistributions
$creadsPrec :: Int -> ReadS ListDistributions
Prelude.Read, Int -> ListDistributions -> ShowS
[ListDistributions] -> ShowS
ListDistributions -> String
(Int -> ListDistributions -> ShowS)
-> (ListDistributions -> String)
-> ([ListDistributions] -> ShowS)
-> Show ListDistributions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDistributions] -> ShowS
$cshowList :: [ListDistributions] -> ShowS
show :: ListDistributions -> String
$cshow :: ListDistributions -> String
showsPrec :: Int -> ListDistributions -> ShowS
$cshowsPrec :: Int -> ListDistributions -> ShowS
Prelude.Show, (forall x. ListDistributions -> Rep ListDistributions x)
-> (forall x. Rep ListDistributions x -> ListDistributions)
-> Generic ListDistributions
forall x. Rep ListDistributions x -> ListDistributions
forall x. ListDistributions -> Rep ListDistributions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDistributions x -> ListDistributions
$cfrom :: forall x. ListDistributions -> Rep ListDistributions x
Prelude.Generic)
newListDistributions ::
ListDistributions
newListDistributions :: ListDistributions
newListDistributions =
ListDistributions' :: Maybe Text -> Maybe Text -> ListDistributions
ListDistributions'
{ $sel:marker:ListDistributions' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:maxItems:ListDistributions' :: Maybe Text
maxItems = Maybe Text
forall a. Maybe a
Prelude.Nothing
}
listDistributions_marker :: Lens.Lens' ListDistributions (Prelude.Maybe Prelude.Text)
listDistributions_marker :: (Maybe Text -> f (Maybe Text))
-> ListDistributions -> f ListDistributions
listDistributions_marker = (ListDistributions -> Maybe Text)
-> (ListDistributions -> Maybe Text -> ListDistributions)
-> Lens
ListDistributions ListDistributions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDistributions' {Maybe Text
marker :: Maybe Text
$sel:marker:ListDistributions' :: ListDistributions -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListDistributions
s@ListDistributions' {} Maybe Text
a -> ListDistributions
s {$sel:marker:ListDistributions' :: Maybe Text
marker = Maybe Text
a} :: ListDistributions)
listDistributions_maxItems :: Lens.Lens' ListDistributions (Prelude.Maybe Prelude.Text)
listDistributions_maxItems :: (Maybe Text -> f (Maybe Text))
-> ListDistributions -> f ListDistributions
listDistributions_maxItems = (ListDistributions -> Maybe Text)
-> (ListDistributions -> Maybe Text -> ListDistributions)
-> Lens
ListDistributions ListDistributions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDistributions' {Maybe Text
maxItems :: Maybe Text
$sel:maxItems:ListDistributions' :: ListDistributions -> Maybe Text
maxItems} -> Maybe Text
maxItems) (\s :: ListDistributions
s@ListDistributions' {} Maybe Text
a -> ListDistributions
s {$sel:maxItems:ListDistributions' :: Maybe Text
maxItems = Maybe Text
a} :: ListDistributions)
instance Core.AWSPager ListDistributions where
page :: ListDistributions
-> AWSResponse ListDistributions -> Maybe ListDistributions
page ListDistributions
rq AWSResponse ListDistributions
rs
| Bool -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListDistributions
ListDistributionsResponse
rs
ListDistributionsResponse
-> Getting Bool ListDistributionsResponse Bool -> Bool
forall s a. s -> Getting a s a -> a
Lens.^. (DistributionList -> Const Bool DistributionList)
-> ListDistributionsResponse
-> Const Bool ListDistributionsResponse
Lens' ListDistributionsResponse DistributionList
listDistributionsResponse_distributionList
((DistributionList -> Const Bool DistributionList)
-> ListDistributionsResponse
-> Const Bool ListDistributionsResponse)
-> ((Bool -> Const Bool Bool)
-> DistributionList -> Const Bool DistributionList)
-> Getting Bool ListDistributionsResponse Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Bool -> Const Bool Bool)
-> DistributionList -> Const Bool DistributionList
Lens' DistributionList Bool
distributionList_isTruncated
) =
Maybe ListDistributions
forall a. Maybe a
Prelude.Nothing
| Maybe Text -> Bool
forall a. Maybe a -> Bool
Prelude.isNothing
( AWSResponse ListDistributions
ListDistributionsResponse
rs
ListDistributionsResponse
-> Getting (First Text) ListDistributionsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (DistributionList -> Const (First Text) DistributionList)
-> ListDistributionsResponse
-> Const (First Text) ListDistributionsResponse
Lens' ListDistributionsResponse DistributionList
listDistributionsResponse_distributionList
((DistributionList -> Const (First Text) DistributionList)
-> ListDistributionsResponse
-> Const (First Text) ListDistributionsResponse)
-> ((Text -> Const (First Text) Text)
-> DistributionList -> Const (First Text) DistributionList)
-> Getting (First Text) ListDistributionsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe Text -> Const (First Text) (Maybe Text))
-> DistributionList -> Const (First Text) DistributionList
Lens' DistributionList (Maybe Text)
distributionList_nextMarker
((Maybe Text -> Const (First Text) (Maybe Text))
-> DistributionList -> Const (First Text) DistributionList)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> (Text -> Const (First Text) Text)
-> DistributionList
-> Const (First Text) DistributionList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe ListDistributions
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
ListDistributions -> Maybe ListDistributions
forall a. a -> Maybe a
Prelude.Just (ListDistributions -> Maybe ListDistributions)
-> ListDistributions -> Maybe ListDistributions
forall a b. (a -> b) -> a -> b
Prelude.$
ListDistributions
rq
ListDistributions
-> (ListDistributions -> ListDistributions) -> ListDistributions
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListDistributions -> Identity ListDistributions
Lens ListDistributions ListDistributions (Maybe Text) (Maybe Text)
listDistributions_marker
((Maybe Text -> Identity (Maybe Text))
-> ListDistributions -> Identity ListDistributions)
-> Maybe Text -> ListDistributions -> ListDistributions
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListDistributions
ListDistributionsResponse
rs
ListDistributionsResponse
-> Getting (First Text) ListDistributionsResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (DistributionList -> Const (First Text) DistributionList)
-> ListDistributionsResponse
-> Const (First Text) ListDistributionsResponse
Lens' ListDistributionsResponse DistributionList
listDistributionsResponse_distributionList
((DistributionList -> Const (First Text) DistributionList)
-> ListDistributionsResponse
-> Const (First Text) ListDistributionsResponse)
-> ((Text -> Const (First Text) Text)
-> DistributionList -> Const (First Text) DistributionList)
-> Getting (First Text) ListDistributionsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe Text -> Const (First Text) (Maybe Text))
-> DistributionList -> Const (First Text) DistributionList
Lens' DistributionList (Maybe Text)
distributionList_nextMarker
((Maybe Text -> Const (First Text) (Maybe Text))
-> DistributionList -> Const (First Text) DistributionList)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> (Text -> Const (First Text) Text)
-> DistributionList
-> Const (First Text) DistributionList
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest ListDistributions where
type
AWSResponse ListDistributions =
ListDistributionsResponse
request :: ListDistributions -> Request ListDistributions
request = Service -> ListDistributions -> Request ListDistributions
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy ListDistributions
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ListDistributions)))
response =
(Int
-> ResponseHeaders
-> [Node]
-> Either String (AWSResponse ListDistributions))
-> Logger
-> Service
-> Proxy ListDistributions
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ListDistributions)))
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 ->
Int -> DistributionList -> ListDistributionsResponse
ListDistributionsResponse'
(Int -> DistributionList -> ListDistributionsResponse)
-> Either String Int
-> Either String (DistributionList -> ListDistributionsResponse)
forall (f :: * -> *) a b. Functor 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))
Either String (DistributionList -> ListDistributionsResponse)
-> Either String DistributionList
-> Either String ListDistributionsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node] -> Either String DistributionList
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
)
instance Prelude.Hashable ListDistributions
instance Prelude.NFData ListDistributions
instance Core.ToHeaders ListDistributions where
toHeaders :: ListDistributions -> ResponseHeaders
toHeaders = ResponseHeaders -> ListDistributions -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty
instance Core.ToPath ListDistributions where
toPath :: ListDistributions -> ByteString
toPath = ByteString -> ListDistributions -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/2020-05-31/distribution"
instance Core.ToQuery ListDistributions where
toQuery :: ListDistributions -> QueryString
toQuery ListDistributions' {Maybe Text
maxItems :: Maybe Text
marker :: Maybe Text
$sel:maxItems:ListDistributions' :: ListDistributions -> Maybe Text
$sel:marker:ListDistributions' :: ListDistributions -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"Marker" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
marker,
ByteString
"MaxItems" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
maxItems
]
data ListDistributionsResponse = ListDistributionsResponse'
{
ListDistributionsResponse -> Int
httpStatus :: Prelude.Int,
ListDistributionsResponse -> DistributionList
distributionList :: DistributionList
}
deriving (ListDistributionsResponse -> ListDistributionsResponse -> Bool
(ListDistributionsResponse -> ListDistributionsResponse -> Bool)
-> (ListDistributionsResponse -> ListDistributionsResponse -> Bool)
-> Eq ListDistributionsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDistributionsResponse -> ListDistributionsResponse -> Bool
$c/= :: ListDistributionsResponse -> ListDistributionsResponse -> Bool
== :: ListDistributionsResponse -> ListDistributionsResponse -> Bool
$c== :: ListDistributionsResponse -> ListDistributionsResponse -> Bool
Prelude.Eq, ReadPrec [ListDistributionsResponse]
ReadPrec ListDistributionsResponse
Int -> ReadS ListDistributionsResponse
ReadS [ListDistributionsResponse]
(Int -> ReadS ListDistributionsResponse)
-> ReadS [ListDistributionsResponse]
-> ReadPrec ListDistributionsResponse
-> ReadPrec [ListDistributionsResponse]
-> Read ListDistributionsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDistributionsResponse]
$creadListPrec :: ReadPrec [ListDistributionsResponse]
readPrec :: ReadPrec ListDistributionsResponse
$creadPrec :: ReadPrec ListDistributionsResponse
readList :: ReadS [ListDistributionsResponse]
$creadList :: ReadS [ListDistributionsResponse]
readsPrec :: Int -> ReadS ListDistributionsResponse
$creadsPrec :: Int -> ReadS ListDistributionsResponse
Prelude.Read, Int -> ListDistributionsResponse -> ShowS
[ListDistributionsResponse] -> ShowS
ListDistributionsResponse -> String
(Int -> ListDistributionsResponse -> ShowS)
-> (ListDistributionsResponse -> String)
-> ([ListDistributionsResponse] -> ShowS)
-> Show ListDistributionsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDistributionsResponse] -> ShowS
$cshowList :: [ListDistributionsResponse] -> ShowS
show :: ListDistributionsResponse -> String
$cshow :: ListDistributionsResponse -> String
showsPrec :: Int -> ListDistributionsResponse -> ShowS
$cshowsPrec :: Int -> ListDistributionsResponse -> ShowS
Prelude.Show, (forall x.
ListDistributionsResponse -> Rep ListDistributionsResponse x)
-> (forall x.
Rep ListDistributionsResponse x -> ListDistributionsResponse)
-> Generic ListDistributionsResponse
forall x.
Rep ListDistributionsResponse x -> ListDistributionsResponse
forall x.
ListDistributionsResponse -> Rep ListDistributionsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListDistributionsResponse x -> ListDistributionsResponse
$cfrom :: forall x.
ListDistributionsResponse -> Rep ListDistributionsResponse x
Prelude.Generic)
newListDistributionsResponse ::
Prelude.Int ->
DistributionList ->
ListDistributionsResponse
newListDistributionsResponse :: Int -> DistributionList -> ListDistributionsResponse
newListDistributionsResponse
Int
pHttpStatus_
DistributionList
pDistributionList_ =
ListDistributionsResponse' :: Int -> DistributionList -> ListDistributionsResponse
ListDistributionsResponse'
{ $sel:httpStatus:ListDistributionsResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:distributionList:ListDistributionsResponse' :: DistributionList
distributionList = DistributionList
pDistributionList_
}
listDistributionsResponse_httpStatus :: Lens.Lens' ListDistributionsResponse Prelude.Int
listDistributionsResponse_httpStatus :: (Int -> f Int)
-> ListDistributionsResponse -> f ListDistributionsResponse
listDistributionsResponse_httpStatus = (ListDistributionsResponse -> Int)
-> (ListDistributionsResponse -> Int -> ListDistributionsResponse)
-> Lens ListDistributionsResponse ListDistributionsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDistributionsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListDistributionsResponse' :: ListDistributionsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListDistributionsResponse
s@ListDistributionsResponse' {} Int
a -> ListDistributionsResponse
s {$sel:httpStatus:ListDistributionsResponse' :: Int
httpStatus = Int
a} :: ListDistributionsResponse)
listDistributionsResponse_distributionList :: Lens.Lens' ListDistributionsResponse DistributionList
listDistributionsResponse_distributionList :: (DistributionList -> f DistributionList)
-> ListDistributionsResponse -> f ListDistributionsResponse
listDistributionsResponse_distributionList = (ListDistributionsResponse -> DistributionList)
-> (ListDistributionsResponse
-> DistributionList -> ListDistributionsResponse)
-> Lens' ListDistributionsResponse DistributionList
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDistributionsResponse' {DistributionList
distributionList :: DistributionList
$sel:distributionList:ListDistributionsResponse' :: ListDistributionsResponse -> DistributionList
distributionList} -> DistributionList
distributionList) (\s :: ListDistributionsResponse
s@ListDistributionsResponse' {} DistributionList
a -> ListDistributionsResponse
s {$sel:distributionList:ListDistributionsResponse' :: DistributionList
distributionList = DistributionList
a} :: ListDistributionsResponse)
instance Prelude.NFData ListDistributionsResponse