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

-- | 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 :: Data.ISO8601,
    -- | The approximate value that this contributor added during this timestamp.
    InsightRuleContributorDatapoint -> Double
approximateValue :: Prelude.Double
  }
  deriving (InsightRuleContributorDatapoint
-> InsightRuleContributorDatapoint -> Bool
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]
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
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.
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'
      { $sel:timestamp:InsightRuleContributorDatapoint' :: ISO8601
timestamp =
          forall (a :: Format). Iso' (Time a) UTCTime
Data._Time 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 :: Lens' InsightRuleContributorDatapoint UTCTime
insightRuleContributorDatapoint_timestamp = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The approximate value that this contributor added during this timestamp.
insightRuleContributorDatapoint_approximateValue :: Lens.Lens' InsightRuleContributorDatapoint Prelude.Double
insightRuleContributorDatapoint_approximateValue :: Lens' InsightRuleContributorDatapoint Double
insightRuleContributorDatapoint_approximateValue = 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 Data.FromXML InsightRuleContributorDatapoint where
  parseXML :: [Node] -> Either String InsightRuleContributorDatapoint
parseXML [Node]
x =
    ISO8601 -> Double -> InsightRuleContributorDatapoint
InsightRuleContributorDatapoint'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Timestamp")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"ApproximateValue")

instance
  Prelude.Hashable
    InsightRuleContributorDatapoint
  where
  hashWithSalt :: Int -> InsightRuleContributorDatapoint -> Int
hashWithSalt
    Int
_salt
    InsightRuleContributorDatapoint' {Double
ISO8601
approximateValue :: Double
timestamp :: ISO8601
$sel:approximateValue:InsightRuleContributorDatapoint' :: InsightRuleContributorDatapoint -> Double
$sel:timestamp:InsightRuleContributorDatapoint' :: InsightRuleContributorDatapoint -> ISO8601
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ISO8601
timestamp
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
approximateValue

instance
  Prelude.NFData
    InsightRuleContributorDatapoint
  where
  rnf :: InsightRuleContributorDatapoint -> ()
rnf InsightRuleContributorDatapoint' {Double
ISO8601
approximateValue :: Double
timestamp :: ISO8601
$sel:approximateValue:InsightRuleContributorDatapoint' :: InsightRuleContributorDatapoint -> Double
$sel:timestamp:InsightRuleContributorDatapoint' :: InsightRuleContributorDatapoint -> ISO8601
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ISO8601
timestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
approximateValue