module Network.AWS.CloudWatchLogs.DescribeLogGroups
(
describeLogGroups
, DescribeLogGroups
, dlgNextToken
, dlgLogGroupNamePrefix
, dlgLimit
, describeLogGroupsResponse
, DescribeLogGroupsResponse
, dlgrsLogGroups
, dlgrsNextToken
, dlgrsStatus
) 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 DescribeLogGroups = DescribeLogGroups'
{ _dlgNextToken :: !(Maybe Text)
, _dlgLogGroupNamePrefix :: !(Maybe Text)
, _dlgLimit :: !(Maybe Nat)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeLogGroups
:: DescribeLogGroups
describeLogGroups =
DescribeLogGroups'
{ _dlgNextToken = Nothing
, _dlgLogGroupNamePrefix = Nothing
, _dlgLimit = Nothing
}
dlgNextToken :: Lens' DescribeLogGroups (Maybe Text)
dlgNextToken = lens _dlgNextToken (\ s a -> s{_dlgNextToken = a});
dlgLogGroupNamePrefix :: Lens' DescribeLogGroups (Maybe Text)
dlgLogGroupNamePrefix = lens _dlgLogGroupNamePrefix (\ s a -> s{_dlgLogGroupNamePrefix = a});
dlgLimit :: Lens' DescribeLogGroups (Maybe Natural)
dlgLimit = lens _dlgLimit (\ s a -> s{_dlgLimit = a}) . mapping _Nat;
instance AWSPager DescribeLogGroups where
page rq rs
| stop (rs ^. dlgrsNextToken) = Nothing
| stop (rs ^. dlgrsLogGroups) = Nothing
| otherwise =
Just $ rq & dlgNextToken .~ rs ^. dlgrsNextToken
instance AWSRequest DescribeLogGroups where
type Sv DescribeLogGroups = CloudWatchLogs
type Rs DescribeLogGroups = DescribeLogGroupsResponse
request = postJSON
response
= receiveJSON
(\ s h x ->
DescribeLogGroupsResponse' <$>
(x .?> "logGroups" .!@ mempty) <*>
(x .?> "nextToken")
<*> (pure (fromEnum s)))
instance ToHeaders DescribeLogGroups where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Logs_20140328.DescribeLogGroups" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON DescribeLogGroups where
toJSON DescribeLogGroups'{..}
= object
["nextToken" .= _dlgNextToken,
"logGroupNamePrefix" .= _dlgLogGroupNamePrefix,
"limit" .= _dlgLimit]
instance ToPath DescribeLogGroups where
toPath = const "/"
instance ToQuery DescribeLogGroups where
toQuery = const mempty
data DescribeLogGroupsResponse = DescribeLogGroupsResponse'
{ _dlgrsLogGroups :: !(Maybe [LogGroup])
, _dlgrsNextToken :: !(Maybe Text)
, _dlgrsStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeLogGroupsResponse
:: Int
-> DescribeLogGroupsResponse
describeLogGroupsResponse pStatus_ =
DescribeLogGroupsResponse'
{ _dlgrsLogGroups = Nothing
, _dlgrsNextToken = Nothing
, _dlgrsStatus = pStatus_
}
dlgrsLogGroups :: Lens' DescribeLogGroupsResponse [LogGroup]
dlgrsLogGroups = lens _dlgrsLogGroups (\ s a -> s{_dlgrsLogGroups = a}) . _Default . _Coerce;
dlgrsNextToken :: Lens' DescribeLogGroupsResponse (Maybe Text)
dlgrsNextToken = lens _dlgrsNextToken (\ s a -> s{_dlgrsNextToken = a});
dlgrsStatus :: Lens' DescribeLogGroupsResponse Int
dlgrsStatus = lens _dlgrsStatus (\ s a -> s{_dlgrsStatus = a});