{-# 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.HistoricalMetricData
-- 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.HistoricalMetricData where

import Amazonka.Connect.Types.HistoricalMetric
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the data for a historical metric.
--
-- /See:/ 'newHistoricalMetricData' smart constructor.
data HistoricalMetricData = HistoricalMetricData'
  { -- | The value of the metric.
    HistoricalMetricData -> Maybe Double
value :: Prelude.Maybe Prelude.Double,
    -- | Information about the metric.
    HistoricalMetricData -> Maybe HistoricalMetric
metric :: Prelude.Maybe HistoricalMetric
  }
  deriving (HistoricalMetricData -> HistoricalMetricData -> Bool
(HistoricalMetricData -> HistoricalMetricData -> Bool)
-> (HistoricalMetricData -> HistoricalMetricData -> Bool)
-> Eq HistoricalMetricData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HistoricalMetricData -> HistoricalMetricData -> Bool
$c/= :: HistoricalMetricData -> HistoricalMetricData -> Bool
== :: HistoricalMetricData -> HistoricalMetricData -> Bool
$c== :: HistoricalMetricData -> HistoricalMetricData -> Bool
Prelude.Eq, ReadPrec [HistoricalMetricData]
ReadPrec HistoricalMetricData
Int -> ReadS HistoricalMetricData
ReadS [HistoricalMetricData]
(Int -> ReadS HistoricalMetricData)
-> ReadS [HistoricalMetricData]
-> ReadPrec HistoricalMetricData
-> ReadPrec [HistoricalMetricData]
-> Read HistoricalMetricData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HistoricalMetricData]
$creadListPrec :: ReadPrec [HistoricalMetricData]
readPrec :: ReadPrec HistoricalMetricData
$creadPrec :: ReadPrec HistoricalMetricData
readList :: ReadS [HistoricalMetricData]
$creadList :: ReadS [HistoricalMetricData]
readsPrec :: Int -> ReadS HistoricalMetricData
$creadsPrec :: Int -> ReadS HistoricalMetricData
Prelude.Read, Int -> HistoricalMetricData -> ShowS
[HistoricalMetricData] -> ShowS
HistoricalMetricData -> String
(Int -> HistoricalMetricData -> ShowS)
-> (HistoricalMetricData -> String)
-> ([HistoricalMetricData] -> ShowS)
-> Show HistoricalMetricData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HistoricalMetricData] -> ShowS
$cshowList :: [HistoricalMetricData] -> ShowS
show :: HistoricalMetricData -> String
$cshow :: HistoricalMetricData -> String
showsPrec :: Int -> HistoricalMetricData -> ShowS
$cshowsPrec :: Int -> HistoricalMetricData -> ShowS
Prelude.Show, (forall x. HistoricalMetricData -> Rep HistoricalMetricData x)
-> (forall x. Rep HistoricalMetricData x -> HistoricalMetricData)
-> Generic HistoricalMetricData
forall x. Rep HistoricalMetricData x -> HistoricalMetricData
forall x. HistoricalMetricData -> Rep HistoricalMetricData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HistoricalMetricData x -> HistoricalMetricData
$cfrom :: forall x. HistoricalMetricData -> Rep HistoricalMetricData x
Prelude.Generic)

-- |
-- Create a value of 'HistoricalMetricData' 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:
--
-- 'value', 'historicalMetricData_value' - The value of the metric.
--
-- 'metric', 'historicalMetricData_metric' - Information about the metric.
newHistoricalMetricData ::
  HistoricalMetricData
newHistoricalMetricData :: HistoricalMetricData
newHistoricalMetricData =
  HistoricalMetricData' :: Maybe Double -> Maybe HistoricalMetric -> HistoricalMetricData
HistoricalMetricData'
    { $sel:value:HistoricalMetricData' :: Maybe Double
value = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:metric:HistoricalMetricData' :: Maybe HistoricalMetric
metric = Maybe HistoricalMetric
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the metric.
historicalMetricData_value :: Lens.Lens' HistoricalMetricData (Prelude.Maybe Prelude.Double)
historicalMetricData_value :: (Maybe Double -> f (Maybe Double))
-> HistoricalMetricData -> f HistoricalMetricData
historicalMetricData_value = (HistoricalMetricData -> Maybe Double)
-> (HistoricalMetricData -> Maybe Double -> HistoricalMetricData)
-> Lens
     HistoricalMetricData
     HistoricalMetricData
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistoricalMetricData' {Maybe Double
value :: Maybe Double
$sel:value:HistoricalMetricData' :: HistoricalMetricData -> Maybe Double
value} -> Maybe Double
value) (\s :: HistoricalMetricData
s@HistoricalMetricData' {} Maybe Double
a -> HistoricalMetricData
s {$sel:value:HistoricalMetricData' :: Maybe Double
value = Maybe Double
a} :: HistoricalMetricData)

-- | Information about the metric.
historicalMetricData_metric :: Lens.Lens' HistoricalMetricData (Prelude.Maybe HistoricalMetric)
historicalMetricData_metric :: (Maybe HistoricalMetric -> f (Maybe HistoricalMetric))
-> HistoricalMetricData -> f HistoricalMetricData
historicalMetricData_metric = (HistoricalMetricData -> Maybe HistoricalMetric)
-> (HistoricalMetricData
    -> Maybe HistoricalMetric -> HistoricalMetricData)
-> Lens
     HistoricalMetricData
     HistoricalMetricData
     (Maybe HistoricalMetric)
     (Maybe HistoricalMetric)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HistoricalMetricData' {Maybe HistoricalMetric
metric :: Maybe HistoricalMetric
$sel:metric:HistoricalMetricData' :: HistoricalMetricData -> Maybe HistoricalMetric
metric} -> Maybe HistoricalMetric
metric) (\s :: HistoricalMetricData
s@HistoricalMetricData' {} Maybe HistoricalMetric
a -> HistoricalMetricData
s {$sel:metric:HistoricalMetricData' :: Maybe HistoricalMetric
metric = Maybe HistoricalMetric
a} :: HistoricalMetricData)

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

instance Prelude.Hashable HistoricalMetricData

instance Prelude.NFData HistoricalMetricData