{-# 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.Pi.Types.ResponseResourceMetricKey
-- 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.Pi.Types.ResponseResourceMetricKey where

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

-- | An object describing a Performance Insights metric and one or more
-- dimensions for that metric.
--
-- /See:/ 'newResponseResourceMetricKey' smart constructor.
data ResponseResourceMetricKey = ResponseResourceMetricKey'
  { -- | The valid dimensions for the metric.
    ResponseResourceMetricKey -> Maybe (HashMap Text Text)
dimensions :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name of a Performance Insights metric to be measured.
    --
    -- Valid values for @Metric@ are:
    --
    -- -   @db.load.avg@ - a scaled representation of the number of active
    --     sessions for the database engine.
    --
    -- -   @db.sampledload.avg@ - the raw number of active sessions for the
    --     database engine.
    --
    -- If the number of active sessions is less than an internal Performance
    -- Insights threshold, @db.load.avg@ and @db.sampledload.avg@ are the same
    -- value. If the number of active sessions is greater than the internal
    -- threshold, Performance Insights samples the active sessions, with
    -- @db.load.avg@ showing the scaled values, @db.sampledload.avg@ showing
    -- the raw values, and @db.sampledload.avg@ less than @db.load.avg@. For
    -- most use cases, you can query @db.load.avg@ only.
    ResponseResourceMetricKey -> Text
metric :: Prelude.Text
  }
  deriving (ResponseResourceMetricKey -> ResponseResourceMetricKey -> Bool
(ResponseResourceMetricKey -> ResponseResourceMetricKey -> Bool)
-> (ResponseResourceMetricKey -> ResponseResourceMetricKey -> Bool)
-> Eq ResponseResourceMetricKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResponseResourceMetricKey -> ResponseResourceMetricKey -> Bool
$c/= :: ResponseResourceMetricKey -> ResponseResourceMetricKey -> Bool
== :: ResponseResourceMetricKey -> ResponseResourceMetricKey -> Bool
$c== :: ResponseResourceMetricKey -> ResponseResourceMetricKey -> Bool
Prelude.Eq, ReadPrec [ResponseResourceMetricKey]
ReadPrec ResponseResourceMetricKey
Int -> ReadS ResponseResourceMetricKey
ReadS [ResponseResourceMetricKey]
(Int -> ReadS ResponseResourceMetricKey)
-> ReadS [ResponseResourceMetricKey]
-> ReadPrec ResponseResourceMetricKey
-> ReadPrec [ResponseResourceMetricKey]
-> Read ResponseResourceMetricKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResponseResourceMetricKey]
$creadListPrec :: ReadPrec [ResponseResourceMetricKey]
readPrec :: ReadPrec ResponseResourceMetricKey
$creadPrec :: ReadPrec ResponseResourceMetricKey
readList :: ReadS [ResponseResourceMetricKey]
$creadList :: ReadS [ResponseResourceMetricKey]
readsPrec :: Int -> ReadS ResponseResourceMetricKey
$creadsPrec :: Int -> ReadS ResponseResourceMetricKey
Prelude.Read, Int -> ResponseResourceMetricKey -> ShowS
[ResponseResourceMetricKey] -> ShowS
ResponseResourceMetricKey -> String
(Int -> ResponseResourceMetricKey -> ShowS)
-> (ResponseResourceMetricKey -> String)
-> ([ResponseResourceMetricKey] -> ShowS)
-> Show ResponseResourceMetricKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResponseResourceMetricKey] -> ShowS
$cshowList :: [ResponseResourceMetricKey] -> ShowS
show :: ResponseResourceMetricKey -> String
$cshow :: ResponseResourceMetricKey -> String
showsPrec :: Int -> ResponseResourceMetricKey -> ShowS
$cshowsPrec :: Int -> ResponseResourceMetricKey -> ShowS
Prelude.Show, (forall x.
 ResponseResourceMetricKey -> Rep ResponseResourceMetricKey x)
-> (forall x.
    Rep ResponseResourceMetricKey x -> ResponseResourceMetricKey)
-> Generic ResponseResourceMetricKey
forall x.
Rep ResponseResourceMetricKey x -> ResponseResourceMetricKey
forall x.
ResponseResourceMetricKey -> Rep ResponseResourceMetricKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResponseResourceMetricKey x -> ResponseResourceMetricKey
$cfrom :: forall x.
ResponseResourceMetricKey -> Rep ResponseResourceMetricKey x
Prelude.Generic)

-- |
-- Create a value of 'ResponseResourceMetricKey' 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:
--
-- 'dimensions', 'responseResourceMetricKey_dimensions' - The valid dimensions for the metric.
--
-- 'metric', 'responseResourceMetricKey_metric' - The name of a Performance Insights metric to be measured.
--
-- Valid values for @Metric@ are:
--
-- -   @db.load.avg@ - a scaled representation of the number of active
--     sessions for the database engine.
--
-- -   @db.sampledload.avg@ - the raw number of active sessions for the
--     database engine.
--
-- If the number of active sessions is less than an internal Performance
-- Insights threshold, @db.load.avg@ and @db.sampledload.avg@ are the same
-- value. If the number of active sessions is greater than the internal
-- threshold, Performance Insights samples the active sessions, with
-- @db.load.avg@ showing the scaled values, @db.sampledload.avg@ showing
-- the raw values, and @db.sampledload.avg@ less than @db.load.avg@. For
-- most use cases, you can query @db.load.avg@ only.
newResponseResourceMetricKey ::
  -- | 'metric'
  Prelude.Text ->
  ResponseResourceMetricKey
