{-# 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.CloudWatch.Types.InsightRuleContributorDatapoint
-- 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.CloudWatch.Types.InsightRuleContributorDatapoint where

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

-- | One data point related to one contributor.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_GetInsightRuleReport.html GetInsightRuleReport>
-- and
-- <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_InsightRuleContributor.html InsightRuleContributor>.
--
-- /See:/ 'newInsightRuleContributorDatapoint' smart constructor.
data InsightRuleContributorDatapoint = InsightRuleContributorDatapoint'
  { -- | The timestamp of the data point.
    InsightRuleContributorDatapoint -> ISO8601
timestamp :: Core.ISO8601,
    -- | The approximate value that this contributor added during this timestamp.
    InsightRuleContributorDatapoint -> Double
approximateValue :: Prelude.Double
  }
  deriving (InsightRuleContributorDatapoint
-> InsightRuleContributorDatapoint -> Bool
(InsightRuleContributorDatapoint
 -> InsightRuleContributorDatapoint -> Bool)
-> (InsightRuleContributorDatapoint
    -> InsightRuleContributorDatapoint -> Bool)
-> Eq InsightRuleContributorDatapoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InsightRuleContributorDatapoint
-> InsightRuleContributorDatapoint -> Bool
$c/= :: InsightRuleContributorDatapoint
-> InsightRuleContributorDatapoint -> Bool
== :: InsightRuleContributorDatapoint
-> InsightRuleContributorDatapoint -> Bool
$c== :: InsightRuleContributorDatapoint
-> InsightRuleContributorDatapoint -> Bool
Prelude.Eq, ReadPrec [InsightRuleContributorDatapoint]
ReadPrec InsightRuleContributorDatapoint
Int -> ReadS InsightRuleContributorDatapoint
ReadS [InsightRuleContributorDatapoint]
(Int -> ReadS InsightRuleContributorDatapoint)
-> ReadS [InsightRuleContributorDatapoint]
-> ReadPrec InsightRuleContributorDatapoint
-> ReadPrec [InsightRuleContributorDatapoint]
-> Read InsightRuleContributorDatapoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InsightRuleContributorDatapoint]
$creadListPrec :: ReadPrec [InsightRuleContributorDatapoint]
readPrec :: ReadPrec InsightRuleContributorDatapoint
$creadPrec :: ReadPrec InsightRuleContributorDatapoint
readList :: ReadS [InsightRuleContributorDatapoint]
$creadList :: ReadS [InsightRuleContributorDatapoint]
readsPrec :: Int -> ReadS InsightRuleContributorDatapoint
$creadsPrec :: Int -> ReadS InsightRuleContributorDatapoint
Prelude.Read, Int -> InsightRuleContributorDatapoint -> ShowS
[InsightRuleContributorDatapoint] -> ShowS
InsightRuleContributorDatapoint -> String
(Int -> InsightRuleContributorDatapoint -> ShowS)
-> (InsightRuleContributorDatapoint -> String)
-> ([InsightRuleContributorDatapoint] -> ShowS)
-> Show InsightRuleContributorDatapoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InsightRuleContributorDatapoint] -> ShowS
$cshowList :: [InsightRuleContributorDatapoint] -> ShowS
show :: InsightRuleContributorDatapoint -> String
$cshow :: InsightRuleContributorDatapoint -> String
showsPrec :: Int -> InsightRuleContributorDatapoint -> ShowS
$cshowsPrec :: Int -> InsightRuleContributorDatapoint -> ShowS
Prelude.Show, (forall x.
 InsightRuleContributorDatapoint
 -> Rep InsightRuleContributorDatapoint x)
-> (forall x.
    Rep InsightRuleContributorDatapoint x
    -> InsightRuleContributorDatapoint)
-> Generic InsightRuleContributorDatapoint
forall x.
Rep InsightRuleContributorDatapoint x
-> InsightRuleContributorDatapoint
forall x.
InsightRuleContributorDatapoint
-> Rep InsightRuleContributorDatapoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InsightRuleContributorDatapoint x
-> InsightRuleContributorDatapoint
$cfrom :: forall x.
InsightRuleContributorDatapoint
-> Rep InsightRuleContributorDatapoint x
Prelude.Generic)

