{-# 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-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.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.Lens as Lens
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 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,
    -- | The statistic for the metric.
    HistoricalMetric -> Maybe Statistic
statistic :: Prelude.Maybe Statistic
  }
  deriving (HistoricalMetric -> HistoricalMetric -> Bool
(HistoricalMetric -> HistoricalMetric -> Bool)
-> (HistoricalMetric -> HistoricalMetric -> Bool)
-> Eq HistoricalMetric
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]
(Int -> ReadS HistoricalMetric)
-> ReadS [HistoricalMetric]
-> ReadPrec HistoricalMetric
-> ReadPrec [HistoricalMetric]
-> Read 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
(Int -> HistoricalMetric -> ShowS)
-> (HistoricalMetric -> String)
-> ([HistoricalMetric] -> ShowS)
-> Show HistoricalMetric
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. HistoricalMetric -> Rep HistoricalMetric x)
-> (forall x. Rep HistoricalMetric x -> HistoricalMetric)
-> Generic HistoricalMetric
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.
--
-- 'threshold', 'historicalMetric_threshold' - The threshold for the metric, used with service level metrics.
--
-- 'unit', 'historicalMetric_unit' - The unit for the metric.
--
-- 'statistic', 'historicalMetric_statistic' - The statistic for the metric.
newHistoricalMetric ::
  HistoricalMetric
newHistoricalMetric :: HistoricalMetric
newHistoricalMetric =
  HistoricalMetric' :: Maybe HistoricalMetricName
-> Maybe Threshold
-> Maybe Unit
-> Maybe Statistic
-> HistoricalMetric
HistoricalMetric'
    { $sel:name:HistoricalMetric' :: Maybe HistoricalMetricName
name = Maybe HistoricalMetricName
forall a. Maybe a
Prelude.Nothing,
      $sel:threshold:HistoricalMetric' :: Maybe Threshold
threshold = Maybe Threshold
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:HistoricalMetric' :: Maybe Unit
unit = Maybe Unit
forall a. Maybe a
Prelude.Nothing,
      $sel:statistic:HistoricalMetric' :: Maybe Statistic
statistic = Maybe Statistic
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the metric.
historicalMetric_name :: Lens.Lens' HistoricalMetric (Prelude.Maybe HistoricalMetricName)
historicalMetric_name :: (Maybe HistoricalMetricName -> f (Maybe HistoricalMetricName))
-> HistoricalMetric -> f HistoricalMetric
historicalMetric_name = (HistoricalMetric -> Maybe HistoricalMetricName)
-> (HistoricalMetric
    -> Maybe HistoricalMetricName -> HistoricalMetric)
-> Lens
     HistoricalMetric
     HistoricalMetric
     (Maybe HistoricalMetricName)
     (Maybe HistoricalMetricName)
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 threshold for the metric, used with service level metrics.
historicalMetric_threshold :: Lens.Lens' HistoricalMetric (Prelude.Maybe Threshold)
historicalMetric_threshold :: (Maybe Threshold -> f (Maybe Threshold))
-> HistoricalMetric -> f HistoricalMetric
historicalMetric_threshold = (HistoricalMetric -> Maybe Threshold)
-> (HistoricalMetric -> Maybe Threshold -> HistoricalMetric)
-> Lens
     HistoricalMetric
     HistoricalMetric
     (Maybe Threshold)
     (Maybe 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 :: (Maybe Unit -> f (Maybe Unit))
-> HistoricalMetric -> f HistoricalMetric
historicalMetric_unit = (HistoricalMetric -> Maybe Unit)
-> (HistoricalMetric -> Maybe Unit -> HistoricalMetric)
-> Lens HistoricalMetric HistoricalMetric (Maybe Unit) (Maybe 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)

-- | The statistic for the metric.
historicalMetric_statistic :: Lens.Lens' HistoricalMetric (Prelude.Maybe Statistic)
historicalMetric_statistic :: (Maybe Statistic -> f (Maybe Statistic))
-> HistoricalMetric -> f HistoricalMetric
historicalMetric_statistic = (HistoricalMetric -> Maybe Statistic)
-> (HistoricalMetric -> Maybe Statistic -> HistoricalMetric)
-> Lens
     HistoricalMetric
     HistoricalMetric
     (Maybe Statistic)
     (Maybe 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)

instance Core.FromJSON HistoricalMetric where
  parseJSON :: Value -> Parser HistoricalMetric
parseJSON =
    String
-> (Object -> Parser HistoricalMetric)
-> Value
-> Parser HistoricalMetric
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HistoricalMetric"
      ( \Object
x ->
          Maybe HistoricalMetricName
-> Maybe Threshold
-> Maybe Unit
-> Maybe Statistic
-> HistoricalMetric
HistoricalMetric'
            (Maybe HistoricalMetricName
 -> Maybe Threshold
 -> Maybe Unit
 -> Maybe Statistic
 -> HistoricalMetric)
-> Parser (Maybe HistoricalMetricName)
-> Parser
     (Maybe Threshold
      -> Maybe Unit -> Maybe Statistic -> HistoricalMetric)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe HistoricalMetricName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
            Parser
  (Maybe Threshold
   -> Maybe Unit -> Maybe Statistic -> HistoricalMetric)
-> Parser (Maybe Threshold)
-> Parser (Maybe Unit -> Maybe Statistic -> HistoricalMetric)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Threshold)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Threshold")
            Parser (Maybe Unit -> Maybe Statistic -> HistoricalMetric)
-> Parser (Maybe Unit)
-> Parser (Maybe Statistic -> HistoricalMetric)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Unit)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Unit")
            Parser (Maybe Statistic -> HistoricalMetric)
-> Parser (Maybe Statistic) -> Parser HistoricalMetric
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Statistic)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Statistic")
      )

instance Prelude.Hashable HistoricalMetric

instance Prelude.NFData HistoricalMetric

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