{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CloudWatch.DescribeAlarmsForMetric
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the alarms for the specified metric. To filter the results,
-- specify a statistic, period, or unit.
--
-- This operation retrieves only standard alarms that are based on the
-- specified metric. It does not return alarms based on math expressions
-- that use the specified metric, or composite alarms that use the
-- specified metric.
module Amazonka.CloudWatch.DescribeAlarmsForMetric
  ( -- * Creating a Request
    DescribeAlarmsForMetric (..),
    newDescribeAlarmsForMetric,

    -- * Request Lenses
    describeAlarmsForMetric_period,
    describeAlarmsForMetric_dimensions,
    describeAlarmsForMetric_unit,
    describeAlarmsForMetric_statistic,
    describeAlarmsForMetric_extendedStatistic,
    describeAlarmsForMetric_metricName,
    describeAlarmsForMetric_namespace,

    -- * Destructuring the Response
    DescribeAlarmsForMetricResponse (..),
    newDescribeAlarmsForMetricResponse,

    -- * Response Lenses
    describeAlarmsForMetricResponse_metricAlarms,
    describeAlarmsForMetricResponse_httpStatus,
  )
where

import Amazonka.CloudWatch.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeAlarmsForMetric' smart constructor.
data DescribeAlarmsForMetric = DescribeAlarmsForMetric'
  { -- | The period, in seconds, over which the statistic is applied.
    DescribeAlarmsForMetric -> Maybe Natural
period :: Prelude.Maybe Prelude.Natural,
    -- | The dimensions associated with the metric. If the metric has any
    -- associated dimensions, you must specify them in order for the call to
    -- succeed.
    DescribeAlarmsForMetric -> Maybe [Dimension]
dimensions :: Prelude.Maybe [Dimension],
    -- | The unit for the metric.
    DescribeAlarmsForMetric -> Maybe StandardUnit
unit :: Prelude.Maybe StandardUnit,
    -- | The statistic for the metric, other than percentiles. For percentile
    -- statistics, use @ExtendedStatistics@.
    DescribeAlarmsForMetric -> Maybe Statistic
statistic :: Prelude.Maybe Statistic,
    -- | The percentile statistic for the metric. Specify a value between p0.0
    -- and p100.
    DescribeAlarmsForMetric -> Maybe Text
extendedStatistic :: Prelude.Maybe Prelude.Text,
    -- | The name of the metric.
    DescribeAlarmsForMetric -> Text
metricName :: Prelude.Text,
    -- | The namespace of the metric.
    DescribeAlarmsForMetric -> Text
namespace :: Prelude.Text
  }
  deriving (DescribeAlarmsForMetric -> DescribeAlarmsForMetric -> Bool
(DescribeAlarmsForMetric -> DescribeAlarmsForMetric -> Bool)
-> (DescribeAlarmsForMetric -> DescribeAlarmsForMetric -> Bool)
-> Eq DescribeAlarmsForMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAlarmsForMetric -> DescribeAlarmsForMetric -> Bool
$c/= :: DescribeAlarmsForMetric -> DescribeAlarmsForMetric -> Bool
== :: DescribeAlarmsForMetric -> DescribeAlarmsForMetric -> Bool
$c== :: DescribeAlarmsForMetric -> DescribeAlarmsForMetric -> Bool
Prelude.Eq, ReadPrec [DescribeAlarmsForMetric]
ReadPrec DescribeAlarmsForMetric
Int -> ReadS DescribeAlarmsForMetric
ReadS [DescribeAlarmsForMetric]
(Int -> ReadS DescribeAlarmsForMetric)
-> ReadS [DescribeAlarmsForMetric]
-> ReadPrec DescribeAlarmsForMetric
-> ReadPrec [DescribeAlarmsForMetric]
-> Read DescribeAlarmsForMetric
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAlarmsForMetric]
$creadListPrec :: ReadPrec [DescribeAlarmsForMetric]
readPrec :: ReadPrec DescribeAlarmsForMetric
$creadPrec :: ReadPrec DescribeAlarmsForMetric
readList :: ReadS [DescribeAlarmsForMetric]
$creadList :: ReadS [DescribeAlarmsForMetric]
readsPrec :: Int -> ReadS DescribeAlarmsForMetric
$creadsPrec :: Int -> ReadS DescribeAlarmsForMetric
Prelude.Read, Int -> DescribeAlarmsForMetric -> ShowS
[DescribeAlarmsForMetric] -> ShowS
DescribeAlarmsForMetric -> String
(Int -> DescribeAlarmsForMetric -> ShowS)
-> (DescribeAlarmsForMetric -> String)
-> ([DescribeAlarmsForMetric] -> ShowS)
-> Show DescribeAlarmsForMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAlarmsForMetric] -> ShowS
$cshowList :: [DescribeAlarmsForMetric] -> ShowS
show :: DescribeAlarmsForMetric -> String
$cshow :: DescribeAlarmsForMetric -> String
showsPrec :: Int -> DescribeAlarmsForMetric -> ShowS
$cshowsPrec :: Int -> DescribeAlarmsForMetric -> ShowS
Prelude.Show, (forall x.
 DescribeAlarmsForMetric -> Rep DescribeAlarmsForMetric x)