-- |
-- Create a value of 'InsightRuleContributorDatapoint' 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:
--
-- 'timestamp', 'insightRuleContributorDatapoint_timestamp' - The timestamp of the data point.
--
-- 'approximateValue', 'insightRuleContributorDatapoint_approximateValue' - The approximate value that this contributor added during this timestamp.
newInsightRuleContributorDatapoint ::
  -- | 'timestamp'
  Prelude.UTCTime ->
  -- | 'approximateValue'
  Prelude.Double ->
  InsightRuleContributorDatapoint
newInsightRuleContributorDatapoint :: UTCTime -> Double -> InsightRuleContributorDatapoint
newInsightRuleContributorDatapoint
  UTCTime
pTimestamp_
  Double
pApproximateValue_ =
    InsightRuleContributorDatapoint' :: ISO8601 -> Double -> InsightRuleContributorDatapoint
InsightRuleContributorDatapoint'
      { $sel:timestamp:InsightRuleContributorDatapoint' :: ISO8601
timestamp =
          Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pTimestamp_,
        $sel:approximateValue:InsightRuleContributorDatapoint' :: Double
approximateValue = Double
pApproximateValue_
      }

-- | The timestamp of the data point.
insightRuleContributorDatapoint_timestamp :: Lens.Lens' InsightRuleContributorDatapoint Prelude.UTCTime
insightRuleContributorDatapoint_timestamp :: (UTCTime -> f UTCTime)
-> InsightRuleContributorDatapoint
-> f InsightRuleContributorDatapoint
insightRuleContributorDatapoint_timestamp = (InsightRuleContributorDatapoint -> ISO8601)
-> (InsightRuleContributorDatapoint
    -> ISO8601 -> InsightRuleContributorDatapoint)
-> Lens
     InsightRuleContributorDatapoint
     InsightRuleContributorDatapoint
     ISO8601
     ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightRuleContributorDatapoint' {ISO8601
timestamp :: ISO8601
$sel:timestamp:InsightRuleContributorDatapoint' :: InsightRuleContributorDatapoint -> ISO8601
timestamp} -> ISO8601
timestamp) (\s :: InsightRuleContributorDatapoint
s@InsightRuleContributorDatapoint' {} ISO8601
a -> InsightRuleContributorDatapoint
s {$sel:timestamp:InsightRuleContributorDatapoint' :: ISO8601
timestamp = ISO8601
a} :: InsightRuleContributorDatapoint) ((ISO8601 -> f ISO8601)
 -> InsightRuleContributorDatapoint
 -> f InsightRuleContributorDatapoint)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> InsightRuleContributorDatapoint
-> f InsightRuleContributorDatapoint
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The approximate value that this contributor added during this timestamp.
insightRuleContributorDatapoint_approximateValue :: Lens.Lens' InsightRuleContributorDatapoint Prelude.Double
insightRuleContributorDatapoint_approximateValue :: (Double -> f Double)
-> InsightRuleContributorDatapoint
-> f InsightRuleContributorDatapoint
insightRuleContributorDatapoint_approximateValue = (InsightRuleContributorDatapoint -> Double)
-> (InsightRuleContributorDatapoint
    -> Double -> InsightRuleContributorDatapoint)
-> Lens
     InsightRuleContributorDatapoint
     InsightRuleContributorDatapoint
     Double
     Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightRuleContributorDatapoint' {Double
approximateValue :: Double
$sel:approximateValue:InsightRuleContributorDatapoint' :: InsightRuleContributorDatapoint -> Double
approximateValue} -> Double
approximateValue) (\s :: InsightRuleContributorDatapoint
s@InsightRuleContributorDatapoint' {} Double
a -> InsightRuleContributorDatapoint
s {$sel:approximateValue:InsightRuleContributorDatapoint' :: Double
approximateValue = Double
a} :: InsightRuleContributorDatapoint)

instance Core.FromXML InsightRuleContributorDatapoint where
  parseXML :: [Node] -> Either String InsightRuleContributorDatapoint
parseXML [Node]
x =
    ISO8601 -> Double -> InsightRuleContributorDatapoint
InsightRuleContributorDatapoint'
      (ISO8601 -> Double -> InsightRuleContributorDatapoint)
-> Either String ISO8601
-> Either String (Double -> InsightRuleContributorDatapoint)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String ISO8601
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Timestamp")
      Either String (Double -> InsightRuleContributorDatapoint)
-> Either String Double
-> Either String InsightRuleContributorDatapoint
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Double
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"ApproximateValue")

instance
  Prelude.Hashable
    InsightRuleContributorDatapoint

instance
  Prelude.NFData
    InsightRuleContributorDatapoint