{-# 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.Connect.Types.HistoricalMetric
-- 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.Connect.Types.HistoricalMetric where

import Amazonka.Connect.Types.HistoricalMetricName
import Amazonka.Connect.Types.Statistic
import Amazonka.Connect.Types.Threshold
import Amazonka.Connect.Types.Unit
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

-- | Contains information about a historical metric. For a description of
-- each metric, see
-- <https://docs.aws.amazon.com/connect/latest/adminguide/historical-metrics-definitions.html Historical Metrics Definitions>
-- in the /Amazon Connect Administrator Guide/.
--
-- /See:/ 'newHistoricalMetric' smart constructor.
data HistoricalMetric = HistoricalMetric'
  { -- | The name of the metric.
    HistoricalMetric -> Maybe HistoricalMetricName
name :: Prelude.Maybe HistoricalMetricName,
    -- | The statistic for the metric.
    HistoricalMetric -> Maybe Statistic
statistic :: Prelude.Maybe Statistic,
    -- | The threshold for the metric, used with service level metrics.
    HistoricalMetric -> Maybe Threshold
threshold :: Prelude.Maybe Threshold,
    -- | The unit for the metric.
    HistoricalMetric -> Maybe Unit
unit :: Prelude.Maybe Unit
  }
  deriving (HistoricalMetric -> HistoricalMetric -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HistoricalMetric -> HistoricalMetric -> Bool
$c/= :: HistoricalMetric -> HistoricalMetric -> Bool
== :: HistoricalMetric -> HistoricalMetric -> Bool
$c== :: HistoricalMetric -> HistoricalMetric -> Bool
Prelude.Eq, ReadPrec [HistoricalMetric]
ReadPrec HistoricalMetric
Int -> ReadS HistoricalMetric
ReadS [HistoricalMetric]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HistoricalMetric]
$creadListPrec :: ReadPrec [HistoricalMetric]
readPrec :: ReadPrec HistoricalMetric
$creadPrec :: ReadPrec HistoricalMetric
readList :: ReadS [HistoricalMetric]
$creadList :: ReadS [HistoricalMetric]
readsPrec :: Int -> ReadS HistoricalMetric
$creadsPrec :: Int -> ReadS HistoricalMetric
Prelude.Read, Int -> HistoricalMetric -> ShowS
[HistoricalMetric] -> ShowS
HistoricalMetric -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HistoricalMetric] -> ShowS
$cshowList :: [HistoricalMetric] -> ShowS
show :: HistoricalMetric -> String
$cshow :: HistoricalMetric -> String
showsPrec :: Int -> HistoricalMetric -> ShowS
$cshowsPrec :: Int -> HistoricalMetric -> ShowS
Prelude.Show, forall x. Rep HistoricalMetric x -> HistoricalMetric
forall x. HistoricalMetric -> Rep HistoricalMetric x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HistoricalMetric x -> HistoricalMetric
$cfrom :: forall x. HistoricalMetric -> Rep HistoricalMetric x
Prelude.Generic)

-- |
-- Create a value of 'HistoricalMetric' 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:
--
-- 'name', 'historicalMetric_name' - The name of the metric.
--
-- 'statistic', 'historicalMetric_statistic' - The statistic for the metric.
--
-- 'threshold', 'historicalMetric_threshold' - The threshold for the metric, used with service level metrics.
--
-- 'unit', 'historicalMetric_unit' - The unit for the metric.
newHistoricalMetric ::
  HistoricalMetric
newHistoricalMetric :: HistoricalMetric
newHistoricalMetric =
  HistoricalMetric'
    { $sel:name:HistoricalMetric' :: Maybe HistoricalMetricName
name = forall a. Maybe a
Prelude.Nothing,
      $sel:statistic:HistoricalMetric' :: Maybe Statistic
statistic = forall a. Maybe a
Prelude.Nothing,
      $sel:threshold:HistoricalMetric' :: Maybe Threshold
threshold = forall a. Maybe a
Prelude.Nothing,
      $sel:unit:HistoricalMetric' :: Maybe Unit
unit = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the metric.
historicalMetric_name :: Lens.Lens' HistoricalMetric (Prelude.Maybe HistoricalMetricName)
historicalMetric_name :: Lens' HistoricalMetric (Maybe HistoricalMetricName)
historicalMetric_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistoricalMetric' {Maybe HistoricalMetricName
name :: Maybe HistoricalMetricName
$sel:name:HistoricalMetric' :: HistoricalMetric -> Maybe HistoricalMetricName
name} -> Maybe HistoricalMetricName
name) (\s :: HistoricalMetric
s@HistoricalMetric' {} Maybe HistoricalMetricName
a -> HistoricalMetric
s {$sel:name:HistoricalMetric' :: Maybe HistoricalMetricName
name = Maybe HistoricalMetricName
a} :: HistoricalMetric)

