{-# 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.GuardDuty.ListDetectors
(
listDetectors
, ListDetectors
, ldNextToken
, ldMaxResults
, listDetectorsResponse
, ListDetectorsResponse
, ldrsNextToken
, ldrsDetectorIds
, ldrsResponseStatus
) where
import Network.AWS.GuardDuty.Types
import Network.AWS.GuardDuty.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ListDetectors = ListDetectors'
{ _ldNextToken :: !(Maybe Text)
, _ldMaxResults :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listDetectors
:: ListDetectors
listDetectors = ListDetectors' {_ldNextToken = Nothing, _ldMaxResults = Nothing}
ldNextToken :: Lens' ListDetectors (Maybe Text)
ldNextToken = lens _ldNextToken (\ s a -> s{_ldNextToken = a})
ldMaxResults :: Lens' ListDetectors (Maybe Natural)
ldMaxResults = lens _ldMaxResults (\ s a -> s{_ldMaxResults = a}) . mapping _Nat
instance AWSPager ListDetectors where
page rq rs
| stop (rs ^. ldrsNextToken) = Nothing
| stop (rs ^. ldrsDetectorIds) = Nothing
| otherwise =
Just $ rq & ldNextToken .~ rs ^. ldrsNextToken
instance AWSRequest ListDetectors where
type Rs ListDetectors = ListDetectorsResponse
request = get guardDuty
response
= receiveJSON
(\ s h x ->
ListDetectorsResponse' <$>
(x .?> "nextToken") <*>
(x .?> "detectorIds" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable ListDetectors where
instance NFData ListDetectors where
instance ToHeaders ListDetectors where
toHeaders
= const
(mconcat
["Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToPath ListDetectors where
toPath = const "/detector"
instance ToQuery ListDetectors where
toQuery ListDetectors'{..}
= mconcat
["nextToken" =: _ldNextToken,
"maxResults" =: _ldMaxResults]
data ListDetectorsResponse = ListDetectorsResponse'
{ _ldrsNextToken :: !(Maybe Text)
, _ldrsDetectorIds :: !(Maybe [Text])
, _ldrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listDetectorsResponse
:: Int
-> ListDetectorsResponse
listDetectorsResponse pResponseStatus_ =
ListDetectorsResponse'
{ _ldrsNextToken = Nothing
, _ldrsDetectorIds = Nothing
, _ldrsResponseStatus = pResponseStatus_
}
ldrsNextToken :: Lens' ListDetectorsResponse (Maybe Text)
ldrsNextToken = lens _ldrsNextToken (\ s a -> s{_ldrsNextToken = a})
ldrsDetectorIds :: Lens' ListDetectorsResponse [Text]
ldrsDetectorIds = lens _ldrsDetectorIds (\ s a -> s{_ldrsDetectorIds = a}) . _Default . _Coerce
ldrsResponseStatus :: Lens' ListDetectorsResponse Int
ldrsResponseStatus = lens _ldrsResponseStatus (\ s a -> s{_ldrsResponseStatus = a})
instance NFData ListDetectorsResponse where