{-# 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.AutoScalingPlans.Types.Datapoint
-- 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.AutoScalingPlans.Types.Datapoint where

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

-- | Represents a single value in the forecast data used for predictive
-- scaling.
--
-- /See:/ 'newDatapoint' smart constructor.
data Datapoint = Datapoint'
  { -- | The value of the data point.
    Datapoint -> Maybe Double
value :: Prelude.Maybe Prelude.Double,
    -- | The time stamp for the data point in UTC format.
    Datapoint -> Maybe POSIX
timestamp :: Prelude.Maybe Core.POSIX
  }
  deriving (Datapoint -> Datapoint -> Bool
(Datapoint -> Datapoint -> Bool)
-> (Datapoint -> Datapoint -> Bool) -> Eq Datapoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Datapoint -> Datapoint -> Bool
$c/= :: Datapoint -> Datapoint -> Bool
== :: Datapoint -> Datapoint -> Bool
$c== :: Datapoint -> Datapoint -> Bool
Prelude.Eq, ReadPrec [Datapoint]
ReadPrec Datapoint
Int -> ReadS Datapoint
ReadS [Datapoint]
(Int -> ReadS Datapoint)
-> ReadS [Datapoint]
-> ReadPrec Datapoint
-> ReadPrec [Datapoint]
-> Read Datapoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Datapoint]
$creadListPrec :: ReadPrec [Datapoint]
readPrec :: ReadPrec Datapoint
$creadPrec :: ReadPrec Datapoint
readList :: ReadS [Datapoint]
$creadList :: ReadS [Datapoint]
readsPrec :: Int -> ReadS Datapoint
$creadsPrec :: Int -> ReadS Datapoint
Prelude.Read, Int -> Datapoint -> ShowS
[Datapoint] -> ShowS
Datapoint -> String
(Int -> Datapoint -> ShowS)
-> (Datapoint -> String)
-> ([Datapoint] -> ShowS)
-> Show Datapoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Datapoint] -> ShowS
$cshowList :: [Datapoint] -> ShowS
show :: Datapoint -> String
$cshow :: Datapoint -> String
showsPrec :: Int -> Datapoint -> ShowS
$cshowsPrec :: Int -> Datapoint -> ShowS
Prelude.Show, (forall x. Datapoint -> Rep Datapoint x)
-> (forall x. Rep Datapoint x -> Datapoint) -> Generic Datapoint
forall x. Rep Datapoint x -> Datapoint
forall x. Datapoint -> Rep Datapoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Datapoint x -> Datapoint
$cfrom :: forall x. Datapoint -> Rep Datapoint x
Prelude.Generic)

-- |
-- Create a value of 'Datapoint' 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', 'datapoint_value' - The value of the data point.
--
-- 'timestamp', 'datapoint_timestamp' - The time stamp for the data point in UTC format.
newDatapoint ::
  Datapoint
newDatapoint :: Datapoint
newDatapoint =
  Datapoint' :: Maybe Double -> Maybe POSIX -> Datapoint
Datapoint'
    { $sel:value:Datapoint' :: Maybe Double
value = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:Datapoint' :: Maybe POSIX
timestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

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

-- | The time stamp for the data point in UTC format.
datapoint_timestamp :: Lens.Lens' Datapoint (Prelude.Maybe Prelude.UTCTime)
datapoint_timestamp :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Datapoint -> f Datapoint
datapoint_timestamp = (Datapoint -> Maybe POSIX)
-> (Datapoint -> Maybe POSIX -> Datapoint)
-> Lens Datapoint Datapoint (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Datapoint' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:Datapoint' :: Datapoint -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: Datapoint
s@Datapoint' {} Maybe POSIX
a -> Datapoint
s {$sel:timestamp:Datapoint' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: Datapoint) ((Maybe POSIX -> f (Maybe POSIX)) -> Datapoint -> f Datapoint)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Datapoint
-> f Datapoint
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON Datapoint where
  parseJSON :: Value -> Parser Datapoint
parseJSON =
    String -> (Object -> Parser Datapoint) -> Value -> Parser Datapoint
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Datapoint"
      ( \Object
x ->
          Maybe Double -> Maybe POSIX -> Datapoint
Datapoint'
            (Maybe Double -> Maybe POSIX -> Datapoint)
-> Parser (Maybe Double) -> Parser (Maybe POSIX -> Datapoint)
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 POSIX -> Datapoint)
-> Parser (Maybe POSIX) -> Parser Datapoint
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Timestamp")
      )

instance Prelude.Hashable Datapoint

instance Prelude.NFData Datapoint