-- | The statistic for the metric.
historicalMetric_statistic :: Lens.Lens' HistoricalMetric (Prelude.Maybe Statistic)
historicalMetric_statistic :: Lens' HistoricalMetric (Maybe Statistic)
historicalMetric_statistic = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistoricalMetric' {Maybe Statistic
statistic :: Maybe Statistic
$sel:statistic:HistoricalMetric' :: HistoricalMetric -> Maybe Statistic
statistic} -> Maybe Statistic
statistic) (\s :: HistoricalMetric
s@HistoricalMetric' {} Maybe Statistic
a -> HistoricalMetric
s {$sel:statistic:HistoricalMetric' :: Maybe Statistic
statistic = Maybe Statistic
a} :: HistoricalMetric)

-- | The threshold for the metric, used with service level metrics.
historicalMetric_threshold :: Lens.Lens' HistoricalMetric (Prelude.Maybe Threshold)
historicalMetric_threshold :: Lens' HistoricalMetric (Maybe Threshold)
historicalMetric_threshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistoricalMetric' {Maybe Threshold
threshold :: Maybe Threshold
$sel:threshold:HistoricalMetric' :: HistoricalMetric -> Maybe Threshold
threshold} -> Maybe Threshold
threshold) (\s :: HistoricalMetric
s@HistoricalMetric' {} Maybe Threshold
a -> HistoricalMetric
s {$sel:threshold:HistoricalMetric' :: Maybe Threshold
threshold = Maybe Threshold
a} :: HistoricalMetric)

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

instance Data.FromJSON HistoricalMetric where
  parseJSON :: Value -> Parser HistoricalMetric
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HistoricalMetric"
      ( \Object
x ->
          Maybe HistoricalMetricName
-> Maybe Statistic
-> Maybe Threshold
-> Maybe Unit
-> HistoricalMetric
HistoricalMetric'
            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
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Statistic")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Threshold")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Unit")
      )

instance Prelude.Hashable HistoricalMetric where
  hashWithSalt :: Int -> HistoricalMetric -> Int
hashWithSalt Int
_salt HistoricalMetric' {Maybe HistoricalMetricName
Maybe Statistic
Maybe Threshold
Maybe Unit
unit :: Maybe Unit
threshold :: Maybe Threshold
statistic :: Maybe Statistic
name :: Maybe HistoricalMetricName
$sel:unit:HistoricalMetric' :: HistoricalMetric -> Maybe Unit
$sel:threshold:HistoricalMetric' :: HistoricalMetric -> Maybe Threshold
$sel:statistic:HistoricalMetric' :: HistoricalMetric -> Maybe Statistic
$sel:name:HistoricalMetric' :: HistoricalMetric -> Maybe HistoricalMetricName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HistoricalMetricName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Statistic
statistic
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Threshold
threshold
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Unit
unit

instance Prelude.NFData HistoricalMetric where
  rnf :: HistoricalMetric -> ()
rnf HistoricalMetric' {Maybe HistoricalMetricName
Maybe Statistic
Maybe Threshold
Maybe Unit
unit :: Maybe Unit
threshold :: Maybe Threshold
statistic :: Maybe Statistic
name :: Maybe HistoricalMetricName
$sel:unit:HistoricalMetric' :: HistoricalMetric -> Maybe Unit
$sel:threshold:HistoricalMetric' :: HistoricalMetric -> Maybe Threshold
$sel:statistic:HistoricalMetric' :: HistoricalMetric -> Maybe Statistic
$sel:name:HistoricalMetric' :: HistoricalMetric -> Maybe HistoricalMetricName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe HistoricalMetricName
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Statistic
statistic
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Threshold
threshold
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Unit
unit

instance Data.ToJSON HistoricalMetric where
  toJSON :: HistoricalMetric -> Value
toJSON HistoricalMetric' {Maybe HistoricalMetricName
Maybe Statistic
Maybe Threshold
Maybe Unit
unit :: Maybe Unit
threshold :: Maybe Threshold
statistic :: Maybe Statistic
name :: Maybe HistoricalMetricName
$sel:unit:HistoricalMetric' :: HistoricalMetric -> Maybe Unit
$sel:threshold:HistoricalMetric' :: HistoricalMetric -> Maybe Threshold
$sel:statistic:HistoricalMetric' :: HistoricalMetric -> Maybe Statistic
$sel:name:HistoricalMetric' :: HistoricalMetric -> Maybe HistoricalMetricName
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe HistoricalMetricName
name,
            (Key
"Statistic" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Statistic
statistic,
            (Key
"Threshold" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Threshold
threshold,
            (Key
"Unit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Unit
unit
          ]
      )