{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pi.Types.ResponseResourceMetricKey where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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.
    --
    -- -   The counter metrics listed in
    --     <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_PerfInsights_Counters.html#USER_PerfInsights_Counters.OS Performance Insights operating system counters>
    --     in the /Amazon Aurora User Guide/.
    --
    -- 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
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]
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
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.
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.
--
-- -   The counter metrics listed in
--     <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_PerfInsights_Counters.html#USER_PerfInsights_Counters.OS Performance Insights operating system counters>
--     in the /Amazon Aurora User Guide/.
--
-- 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'
    { $sel:dimensions:ResponseResourceMetricKey' :: Maybe (HashMap Text Text)
dimensions =
        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 :: Lens' ResponseResourceMetricKey (Maybe (HashMap Text Text))
responseResourceMetricKey_dimensions = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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.
--
-- -   The counter metrics listed in
--     <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_PerfInsights_Counters.html#USER_PerfInsights_Counters.OS Performance Insights operating system counters>
--     in the /Amazon Aurora User Guide/.
--
-- 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 :: Lens' ResponseResourceMetricKey Text
responseResourceMetricKey_metric = 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 Data.FromJSON ResponseResourceMetricKey where
  parseJSON :: Value -> Parser ResponseResourceMetricKey
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ResponseResourceMetricKey"
      ( \Object
x ->
          Maybe (HashMap Text Text) -> Text -> ResponseResourceMetricKey
ResponseResourceMetricKey'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Dimensions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Metric")
      )

instance Prelude.Hashable ResponseResourceMetricKey where
  hashWithSalt :: Int -> ResponseResourceMetricKey -> Int
hashWithSalt Int
_salt ResponseResourceMetricKey' {Maybe (HashMap Text Text)
Text
metric :: Text
dimensions :: Maybe (HashMap Text Text)
$sel:metric:ResponseResourceMetricKey' :: ResponseResourceMetricKey -> Text
$sel:dimensions:ResponseResourceMetricKey' :: ResponseResourceMetricKey -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
dimensions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
metric

instance Prelude.NFData ResponseResourceMetricKey where
  rnf :: ResponseResourceMetricKey -> ()
rnf ResponseResourceMetricKey' {Maybe (HashMap Text Text)
Text
metric :: Text
dimensions :: Maybe (HashMap Text Text)
$sel:metric:ResponseResourceMetricKey' :: ResponseResourceMetricKey -> Text
$sel:dimensions:ResponseResourceMetricKey' :: ResponseResourceMetricKey -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
dimensions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
metric