-> (forall x.
    Rep DescribeAlarmsForMetric x -> DescribeAlarmsForMetric)
-> Generic DescribeAlarmsForMetric
forall x. Rep DescribeAlarmsForMetric x -> DescribeAlarmsForMetric
forall x. DescribeAlarmsForMetric -> Rep DescribeAlarmsForMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAlarmsForMetric x -> DescribeAlarmsForMetric
$cfrom :: forall x. DescribeAlarmsForMetric -> Rep DescribeAlarmsForMetric x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAlarmsForMetric' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'period', 'describeAlarmsForMetric_period' - The period, in seconds, over which the statistic is applied.
--
-- 'dimensions', 'describeAlarmsForMetric_dimensions' - The dimensions associated with the metric. If the metric has any
-- associated dimensions, you must specify them in order for the call to
-- succeed.
--
-- 'unit', 'describeAlarmsForMetric_unit' - The unit for the metric.
--
-- 'statistic', 'describeAlarmsForMetric_statistic' - The statistic for the metric, other than percentiles. For percentile
-- statistics, use @ExtendedStatistics@.
--
-- 'extendedStatistic', 'describeAlarmsForMetric_extendedStatistic' - The percentile statistic for the metric. Specify a value between p0.0
-- and p100.
--
-- 'metricName', 'describeAlarmsForMetric_metricName' - The name of the metric.
--
-- 'namespace', 'describeAlarmsForMetric_namespace' - The namespace of the metric.
newDescribeAlarmsForMetric ::
  -- | 'metricName'
  Prelude.Text ->
  -- | 'namespace'
  Prelude.Text ->
  DescribeAlarmsForMetric
newDescribeAlarmsForMetric :: Text -> Text -> DescribeAlarmsForMetric
newDescribeAlarmsForMetric Text
pMetricName_ Text
pNamespace_ =
  DescribeAlarmsForMetric' :: Maybe Natural
-> Maybe [Dimension]
-> Maybe StandardUnit
-> Maybe Statistic
-> Maybe Text
-> Text
-> Text
-> DescribeAlarmsForMetric
DescribeAlarmsForMetric'
    { $sel:period:DescribeAlarmsForMetric' :: Maybe Natural
period = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:dimensions:DescribeAlarmsForMetric' :: Maybe [Dimension]
dimensions = Maybe [Dimension]
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:DescribeAlarmsForMetric' :: Maybe StandardUnit
unit = Maybe StandardUnit
forall a. Maybe a
Prelude.Nothing,
      $sel:statistic:DescribeAlarmsForMetric' :: Maybe Statistic
statistic = Maybe Statistic
forall a. Maybe a
Prelude.Nothing,
      $sel:extendedStatistic:DescribeAlarmsForMetric' :: Maybe Text
extendedStatistic = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:DescribeAlarmsForMetric' :: Text
metricName = Text
pMetricName_,
      $sel:namespace:DescribeAlarmsForMetric' :: Text
namespace = Text
pNamespace_
    }

