module Network.AWS.Lambda.ListFunctions
(
ListFunctions
, listFunctions
, lfMarker
, lfMaxItems
, ListFunctionsResponse
, listFunctionsResponse
, lfrFunctions
, lfrNextMarker
) where
import Network.AWS.Data (Object)
import Network.AWS.Prelude
import Network.AWS.Request.RestJSON
import Network.AWS.Lambda.Types
import qualified GHC.Exts
data ListFunctions = ListFunctions
{ _lfMarker :: Maybe Text
, _lfMaxItems :: Maybe Nat
} deriving (Eq, Ord, Read, Show)
listFunctions :: ListFunctions
listFunctions = ListFunctions
{ _lfMarker = Nothing
, _lfMaxItems = Nothing
}
lfMarker :: Lens' ListFunctions (Maybe Text)
lfMarker = lens _lfMarker (\s a -> s { _lfMarker = a })
lfMaxItems :: Lens' ListFunctions (Maybe Natural)
lfMaxItems = lens _lfMaxItems (\s a -> s { _lfMaxItems = a }) . mapping _Nat
data ListFunctionsResponse = ListFunctionsResponse
{ _lfrFunctions :: List "Functions" FunctionConfiguration
, _lfrNextMarker :: Maybe Text
} deriving (Eq, Read, Show)
listFunctionsResponse :: ListFunctionsResponse
listFunctionsResponse = ListFunctionsResponse
{ _lfrNextMarker = Nothing
, _lfrFunctions = mempty
}
lfrFunctions :: Lens' ListFunctionsResponse [FunctionConfiguration]
lfrFunctions = lens _lfrFunctions (\s a -> s { _lfrFunctions = a }) . _List
lfrNextMarker :: Lens' ListFunctionsResponse (Maybe Text)
lfrNextMarker = lens _lfrNextMarker (\s a -> s { _lfrNextMarker = a })
instance ToPath ListFunctions where
toPath = const "/2015-03-31/functions/"
instance ToQuery ListFunctions where
toQuery ListFunctions{..} = mconcat
[ "Marker" =? _lfMarker
, "MaxItems" =? _lfMaxItems
]
instance ToHeaders ListFunctions
instance ToJSON ListFunctions where
toJSON = const (toJSON Empty)
instance AWSRequest ListFunctions where
type Sv ListFunctions = Lambda
type Rs ListFunctions = ListFunctionsResponse
request = get
response = jsonResponse
instance FromJSON ListFunctionsResponse where
parseJSON = withObject "ListFunctionsResponse" $ \o -> ListFunctionsResponse
<$> o .:? "Functions" .!= mempty
<*> o .:? "NextMarker"
instance AWSPager ListFunctions where
page rq rs
| stop (rs ^. lfrNextMarker) = Nothing
| otherwise = (\x -> rq & lfMarker ?~ x)
<$> (rs ^. lfrNextMarker)