{-# 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.DescribeLogGroups
(
describeLogGroups
, DescribeLogGroups
, dlgLogGroupNamePrefix
, dlgNextToken
, dlgLimit
, describeLogGroupsResponse
, DescribeLogGroupsResponse
, dlgrsLogGroups
, dlgrsNextToken
, dlgrsResponseStatus
) 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 DescribeLogGroups = DescribeLogGroups'
{ _dlgLogGroupNamePrefix :: !(Maybe Text)
, _dlgNextToken :: !(Maybe Text)
, _dlgLimit :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
describeLogGroups
:: DescribeLogGroups
describeLogGroups =
DescribeLogGroups'
{ _dlgLogGroupNamePrefix = Nothing
, _dlgNextToken = Nothing
, _dlgLimit = Nothing
}
dlgLogGroupNamePrefix :: Lens' DescribeLogGroups (Maybe Text)
dlgLogGroupNamePrefix = lens _dlgLogGroupNamePrefix (\ s a -> s{_dlgLogGroupNamePrefix = a})
dlgNextToken :: Lens' DescribeLogGroups (Maybe Text)
dlgNextToken = lens _dlgNextToken (\ s a -> s{_dlgNextToken = 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 Rs DescribeLogGroups = DescribeLogGroupsResponse
request = postJSON cloudWatchLogs
response
= receiveJSON
(\ s h x ->
DescribeLogGroupsResponse' <$>
(x .?> "logGroups" .!@ mempty) <*>
(x .?> "nextToken")
<*> (pure (fromEnum s)))
instance Hashable DescribeLogGroups where
instance NFData DescribeLogGroups where
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
(catMaybes
[("logGroupNamePrefix" .=) <$>
_dlgLogGroupNamePrefix,
("nextToken" .=) <$> _dlgNextToken,
("limit" .=) <$> _dlgLimit])
instance ToPath DescribeLogGroups where
toPath = const "/"
instance ToQuery DescribeLogGroups where
toQuery = const mempty
data DescribeLogGroupsResponse = DescribeLogGroupsResponse'
{ _dlgrsLogGroups :: !(Maybe [LogGroup])
, _dlgrsNextToken :: !(Maybe Text)
, _dlgrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
describeLogGroupsResponse
:: Int
-> DescribeLogGroupsResponse
describeLogGroupsResponse pResponseStatus_ =
DescribeLogGroupsResponse'
{ _dlgrsLogGroups = Nothing
, _dlgrsNextToken = Nothing
, _dlgrsResponseStatus = pResponseStatus_
}
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})
dlgrsResponseStatus :: Lens' DescribeLogGroupsResponse Int
dlgrsResponseStatus = lens _dlgrsResponseStatus (\ s a -> s{_dlgrsResponseStatus = a})
instance NFData DescribeLogGroupsResponse where