-- | The period, in seconds, over which the statistic is applied.
describeAlarmsForMetric_period :: Lens.Lens' DescribeAlarmsForMetric (Prelude.Maybe Prelude.Natural)
describeAlarmsForMetric_period :: (Maybe Natural -> f (Maybe Natural))
-> DescribeAlarmsForMetric -> f DescribeAlarmsForMetric
describeAlarmsForMetric_period = (DescribeAlarmsForMetric -> Maybe Natural)
-> (DescribeAlarmsForMetric
    -> Maybe Natural -> DescribeAlarmsForMetric)
-> Lens
     DescribeAlarmsForMetric
     DescribeAlarmsForMetric
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmsForMetric' {Maybe Natural
period :: Maybe Natural
$sel:period:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Maybe Natural
period} -> Maybe Natural
period) (\s :: DescribeAlarmsForMetric
s@DescribeAlarmsForMetric' {} Maybe Natural
a -> DescribeAlarmsForMetric
s {$sel:period:DescribeAlarmsForMetric' :: Maybe Natural
period = Maybe Natural
a} :: DescribeAlarmsForMetric)

-- | The dimensions associated with the metric. If the metric has any
-- associated dimensions, you must specify them in order for the call to
-- succeed.
describeAlarmsForMetric_dimensions :: Lens.Lens' DescribeAlarmsForMetric (Prelude.Maybe [Dimension])
describeAlarmsForMetric_dimensions :: (Maybe [Dimension] -> f (Maybe [Dimension]))
-> DescribeAlarmsForMetric -> f DescribeAlarmsForMetric
describeAlarmsForMetric_dimensions = (DescribeAlarmsForMetric -> Maybe [Dimension])
-> (DescribeAlarmsForMetric
    -> Maybe [Dimension] -> DescribeAlarmsForMetric)
-> Lens
     DescribeAlarmsForMetric
     DescribeAlarmsForMetric
     (Maybe [Dimension])
     (Maybe [Dimension])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmsForMetric' {Maybe [Dimension]
dimensions :: Maybe [Dimension]
$sel:dimensions:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Maybe [Dimension]
dimensions} -> Maybe [Dimension]
dimensions) (\s :: DescribeAlarmsForMetric
s@DescribeAlarmsForMetric' {} Maybe [Dimension]
a -> DescribeAlarmsForMetric
s {$sel:dimensions:DescribeAlarmsForMetric' :: Maybe [Dimension]
dimensions = Maybe [Dimension]
a} :: DescribeAlarmsForMetric) ((Maybe [Dimension] -> f (Maybe [Dimension]))
 -> DescribeAlarmsForMetric -> f DescribeAlarmsForMetric)
-> ((Maybe [Dimension] -> f (Maybe [Dimension]))
    -> Maybe [Dimension] -> f (Maybe [Dimension]))
-> (Maybe [Dimension] -> f (Maybe [Dimension]))
-> DescribeAlarmsForMetric
-> f DescribeAlarmsForMetric
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Dimension] [Dimension] [Dimension] [Dimension]
-> Iso
     (Maybe [Dimension])
     (Maybe [Dimension])
     (Maybe [Dimension])
     (Maybe [Dimension])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Dimension] [Dimension] [Dimension] [Dimension]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unit for the metric.
describeAlarmsForMetric_unit :: Lens.Lens' DescribeAlarmsForMetric (Prelude.Maybe StandardUnit)
describeAlarmsForMetric_unit :: (Maybe StandardUnit -> f (Maybe StandardUnit))
-> DescribeAlarmsForMetric -> f DescribeAlarmsForMetric
describeAlarmsForMetric_unit = (DescribeAlarmsForMetric -> Maybe StandardUnit)
-> (DescribeAlarmsForMetric
    -> Maybe StandardUnit -> DescribeAlarmsForMetric)
-> Lens
     DescribeAlarmsForMetric
     DescribeAlarmsForMetric
     (Maybe StandardUnit)
     (Maybe StandardUnit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmsForMetric' {Maybe StandardUnit
unit :: Maybe StandardUnit
$sel:unit:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Maybe StandardUnit
unit} -> Maybe StandardUnit
unit) (\s :: DescribeAlarmsForMetric
s@DescribeAlarmsForMetric' {} Maybe StandardUnit
a -> DescribeAlarmsForMetric
s {$sel:unit:DescribeAlarmsForMetric' :: Maybe StandardUnit
unit = Maybe StandardUnit
a} :: DescribeAlarmsForMetric)

