module Network.AWS.CloudWatchLogs.FilterLogEvents
(
filterLogEvents
, FilterLogEvents
, fleStartTime
, fleLogStreamNames
, fleNextToken
, fleEndTime
, fleLimit
, fleFilterPattern
, fleInterleaved
, fleLogGroupName
, filterLogEventsResponse
, FilterLogEventsResponse
, flersSearchedLogStreams
, flersNextToken
, flersEvents
, flersStatus
) where
import Network.AWS.CloudWatchLogs.Types
import Network.AWS.CloudWatchLogs.Types.Product
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data FilterLogEvents = FilterLogEvents'
{ _fleStartTime :: !(Maybe Nat)
, _fleLogStreamNames :: !(Maybe (List1 Text))
, _fleNextToken :: !(Maybe Text)
, _fleEndTime :: !(Maybe Nat)
, _fleLimit :: !(Maybe Nat)
, _fleFilterPattern :: !(Maybe Text)
, _fleInterleaved :: !(Maybe Bool)
, _fleLogGroupName :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
filterLogEvents
:: Text
-> FilterLogEvents
filterLogEvents pLogGroupName_ =
FilterLogEvents'
{ _fleStartTime = Nothing
, _fleLogStreamNames = Nothing
, _fleNextToken = Nothing
, _fleEndTime = Nothing
, _fleLimit = Nothing
, _fleFilterPattern = Nothing
, _fleInterleaved = Nothing
, _fleLogGroupName = pLogGroupName_
}
fleStartTime :: Lens' FilterLogEvents (Maybe Natural)
fleStartTime = lens _fleStartTime (\ s a -> s{_fleStartTime = a}) . mapping _Nat;
fleLogStreamNames :: Lens' FilterLogEvents (Maybe (NonEmpty Text))
fleLogStreamNames = lens _fleLogStreamNames (\ s a -> s{_fleLogStreamNames = a}) . mapping _List1;
fleNextToken :: Lens' FilterLogEvents (Maybe Text)
fleNextToken = lens _fleNextToken (\ s a -> s{_fleNextToken = a});
fleEndTime :: Lens' FilterLogEvents (Maybe Natural)
fleEndTime = lens _fleEndTime (\ s a -> s{_fleEndTime = a}) . mapping _Nat;
fleLimit :: Lens' FilterLogEvents (Maybe Natural)
fleLimit = lens _fleLimit (\ s a -> s{_fleLimit = a}) . mapping _Nat;
fleFilterPattern :: Lens' FilterLogEvents (Maybe Text)
fleFilterPattern = lens _fleFilterPattern (\ s a -> s{_fleFilterPattern = a});
fleInterleaved :: Lens' FilterLogEvents (Maybe Bool)
fleInterleaved = lens _fleInterleaved (\ s a -> s{_fleInterleaved = a});
fleLogGroupName :: Lens' FilterLogEvents Text
fleLogGroupName = lens _fleLogGroupName (\ s a -> s{_fleLogGroupName = a});
instance AWSPager FilterLogEvents where
page rq rs
| stop (rs ^. flersNextToken) = Nothing
| stop (rs ^. flersEvents) = Nothing
| otherwise =
Just $ rq & fleNextToken .~ rs ^. flersNextToken
instance AWSRequest FilterLogEvents where
type Sv FilterLogEvents = CloudWatchLogs
type Rs FilterLogEvents = FilterLogEventsResponse
request = postJSON
response
= receiveJSON
(\ s h x ->
FilterLogEventsResponse' <$>
(x .?> "searchedLogStreams" .!@ mempty) <*>
(x .?> "nextToken")
<*> (x .?> "events" .!@ mempty)
<*> (pure (fromEnum s)))
instance ToHeaders FilterLogEvents where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Logs_20140328.FilterLogEvents" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON FilterLogEvents where
toJSON FilterLogEvents'{..}
= object
["startTime" .= _fleStartTime,
"logStreamNames" .= _fleLogStreamNames,
"nextToken" .= _fleNextToken,
"endTime" .= _fleEndTime, "limit" .= _fleLimit,
"filterPattern" .= _fleFilterPattern,
"interleaved" .= _fleInterleaved,
"logGroupName" .= _fleLogGroupName]
instance ToPath FilterLogEvents where
toPath = const "/"
instance ToQuery FilterLogEvents where
toQuery = const mempty
data FilterLogEventsResponse = FilterLogEventsResponse'
{ _flersSearchedLogStreams :: !(Maybe [SearchedLogStream])
, _flersNextToken :: !(Maybe Text)
, _flersEvents :: !(Maybe [FilteredLogEvent])
, _flersStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
filterLogEventsResponse
:: Int
-> FilterLogEventsResponse
filterLogEventsResponse pStatus_ =
FilterLogEventsResponse'
{ _flersSearchedLogStreams = Nothing
, _flersNextToken = Nothing
, _flersEvents = Nothing
, _flersStatus = pStatus_
}
flersSearchedLogStreams :: Lens' FilterLogEventsResponse [SearchedLogStream]
flersSearchedLogStreams = lens _flersSearchedLogStreams (\ s a -> s{_flersSearchedLogStreams = a}) . _Default . _Coerce;
flersNextToken :: Lens' FilterLogEventsResponse (Maybe Text)
flersNextToken = lens _flersNextToken (\ s a -> s{_flersNextToken = a});
flersEvents :: Lens' FilterLogEventsResponse [FilteredLogEvent]
flersEvents = lens _flersEvents (\ s a -> s{_flersEvents = a}) . _Default . _Coerce;
flersStatus :: Lens' FilterLogEventsResponse Int
flersStatus = lens _flersStatus (\ s a -> s{_flersStatus = a});