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

-- | Represents a single value in the forecast data used for predictive
-- scaling.
--
-- /See:/ 'newDatapoint' smart constructor.
data Datapoint = Datapoint'
  { -- | The time stamp for the data point in UTC format.
    Datapoint -> Maybe POSIX
timestamp :: Prelude.Maybe Data.POSIX,
    -- | The value of the data point.
    Datapoint -> Maybe Double
value :: Prelude.Maybe Prelude.Double
  }
  deriving (Datapoint -> Datapoint -> Bool
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]
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
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. 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:
--
-- 'timestamp', 'datapoint_timestamp' - The time stamp for the data point in UTC format.
--
-- 'value', 'datapoint_value' - The value of the data point.
newDatapoint ::
  Datapoint
newDatapoint :: Datapoint
newDatapoint =
  Datapoint'
    { $sel:timestamp:Datapoint' :: Maybe POSIX
timestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:value:Datapoint' :: Maybe Double
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The time stamp for the data point in UTC format.
datapoint_timestamp :: Lens.Lens' Datapoint (Prelude.Maybe Prelude.UTCTime)
datapoint_timestamp :: Lens' Datapoint (Maybe UTCTime)
datapoint_timestamp = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The value of the data point.
datapoint_value :: Lens.Lens' Datapoint (Prelude.Maybe Prelude.Double)
datapoint_value :: Lens' Datapoint (Maybe Double)
datapoint_value = 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)

instance Data.FromJSON Datapoint where
  parseJSON :: Value -> Parser Datapoint
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Datapoint"
      ( \Object
x ->
          Maybe POSIX -> Maybe Double -> Datapoint
Datapoint'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Timestamp")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Value")
      )

instance Prelude.Hashable Datapoint where
  hashWithSalt :: Int -> Datapoint -> Int
hashWithSalt Int
_salt Datapoint' {Maybe Double
Maybe POSIX
value :: Maybe Double
timestamp :: Maybe POSIX
$sel:value:Datapoint' :: Datapoint -> Maybe Double
$sel:timestamp:Datapoint' :: Datapoint -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
timestamp
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
value

instance Prelude.NFData Datapoint where
  rnf :: Datapoint -> ()
rnf Datapoint' {Maybe Double
Maybe POSIX
value :: Maybe Double
timestamp :: Maybe POSIX
$sel:value:Datapoint' :: Datapoint -> Maybe Double
$sel:timestamp:Datapoint' :: Datapoint -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
timestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
value