-- | The statistic for the metric, other than percentiles. For percentile
-- statistics, use @ExtendedStatistics@.
describeAlarmsForMetric_statistic :: Lens.Lens' DescribeAlarmsForMetric (Prelude.Maybe Statistic)
describeAlarmsForMetric_statistic :: (Maybe Statistic -> f (Maybe Statistic))
-> DescribeAlarmsForMetric -> f DescribeAlarmsForMetric
describeAlarmsForMetric_statistic = (DescribeAlarmsForMetric -> Maybe Statistic)
-> (DescribeAlarmsForMetric
    -> Maybe Statistic -> DescribeAlarmsForMetric)
-> Lens
     DescribeAlarmsForMetric
     DescribeAlarmsForMetric
     (Maybe Statistic)
     (Maybe Statistic)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmsForMetric' {Maybe Statistic
statistic :: Maybe Statistic
$sel:statistic:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Maybe Statistic
statistic} -> Maybe Statistic
statistic) (\s :: DescribeAlarmsForMetric
s@DescribeAlarmsForMetric' {} Maybe Statistic
a -> DescribeAlarmsForMetric
s {$sel:statistic:DescribeAlarmsForMetric' :: Maybe Statistic
statistic = Maybe Statistic
a} :: DescribeAlarmsForMetric)

-- | The percentile statistic for the metric. Specify a value between p0.0
-- and p100.
describeAlarmsForMetric_extendedStatistic :: Lens.Lens' DescribeAlarmsForMetric (Prelude.Maybe Prelude.Text)
describeAlarmsForMetric_extendedStatistic :: (Maybe Text -> f (Maybe Text))
-> DescribeAlarmsForMetric -> f DescribeAlarmsForMetric
describeAlarmsForMetric_extendedStatistic = (DescribeAlarmsForMetric -> Maybe Text)
-> (DescribeAlarmsForMetric
    -> Maybe Text -> DescribeAlarmsForMetric)
-> Lens
     DescribeAlarmsForMetric
     DescribeAlarmsForMetric
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmsForMetric' {Maybe Text
extendedStatistic :: Maybe Text
$sel:extendedStatistic:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Maybe Text
extendedStatistic} -> Maybe Text
extendedStatistic) (\s :: DescribeAlarmsForMetric
s@DescribeAlarmsForMetric' {} Maybe Text
a -> DescribeAlarmsForMetric
s {$sel:extendedStatistic:DescribeAlarmsForMetric' :: Maybe Text
extendedStatistic = Maybe Text
a} :: DescribeAlarmsForMetric)

-- | The name of the metric.
describeAlarmsForMetric_metricName :: Lens.Lens' DescribeAlarmsForMetric Prelude.Text
describeAlarmsForMetric_metricName :: (Text -> f Text)
-> DescribeAlarmsForMetric -> f DescribeAlarmsForMetric
describeAlarmsForMetric_metricName = (DescribeAlarmsForMetric -> Text)
-> (DescribeAlarmsForMetric -> Text -> DescribeAlarmsForMetric)
-> Lens DescribeAlarmsForMetric DescribeAlarmsForMetric Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmsForMetric' {Text
metricName :: Text
$sel:metricName:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Text
metricName} -> Text
metricName) (\s :: DescribeAlarmsForMetric
s@DescribeAlarmsForMetric' {} Text
a -> DescribeAlarmsForMetric
s {$sel:metricName:DescribeAlarmsForMetric' :: Text
metricName = Text
a} :: DescribeAlarmsForMetric)

