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

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

-- |
-- Module      : Amazonka.ServiceQuotas.Types.MetricInfo
-- 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)
module Amazonka.ServiceQuotas.Types.MetricInfo where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the CloudWatch metric that reflects quota usage.
--
-- /See:/ 'newMetricInfo' smart constructor.
data MetricInfo = MetricInfo'
  { -- | The metric dimension. This is a name\/value pair that is part of the
    -- identity of a metric.
    MetricInfo -> Maybe (HashMap Text Text)
metricDimensions :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of the metric.
    MetricInfo -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | The metric statistic that we recommend you use when determining quota
    -- usage.
    MetricInfo -> Maybe Text
metricStatisticRecommendation :: Prelude.Maybe Prelude.Text,
    -- | The namespace of the metric.
    MetricInfo -> Maybe Text
metricNamespace :: Prelude.Maybe Prelude.Text
  }
  deriving (MetricInfo -> MetricInfo -> Bool
(MetricInfo -> MetricInfo -> Bool)
-> (MetricInfo -> MetricInfo -> Bool) -> Eq MetricInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricInfo -> MetricInfo -> Bool
$c/= :: MetricInfo -> MetricInfo -> Bool
== :: MetricInfo -> MetricInfo -> Bool
$c== :: MetricInfo -> MetricInfo -> Bool
Prelude.Eq, ReadPrec [MetricInfo]
ReadPrec MetricInfo
Int -> ReadS MetricInfo
ReadS [MetricInfo]
(Int -> ReadS MetricInfo)
-> ReadS [MetricInfo]
-> ReadPrec MetricInfo
-> ReadPrec [MetricInfo]
-> Read MetricInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricInfo]
$creadListPrec :: ReadPrec [MetricInfo]
readPrec :: ReadPrec MetricInfo
$creadPrec :: ReadPrec MetricInfo
readList :: ReadS [MetricInfo]
$creadList :: ReadS [MetricInfo]
readsPrec :: Int -> ReadS MetricInfo
$creadsPrec :: Int -> ReadS MetricInfo
Prelude.Read, Int -> MetricInfo -> ShowS
[MetricInfo] -> ShowS
MetricInfo -> String
(Int -> MetricInfo -> ShowS)
-> (MetricInfo -> String)
-> ([MetricInfo] -> ShowS)
-> Show MetricInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricInfo] -> ShowS
$cshowList :: [MetricInfo] -> ShowS
show :: MetricInfo -> String
$cshow :: MetricInfo -> String
showsPrec :: Int -> MetricInfo -> ShowS
$cshowsPrec :: Int -> MetricInfo -> ShowS
Prelude.Show, (forall x. MetricInfo -> Rep MetricInfo x)
-> (forall x. Rep MetricInfo x -> MetricInfo) -> Generic MetricInfo
forall x. Rep MetricInfo x -> MetricInfo
forall x. MetricInfo -> Rep MetricInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricInfo x -> MetricInfo
$cfrom :: forall x. MetricInfo -> Rep MetricInfo x
Prelude.Generic)

-- |
-- Create a value of 'MetricInfo' 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:
--
-- 'metricDimensions', 'metricInfo_metricDimensions' - The metric dimension. This is a name\/value pair that is part of the
-- identity of a metric.
--
-- 'metricName', 'metricInfo_metricName' - The name of the metric.
--
-- 'metricStatisticRecommendation', 'metricInfo_metricStatisticRecommendation' - The metric statistic that we recommend you use when determining quota
-- usage.
--
-- 'metricNamespace', 'metricInfo_metricNamespace' - The namespace of the metric.
newMetricInfo ::
  MetricInfo
newMetricInfo :: MetricInfo
newMetricInfo =
  MetricInfo' :: Maybe (HashMap Text Text)
-> Maybe Text -> Maybe Text -> Maybe Text -> MetricInfo
MetricInfo'
    { $sel:metricDimensions:MetricInfo' :: Maybe (HashMap Text Text)
metricDimensions = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:MetricInfo' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metricStatisticRecommendation:MetricInfo' :: Maybe Text
metricStatisticRecommendation = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metricNamespace:MetricInfo' :: Maybe Text
metricNamespace = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The metric dimension. This is a name\/value pair that is part of the
-- identity of a metric.
metricInfo_metricDimensions :: Lens.Lens' MetricInfo (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
metricInfo_metricDimensions :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> MetricInfo -> f MetricInfo
metricInfo_metricDimensions = (MetricInfo -> Maybe (HashMap Text Text))
-> (MetricInfo -> Maybe (HashMap Text Text) -> MetricInfo)
-> Lens
     MetricInfo
     MetricInfo
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricInfo' {Maybe (HashMap Text Text)
metricDimensions :: Maybe (HashMap Text Text)
$sel:metricDimensions:MetricInfo' :: MetricInfo -> Maybe (HashMap Text Text)
metricDimensions} -> Maybe (HashMap Text Text)
metricDimensions) (\s :: MetricInfo
s@MetricInfo' {} Maybe (HashMap Text Text)
a -> MetricInfo
s {$sel:metricDimensions:MetricInfo' :: Maybe (HashMap Text Text)
metricDimensions = Maybe (HashMap Text Text)
a} :: MetricInfo) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> MetricInfo -> f MetricInfo)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> MetricInfo
-> f MetricInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

-- | The metric statistic that we recommend you use when determining quota
-- usage.
metricInfo_metricStatisticRecommendation :: Lens.Lens' MetricInfo (Prelude.Maybe Prelude.Text)
metricInfo_metricStatisticRecommendation :: (Maybe Text -> f (Maybe Text)) -> MetricInfo -> f MetricInfo
metricInfo_metricStatisticRecommendation = (MetricInfo -> Maybe Text)
-> (MetricInfo -> Maybe Text -> MetricInfo)
-> Lens MetricInfo MetricInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricInfo' {Maybe Text
metricStatisticRecommendation :: Maybe Text
$sel:metricStatisticRecommendation:MetricInfo' :: MetricInfo -> Maybe Text
metricStatisticRecommendation} -> Maybe Text
metricStatisticRecommendation) (\s :: MetricInfo
s@MetricInfo' {} Maybe Text
a -> MetricInfo
s {$sel:metricStatisticRecommendation:MetricInfo' :: Maybe Text
metricStatisticRecommendation = Maybe Text
a} :: MetricInfo)

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

instance Core.FromJSON MetricInfo where
  parseJSON :: Value -> Parser MetricInfo
parseJSON =
    String
-> (Object -> Parser MetricInfo) -> Value -> Parser MetricInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricInfo"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe Text -> Maybe Text -> Maybe Text -> MetricInfo
MetricInfo'
            (Maybe (HashMap Text Text)
 -> Maybe Text -> Maybe Text -> Maybe Text -> MetricInfo)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> MetricInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MetricDimensions"
                            Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> MetricInfo)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> MetricInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MetricName")
            Parser (Maybe Text -> Maybe Text -> MetricInfo)
-> Parser (Maybe Text) -> Parser (Maybe Text -> MetricInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MetricStatisticRecommendation")
            Parser (Maybe Text -> MetricInfo)
-> Parser (Maybe Text) -> Parser MetricInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MetricNamespace")
      )

instance Prelude.Hashable MetricInfo

instance Prelude.NFData MetricInfo