{-# 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.CloudWatch.DescribeAlarmsForMetric
(
describeAlarmsForMetric
, DescribeAlarmsForMetric
, dafmPeriod
, dafmDimensions
, dafmUnit
, dafmStatistic
, dafmExtendedStatistic
, dafmMetricName
, dafmNamespace
, describeAlarmsForMetricResponse
, DescribeAlarmsForMetricResponse
, dafmrsMetricAlarms
, dafmrsResponseStatus
) where
import Network.AWS.CloudWatch.Types
import Network.AWS.CloudWatch.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data DescribeAlarmsForMetric = DescribeAlarmsForMetric'
{ _dafmPeriod :: !(Maybe Nat)
, _dafmDimensions :: !(Maybe [Dimension])
, _dafmUnit :: !(Maybe StandardUnit)
, _dafmStatistic :: !(Maybe Statistic)
, _dafmExtendedStatistic :: !(Maybe Text)
, _dafmMetricName :: !Text
, _dafmNamespace :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
describeAlarmsForMetric
:: Text
-> Text
-> DescribeAlarmsForMetric
describeAlarmsForMetric pMetricName_ pNamespace_ =
DescribeAlarmsForMetric'
{ _dafmPeriod = Nothing
, _dafmDimensions = Nothing
, _dafmUnit = Nothing
, _dafmStatistic = Nothing
, _dafmExtendedStatistic = Nothing
, _dafmMetricName = pMetricName_
, _dafmNamespace = pNamespace_
}
dafmPeriod :: Lens' DescribeAlarmsForMetric (Maybe Natural)
dafmPeriod = lens _dafmPeriod (\ s a -> s{_dafmPeriod = a}) . mapping _Nat
dafmDimensions :: Lens' DescribeAlarmsForMetric [Dimension]
dafmDimensions = lens _dafmDimensions (\ s a -> s{_dafmDimensions = a}) . _Default . _Coerce
dafmUnit :: Lens' DescribeAlarmsForMetric (Maybe StandardUnit)
dafmUnit = lens _dafmUnit (\ s a -> s{_dafmUnit = a})
dafmStatistic :: Lens' DescribeAlarmsForMetric (Maybe Statistic)
dafmStatistic = lens _dafmStatistic (\ s a -> s{_dafmStatistic = a})
dafmExtendedStatistic :: Lens' DescribeAlarmsForMetric (Maybe Text)
dafmExtendedStatistic = lens _dafmExtendedStatistic (\ s a -> s{_dafmExtendedStatistic = a})
dafmMetricName :: Lens' DescribeAlarmsForMetric Text
dafmMetricName = lens _dafmMetricName (\ s a -> s{_dafmMetricName = a})
dafmNamespace :: Lens' DescribeAlarmsForMetric Text
dafmNamespace = lens _dafmNamespace (\ s a -> s{_dafmNamespace = a})
instance AWSRequest DescribeAlarmsForMetric where
type Rs DescribeAlarmsForMetric =
DescribeAlarmsForMetricResponse
request = postQuery cloudWatch
response
= receiveXMLWrapper "DescribeAlarmsForMetricResult"
(\ s h x ->
DescribeAlarmsForMetricResponse' <$>
(x .@? "MetricAlarms" .!@ mempty >>=
may (parseXMLList "member"))
<*> (pure (fromEnum s)))
instance Hashable DescribeAlarmsForMetric where
instance NFData DescribeAlarmsForMetric where
instance ToHeaders DescribeAlarmsForMetric where
toHeaders = const mempty
instance ToPath DescribeAlarmsForMetric where
toPath = const "/"
instance ToQuery DescribeAlarmsForMetric where
toQuery DescribeAlarmsForMetric'{..}
= mconcat
["Action" =:
("DescribeAlarmsForMetric" :: ByteString),
"Version" =: ("2010-08-01" :: ByteString),
"Period" =: _dafmPeriod,
"Dimensions" =:
toQuery (toQueryList "member" <$> _dafmDimensions),
"Unit" =: _dafmUnit, "Statistic" =: _dafmStatistic,
"ExtendedStatistic" =: _dafmExtendedStatistic,
"MetricName" =: _dafmMetricName,
"Namespace" =: _dafmNamespace]
data DescribeAlarmsForMetricResponse = DescribeAlarmsForMetricResponse'
{ _dafmrsMetricAlarms :: !(Maybe [MetricAlarm])
, _dafmrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
describeAlarmsForMetricResponse
:: Int
-> DescribeAlarmsForMetricResponse
describeAlarmsForMetricResponse pResponseStatus_ =
DescribeAlarmsForMetricResponse'
{_dafmrsMetricAlarms = Nothing, _dafmrsResponseStatus = pResponseStatus_}
dafmrsMetricAlarms :: Lens' DescribeAlarmsForMetricResponse [MetricAlarm]
dafmrsMetricAlarms = lens _dafmrsMetricAlarms (\ s a -> s{_dafmrsMetricAlarms = a}) . _Default . _Coerce
dafmrsResponseStatus :: Lens' DescribeAlarmsForMetricResponse Int
dafmrsResponseStatus = lens _dafmrsResponseStatus (\ s a -> s{_dafmrsResponseStatus = a})
instance NFData DescribeAlarmsForMetricResponse where