-- | The namespace of the metric.
describeAlarmsForMetric_namespace :: Lens.Lens' DescribeAlarmsForMetric Prelude.Text
describeAlarmsForMetric_namespace :: (Text -> f Text)
-> DescribeAlarmsForMetric -> f DescribeAlarmsForMetric
describeAlarmsForMetric_namespace = (DescribeAlarmsForMetric -> Text)
-> (DescribeAlarmsForMetric -> Text -> DescribeAlarmsForMetric)
-> Lens DescribeAlarmsForMetric DescribeAlarmsForMetric Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmsForMetric' {Text
namespace :: Text
$sel:namespace:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Text
namespace} -> Text
namespace) (\s :: DescribeAlarmsForMetric
s@DescribeAlarmsForMetric' {} Text
a -> DescribeAlarmsForMetric
s {$sel:namespace:DescribeAlarmsForMetric' :: Text
namespace = Text
a} :: DescribeAlarmsForMetric)

instance Core.AWSRequest DescribeAlarmsForMetric where
  type
    AWSResponse DescribeAlarmsForMetric =
      DescribeAlarmsForMetricResponse
  request :: DescribeAlarmsForMetric -> Request DescribeAlarmsForMetric
request = Service
-> DescribeAlarmsForMetric -> Request DescribeAlarmsForMetric
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeAlarmsForMetric
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeAlarmsForMetric)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeAlarmsForMetric))
-> Logger
-> Service
-> Proxy DescribeAlarmsForMetric
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeAlarmsForMetric)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DescribeAlarmsForMetricResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [MetricAlarm] -> Int -> DescribeAlarmsForMetricResponse
DescribeAlarmsForMetricResponse'
            (Maybe [MetricAlarm] -> Int -> DescribeAlarmsForMetricResponse)
-> Either String (Maybe [MetricAlarm])
-> Either String (Int -> DescribeAlarmsForMetricResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MetricAlarms" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [MetricAlarm]))
-> Either String (Maybe [MetricAlarm])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [MetricAlarm])
-> [Node] -> Either String (Maybe [MetricAlarm])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [MetricAlarm]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> DescribeAlarmsForMetricResponse)
-> Either String Int
-> Either String DescribeAlarmsForMetricResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeAlarmsForMetric

instance Prelude.NFData DescribeAlarmsForMetric

instance Core.ToHeaders DescribeAlarmsForMetric where
  toHeaders :: DescribeAlarmsForMetric -> ResponseHeaders
toHeaders = ResponseHeaders -> DescribeAlarmsForMetric -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DescribeAlarmsForMetric where
  toPath :: DescribeAlarmsForMetric -> ByteString
toPath = ByteString -> DescribeAlarmsForMetric -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DescribeAlarmsForMetric where
  toQuery :: DescribeAlarmsForMetric -> QueryString
toQuery DescribeAlarmsForMetric' {Maybe Natural
Maybe [Dimension]
Maybe Text
Maybe StandardUnit
Maybe Statistic
Text
namespace :: Text
metricName :: Text
extendedStatistic :: Maybe Text
statistic :: Maybe Statistic
unit :: Maybe StandardUnit
dimensions :: Maybe [Dimension]
period :: Maybe Natural
$sel:namespace:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Text
$sel:metricName:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Text
$sel:extendedStatistic:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Maybe Text
$sel:statistic:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Maybe Statistic
$sel:unit:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Maybe StandardUnit
$sel:dimensions:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Maybe [Dimension]
$sel:period:DescribeAlarmsForMetric' :: DescribeAlarmsForMetric -> Maybe Natural
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DescribeAlarmsForMetric" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-08-01" :: Prelude.ByteString),
        ByteString
"Period" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
period,
        ByteString
"Dimensions"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Dimension] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Dimension] -> QueryString)
-> Maybe [Dimension] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Dimension]
dimensions),
        ByteString
"Unit" ByteString -> Maybe StandardUnit -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe StandardUnit
unit,
        ByteString
"Statistic" ByteString -> Maybe Statistic -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Statistic
statistic,
        ByteString
"ExtendedStatistic" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
extendedStatistic,
        ByteString
"MetricName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
metricName,
        ByteString
"Namespace" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
namespace
      ]

