{-# 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.CloudWatchLogs.FilterLogEvents
(
filterLogEvents
, FilterLogEvents
, fleStartTime
, fleNextToken
, fleLogStreamNames
, fleEndTime
, fleLimit
, fleFilterPattern
, fleInterleaved
, fleLogGroupName
, filterLogEventsResponse
, FilterLogEventsResponse
, flersSearchedLogStreams
, flersNextToken
, flersEvents
, flersResponseStatus
) where
import Network.AWS.CloudWatchLogs.Types
import Network.AWS.CloudWatchLogs.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data FilterLogEvents = FilterLogEvents'
{ _fleStartTime :: !(Maybe Nat)
, _fleNextToken :: !(Maybe Text)
, _fleLogStreamNames :: !(Maybe (List1 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
, _fleNextToken = Nothing
, _fleLogStreamNames = 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;
fleNextToken :: Lens' FilterLogEvents (Maybe Text)
fleNextToken = lens _fleNextToken (\ s a -> s{_fleNextToken = a});
fleLogStreamNames :: Lens' FilterLogEvents (Maybe (NonEmpty Text))
fleLogStreamNames = lens _fleLogStreamNames (\ s a -> s{_fleLogStreamNames = a}) . mapping _List1;
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
| otherwise =
Just $ rq & fleNextToken .~ rs ^. flersNextToken
instance AWSRequest FilterLogEvents where
type Rs FilterLogEvents = FilterLogEventsResponse
request = postJSON cloudWatchLogs
response
= receiveJSON
(\ s h x ->
FilterLogEventsResponse' <$>
(x .?> "searchedLogStreams" .!@ mempty) <*>
(x .?> "nextToken")
<*> (x .?> "events" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable FilterLogEvents
instance NFData FilterLogEvents
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
(catMaybes
[("startTime" .=) <$> _fleStartTime,
("nextToken" .=) <$> _fleNextToken,
("logStreamNames" .=) <$> _fleLogStreamNames,
("endTime" .=) <$> _fleEndTime,
("limit" .=) <$> _fleLimit,
("filterPattern" .=) <$> _fleFilterPattern,
("interleaved" .=) <$> _fleInterleaved,
Just ("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])
, _flersResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
filterLogEventsResponse
:: Int
-> FilterLogEventsResponse
filterLogEventsResponse pResponseStatus_ =
FilterLogEventsResponse'
{ _flersSearchedLogStreams = Nothing
, _flersNextToken = Nothing
, _flersEvents = Nothing
, _flersResponseStatus = pResponseStatus_
}
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;
flersResponseStatus :: Lens' FilterLogEventsResponse Int
flersResponseStatus = lens _flersResponseStatus (\ s a -> s{_flersResponseStatus = a});
instance NFData FilterLogEventsResponse