{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.Shield.ListProtections
(
listProtections
, ListProtections
, lpNextToken
, lpMaxResults
, listProtectionsResponse
, ListProtectionsResponse
, lprsProtections
, lprsNextToken
, lprsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.Shield.Types
import Network.AWS.Shield.Types.Product
data ListProtections = ListProtections'
{ _lpNextToken :: !(Maybe Text)
, _lpMaxResults :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listProtections
:: ListProtections
listProtections =
ListProtections' {_lpNextToken = Nothing, _lpMaxResults = Nothing}
lpNextToken :: Lens' ListProtections (Maybe Text)
lpNextToken = lens _lpNextToken (\ s a -> s{_lpNextToken = a})
lpMaxResults :: Lens' ListProtections (Maybe Natural)
lpMaxResults = lens _lpMaxResults (\ s a -> s{_lpMaxResults = a}) . mapping _Nat
instance AWSPager ListProtections where
page rq rs
| stop (rs ^. lprsNextToken) = Nothing
| stop (rs ^. lprsProtections) = Nothing
| otherwise =
Just $ rq & lpNextToken .~ rs ^. lprsNextToken
instance AWSRequest ListProtections where
type Rs ListProtections = ListProtectionsResponse
request = postJSON shield
response
= receiveJSON
(\ s h x ->
ListProtectionsResponse' <$>
(x .?> "Protections" .!@ mempty) <*>
(x .?> "NextToken")
<*> (pure (fromEnum s)))
instance Hashable ListProtections where
instance NFData ListProtections where
instance ToHeaders ListProtections where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSShield_20160616.ListProtections" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListProtections where
toJSON ListProtections'{..}
= object
(catMaybes
[("NextToken" .=) <$> _lpNextToken,
("MaxResults" .=) <$> _lpMaxResults])
instance ToPath ListProtections where
toPath = const "/"
instance ToQuery ListProtections where
toQuery = const mempty
data ListProtectionsResponse = ListProtectionsResponse'
{ _lprsProtections :: !(Maybe [Protection])
, _lprsNextToken :: !(Maybe Text)
, _lprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listProtectionsResponse
:: Int
-> ListProtectionsResponse
listProtectionsResponse pResponseStatus_ =
ListProtectionsResponse'
{ _lprsProtections = Nothing
, _lprsNextToken = Nothing
, _lprsResponseStatus = pResponseStatus_
}
lprsProtections :: Lens' ListProtectionsResponse [Protection]
lprsProtections = lens _lprsProtections (\ s a -> s{_lprsProtections = a}) . _Default . _Coerce
lprsNextToken :: Lens' ListProtectionsResponse (Maybe Text)
lprsNextToken = lens _lprsNextToken (\ s a -> s{_lprsNextToken = a})
lprsResponseStatus :: Lens' ListProtectionsResponse Int
lprsResponseStatus = lens _lprsResponseStatus (\ s a -> s{_lprsResponseStatus = a})
instance NFData ListProtectionsResponse where