-- | /See:/ 'newDescribeAlarmsForMetricResponse' smart constructor.
data DescribeAlarmsForMetricResponse = DescribeAlarmsForMetricResponse'
  { -- | The information for each alarm with the specified metric.
    DescribeAlarmsForMetricResponse -> Maybe [MetricAlarm]
metricAlarms :: Prelude.Maybe [MetricAlarm],
    -- | The response's http status code.
    DescribeAlarmsForMetricResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAlarmsForMetricResponse
-> DescribeAlarmsForMetricResponse -> Bool
(DescribeAlarmsForMetricResponse
 -> DescribeAlarmsForMetricResponse -> Bool)
-> (DescribeAlarmsForMetricResponse
    -> DescribeAlarmsForMetricResponse -> Bool)
-> Eq DescribeAlarmsForMetricResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAlarmsForMetricResponse
-> DescribeAlarmsForMetricResponse -> Bool
$c/= :: DescribeAlarmsForMetricResponse
-> DescribeAlarmsForMetricResponse -> Bool
== :: DescribeAlarmsForMetricResponse
-> DescribeAlarmsForMetricResponse -> Bool
$c== :: DescribeAlarmsForMetricResponse
-> DescribeAlarmsForMetricResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAlarmsForMetricResponse]
ReadPrec DescribeAlarmsForMetricResponse
Int -> ReadS DescribeAlarmsForMetricResponse
ReadS [DescribeAlarmsForMetricResponse]
(Int -> ReadS DescribeAlarmsForMetricResponse)
-> ReadS [DescribeAlarmsForMetricResponse]
-> ReadPrec DescribeAlarmsForMetricResponse
-> ReadPrec [DescribeAlarmsForMetricResponse]
-> Read DescribeAlarmsForMetricResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAlarmsForMetricResponse]
$creadListPrec :: ReadPrec [DescribeAlarmsForMetricResponse]
readPrec :: ReadPrec DescribeAlarmsForMetricResponse
$creadPrec :: ReadPrec DescribeAlarmsForMetricResponse
readList :: ReadS [DescribeAlarmsForMetricResponse]
$creadList :: ReadS [DescribeAlarmsForMetricResponse]
readsPrec :: Int -> ReadS DescribeAlarmsForMetricResponse
$creadsPrec :: Int -> ReadS DescribeAlarmsForMetricResponse
Prelude.Read, Int -> DescribeAlarmsForMetricResponse -> ShowS
[DescribeAlarmsForMetricResponse] -> ShowS
DescribeAlarmsForMetricResponse -> String
(Int -> DescribeAlarmsForMetricResponse -> ShowS)
-> (DescribeAlarmsForMetricResponse -> String)
-> ([DescribeAlarmsForMetricResponse] -> ShowS)
-> Show DescribeAlarmsForMetricResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAlarmsForMetricResponse] -> ShowS
$cshowList :: [DescribeAlarmsForMetricResponse] -> ShowS
show :: DescribeAlarmsForMetricResponse -> String
$cshow :: DescribeAlarmsForMetricResponse -> String
showsPrec :: Int -> DescribeAlarmsForMetricResponse -> ShowS
$cshowsPrec :: Int -> DescribeAlarmsForMetricResponse -> ShowS
Prelude.Show, (forall x.
 DescribeAlarmsForMetricResponse
 -> Rep DescribeAlarmsForMetricResponse x)
-> (forall x.
    Rep DescribeAlarmsForMetricResponse x
    -> DescribeAlarmsForMetricResponse)
-> Generic DescribeAlarmsForMetricResponse
forall x.
Rep DescribeAlarmsForMetricResponse x
-> DescribeAlarmsForMetricResponse
forall x.
DescribeAlarmsForMetricResponse
-> Rep DescribeAlarmsForMetricResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAlarmsForMetricResponse x
-> DescribeAlarmsForMetricResponse
$cfrom :: forall x.
DescribeAlarmsForMetricResponse
-> Rep DescribeAlarmsForMetricResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAlarmsForMetricResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'metricAlarms', 'describeAlarmsForMetricResponse_metricAlarms' - The information for each alarm with the specified metric.
--
-- 'httpStatus', 'describeAlarmsForMetricResponse_httpStatus' - The response's http status code.
newDescribeAlarmsForMetricResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAlarmsForMetricResponse
newDescribeAlarmsForMetricResponse :: Int -> DescribeAlarmsForMetricResponse
newDescribeAlarmsForMetricResponse Int
pHttpStatus_ =
  DescribeAlarmsForMetricResponse' :: Maybe [MetricAlarm] -> Int -> DescribeAlarmsForMetricResponse
