module Network.AWS.CloudFront.ListDistributions
(
ListDistributions
, listDistributions
, ldMarker
, ldMaxItems
, ListDistributionsResponse
, listDistributionsResponse
, ldrDistributionList
) where
import Network.AWS.Prelude
import Network.AWS.Request.RestXML
import Network.AWS.CloudFront.Types
import qualified GHC.Exts
data ListDistributions = ListDistributions
{ _ldMarker :: Maybe Text
, _ldMaxItems :: Maybe Text
} deriving (Eq, Ord, Show)
listDistributions :: ListDistributions
listDistributions = ListDistributions
{ _ldMarker = Nothing
, _ldMaxItems = Nothing
}
ldMarker :: Lens' ListDistributions (Maybe Text)
ldMarker = lens _ldMarker (\s a -> s { _ldMarker = a })
ldMaxItems :: Lens' ListDistributions (Maybe Text)
ldMaxItems = lens _ldMaxItems (\s a -> s { _ldMaxItems = a })
newtype ListDistributionsResponse = ListDistributionsResponse
{ _ldrDistributionList :: DistributionList
} deriving (Eq, Show)
listDistributionsResponse :: DistributionList
-> ListDistributionsResponse
listDistributionsResponse p1 = ListDistributionsResponse
{ _ldrDistributionList = p1
}
ldrDistributionList :: Lens' ListDistributionsResponse DistributionList
ldrDistributionList =
lens _ldrDistributionList (\s a -> s { _ldrDistributionList = a })
instance ToPath ListDistributions where
toPath = const "/2014-05-31/distribution"
instance ToQuery ListDistributions where
toQuery ListDistributions{..} = mconcat
[ "Marker" =? _ldMarker
, "MaxItems" =? _ldMaxItems
]
instance ToHeaders ListDistributions
instance ToXMLRoot ListDistributions where
toXMLRoot = const (namespaced ns "ListDistributions" [])
instance ToXML ListDistributions
instance AWSRequest ListDistributions where
type Sv ListDistributions = CloudFront
type Rs ListDistributions = ListDistributionsResponse
request = get
response = xmlResponse
instance FromXML ListDistributionsResponse where
parseXML x = ListDistributionsResponse
<$> x .@ "DistributionList"
instance AWSPager ListDistributions where
page rq rs
| stop (rs ^. ldrDistributionList . dlIsTruncated) = Nothing
| otherwise = Just $ rq
& ldMarker .~ rs ^. ldrDistributionList . dlNextMarker