module Network.AWS.CloudWatch.DescribeAlarms
(
describeAlarms
, DescribeAlarms
, daAlarmNamePrefix
, daActionPrefix
, daNextToken
, daStateValue
, daAlarmNames
, daMaxRecords
, describeAlarmsResponse
, DescribeAlarmsResponse
, darsMetricAlarms
, darsNextToken
, darsResponseStatus
) where
import Network.AWS.CloudWatch.Types
import Network.AWS.CloudWatch.Types.Product
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data DescribeAlarms = DescribeAlarms'
{ _daAlarmNamePrefix :: !(Maybe Text)
, _daActionPrefix :: !(Maybe Text)
, _daNextToken :: !(Maybe Text)
, _daStateValue :: !(Maybe StateValue)
, _daAlarmNames :: !(Maybe [Text])
, _daMaxRecords :: !(Maybe Nat)
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeAlarms
:: DescribeAlarms
describeAlarms =
DescribeAlarms'
{ _daAlarmNamePrefix = Nothing
, _daActionPrefix = Nothing
, _daNextToken = Nothing
, _daStateValue = Nothing
, _daAlarmNames = Nothing
, _daMaxRecords = Nothing
}
daAlarmNamePrefix :: Lens' DescribeAlarms (Maybe Text)
daAlarmNamePrefix = lens _daAlarmNamePrefix (\ s a -> s{_daAlarmNamePrefix = a});
daActionPrefix :: Lens' DescribeAlarms (Maybe Text)
daActionPrefix = lens _daActionPrefix (\ s a -> s{_daActionPrefix = a});
daNextToken :: Lens' DescribeAlarms (Maybe Text)
daNextToken = lens _daNextToken (\ s a -> s{_daNextToken = a});
daStateValue :: Lens' DescribeAlarms (Maybe StateValue)
daStateValue = lens _daStateValue (\ s a -> s{_daStateValue = a});
daAlarmNames :: Lens' DescribeAlarms [Text]
daAlarmNames = lens _daAlarmNames (\ s a -> s{_daAlarmNames = a}) . _Default . _Coerce;
daMaxRecords :: Lens' DescribeAlarms (Maybe Natural)
daMaxRecords = lens _daMaxRecords (\ s a -> s{_daMaxRecords = a}) . mapping _Nat;
instance AWSPager DescribeAlarms where
page rq rs
| stop (rs ^. darsNextToken) = Nothing
| stop (rs ^. darsMetricAlarms) = Nothing
| otherwise =
Just $ rq & daNextToken .~ rs ^. darsNextToken
instance AWSRequest DescribeAlarms where
type Rs DescribeAlarms = DescribeAlarmsResponse
request = postQuery cloudWatch
response
= receiveXMLWrapper "DescribeAlarmsResult"
(\ s h x ->
DescribeAlarmsResponse' <$>
(x .@? "MetricAlarms" .!@ mempty >>=
may (parseXMLList "member"))
<*> (x .@? "NextToken")
<*> (pure (fromEnum s)))
instance ToHeaders DescribeAlarms where
toHeaders = const mempty
instance ToPath DescribeAlarms where
toPath = const "/"
instance ToQuery DescribeAlarms where
toQuery DescribeAlarms'{..}
= mconcat
["Action" =: ("DescribeAlarms" :: ByteString),
"Version" =: ("2010-08-01" :: ByteString),
"AlarmNamePrefix" =: _daAlarmNamePrefix,
"ActionPrefix" =: _daActionPrefix,
"NextToken" =: _daNextToken,
"StateValue" =: _daStateValue,
"AlarmNames" =:
toQuery (toQueryList "member" <$> _daAlarmNames),
"MaxRecords" =: _daMaxRecords]
data DescribeAlarmsResponse = DescribeAlarmsResponse'
{ _darsMetricAlarms :: !(Maybe [MetricAlarm])
, _darsNextToken :: !(Maybe Text)
, _darsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
describeAlarmsResponse
:: Int
-> DescribeAlarmsResponse
describeAlarmsResponse pResponseStatus_ =
DescribeAlarmsResponse'
{ _darsMetricAlarms = Nothing
, _darsNextToken = Nothing
, _darsResponseStatus = pResponseStatus_
}
darsMetricAlarms :: Lens' DescribeAlarmsResponse [MetricAlarm]
darsMetricAlarms = lens _darsMetricAlarms (\ s a -> s{_darsMetricAlarms = a}) . _Default . _Coerce;
darsNextToken :: Lens' DescribeAlarmsResponse (Maybe Text)
darsNextToken = lens _darsNextToken (\ s a -> s{_darsNextToken = a});
darsResponseStatus :: Lens' DescribeAlarmsResponse Int
darsResponseStatus = lens _darsResponseStatus (\ s a -> s{_darsResponseStatus = a});