DescribeAlarmsForMetricResponse'
    { $sel:metricAlarms:DescribeAlarmsForMetricResponse' :: Maybe [MetricAlarm]
metricAlarms =
        Maybe [MetricAlarm]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAlarmsForMetricResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The information for each alarm with the specified metric.
describeAlarmsForMetricResponse_metricAlarms :: Lens.Lens' DescribeAlarmsForMetricResponse (Prelude.Maybe [MetricAlarm])
describeAlarmsForMetricResponse_metricAlarms :: (Maybe [MetricAlarm] -> f (Maybe [MetricAlarm]))
-> DescribeAlarmsForMetricResponse
-> f DescribeAlarmsForMetricResponse
describeAlarmsForMetricResponse_metricAlarms = (DescribeAlarmsForMetricResponse -> Maybe [MetricAlarm])
-> (DescribeAlarmsForMetricResponse
    -> Maybe [MetricAlarm] -> DescribeAlarmsForMetricResponse)
-> Lens
     DescribeAlarmsForMetricResponse
     DescribeAlarmsForMetricResponse
     (Maybe [MetricAlarm])
     (Maybe [MetricAlarm])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmsForMetricResponse' {Maybe [MetricAlarm]
metricAlarms :: Maybe [MetricAlarm]
$sel:metricAlarms:DescribeAlarmsForMetricResponse' :: DescribeAlarmsForMetricResponse -> Maybe [MetricAlarm]
metricAlarms} -> Maybe [MetricAlarm]
metricAlarms) (\s :: DescribeAlarmsForMetricResponse
s@DescribeAlarmsForMetricResponse' {} Maybe [MetricAlarm]
a -> DescribeAlarmsForMetricResponse
s {$sel:metricAlarms:DescribeAlarmsForMetricResponse' :: Maybe [MetricAlarm]
metricAlarms = Maybe [MetricAlarm]
a} :: DescribeAlarmsForMetricResponse) ((Maybe [MetricAlarm] -> f (Maybe [MetricAlarm]))
 -> DescribeAlarmsForMetricResponse
 -> f DescribeAlarmsForMetricResponse)
-> ((Maybe [MetricAlarm] -> f (Maybe [MetricAlarm]))
    -> Maybe [MetricAlarm] -> f (Maybe [MetricAlarm]))
-> (Maybe [MetricAlarm] -> f (Maybe [MetricAlarm]))
-> DescribeAlarmsForMetricResponse
-> f DescribeAlarmsForMetricResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [MetricAlarm] [MetricAlarm] [MetricAlarm] [MetricAlarm]
-> Iso
     (Maybe [MetricAlarm])
     (Maybe [MetricAlarm])
     (Maybe [MetricAlarm])
     (Maybe [MetricAlarm])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [MetricAlarm] [MetricAlarm] [MetricAlarm] [MetricAlarm]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
describeAlarmsForMetricResponse_httpStatus :: Lens.Lens' DescribeAlarmsForMetricResponse Prelude.Int
describeAlarmsForMetricResponse_httpStatus :: (Int -> f Int)
-> DescribeAlarmsForMetricResponse
-> f DescribeAlarmsForMetricResponse
describeAlarmsForMetricResponse_httpStatus = (DescribeAlarmsForMetricResponse -> Int)
-> (DescribeAlarmsForMetricResponse
    -> Int -> DescribeAlarmsForMetricResponse)
-> Lens
     DescribeAlarmsForMetricResponse
     DescribeAlarmsForMetricResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlarmsForMetricResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeAlarmsForMetricResponse' :: DescribeAlarmsForMetricResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeAlarmsForMetricResponse
s@DescribeAlarmsForMetricResponse' {} Int
a -> DescribeAlarmsForMetricResponse
s {$sel:httpStatus:DescribeAlarmsForMetricResponse' :: Int
httpStatus = Int
a} :: DescribeAlarmsForMetricResponse)

instance
  Prelude.NFData
    DescribeAlarmsForMetricResponse