newResponseResourceMetricKey :: Text -> ResponseResourceMetricKey
newResponseResourceMetricKey Text
pMetric_ =
  ResponseResourceMetricKey' :: Maybe (HashMap Text Text) -> Text -> ResponseResourceMetricKey
ResponseResourceMetricKey'
    { $sel:dimensions:ResponseResourceMetricKey' :: Maybe (HashMap Text Text)
dimensions =
        Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:metric:ResponseResourceMetricKey' :: Text
metric = Text
pMetric_
    }

-- | The valid dimensions for the metric.
responseResourceMetricKey_dimensions :: Lens.Lens' ResponseResourceMetricKey (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
responseResourceMetricKey_dimensions :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ResponseResourceMetricKey -> f ResponseResourceMetricKey
responseResourceMetricKey_dimensions = (ResponseResourceMetricKey -> Maybe (HashMap Text Text))
-> (ResponseResourceMetricKey
    -> Maybe (HashMap Text Text) -> ResponseResourceMetricKey)
-> Lens
     ResponseResourceMetricKey
     ResponseResourceMetricKey
     (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 (\ResponseResourceMetricKey' {Maybe (HashMap Text Text)
dimensions :: Maybe (HashMap Text Text)
$sel:dimensions:ResponseResourceMetricKey' :: ResponseResourceMetricKey -> Maybe (HashMap Text Text)
dimensions} -> Maybe (HashMap Text Text)
dimensions) (\s :: ResponseResourceMetricKey
s@ResponseResourceMetricKey' {} Maybe (HashMap Text Text)
a -> ResponseResourceMetricKey
s {$sel:dimensions:ResponseResourceMetricKey' :: Maybe (HashMap Text Text)
dimensions = Maybe (HashMap Text Text)
a} :: ResponseResourceMetricKey) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ResponseResourceMetricKey -> f ResponseResourceMetricKey)
-> ((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)))
-> ResponseResourceMetricKey
-> f ResponseResourceMetricKey
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 a Performance Insights metric to be measured.
--
-- Valid values for @Metric@ are:
--
-- -   @db.load.avg@ - a scaled representation of the number of active
--     sessions for the database engine.
--
-- -   @db.sampledload.avg@ - the raw number of active sessions for the
--     database engine.
--
-- If the number of active sessions is less than an internal Performance
-- Insights threshold, @db.load.avg@ and @db.sampledload.avg@ are the same
-- value. If the number of active sessions is greater than the internal
-- threshold, Performance Insights samples the active sessions, with
-- @db.load.avg@ showing the scaled values, @db.sampledload.avg@ showing
-- the raw values, and @db.sampledload.avg@ less than @db.load.avg@. For
-- most use cases, you can query @db.load.avg@ only.
responseResourceMetricKey_metric :: Lens.Lens' ResponseResourceMetricKey Prelude.Text
responseResourceMetricKey_metric :: (Text -> f Text)
-> ResponseResourceMetricKey -> f ResponseResourceMetricKey
responseResourceMetricKey_metric = (ResponseResourceMetricKey -> Text)
-> (ResponseResourceMetricKey -> Text -> ResponseResourceMetricKey)
-> Lens
     ResponseResourceMetricKey ResponseResourceMetricKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResponseResourceMetricKey' {Text
metric :: Text
$sel:metric:ResponseResourceMetricKey' :: ResponseResourceMetricKey -> Text
metric} -> Text
metric) (\s :: ResponseResourceMetricKey
s@ResponseResourceMetricKey' {} Text
a -> ResponseResourceMetricKey
s {$sel:metric:ResponseResourceMetricKey' :: Text
metric = Text
a} :: ResponseResourceMetricKey)

instance Core.FromJSON ResponseResourceMetricKey where
  parseJSON :: Value -> Parser ResponseResourceMetricKey
parseJSON =
    String
-> (Object -> Parser ResponseResourceMetricKey)
-> Value
-> Parser ResponseResourceMetricKey
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResponseResourceMetricKey"
      ( \Object
x ->
          Maybe (HashMap Text Text) -> Text -> ResponseResourceMetricKey
ResponseResourceMetricKey'
            (Maybe (HashMap Text Text) -> Text -> ResponseResourceMetricKey)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Text -> ResponseResourceMetricKey)
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
"Dimensions" 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 (Text -> ResponseResourceMetricKey)
-> Parser Text -> Parser ResponseResourceMetricKey
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Metric")
      )

instance Prelude.Hashable ResponseResourceMetricKey

instance Prelude.NFData ResponseResourceMetricKey