{-# 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.ForecastQuery.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.ForecastQuery.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

-- | The forecast value for a specific date. Part of the Forecast object.
--
-- /See:/ 'newDataPoint' smart constructor.
data DataPoint = DataPoint'
  { -- | The timestamp of the specific forecast.
    DataPoint -> Maybe Text
timestamp :: Prelude.Maybe Prelude.Text,
    -- | The forecast value.
    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 timestamp of the specific forecast.
--
-- 'value', 'dataPoint_value' - The forecast value.
newDataPoint ::
  DataPoint
newDataPoint :: DataPoint
newDataPoint =
  DataPoint'
    { $sel:timestamp:DataPoint' :: Maybe Text
timestamp = forall a. Maybe a
Prelude.Nothing,
      $sel:value:DataPoint' :: Maybe Double
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The timestamp of the specific forecast.
dataPoint_timestamp :: Lens.Lens' DataPoint (Prelude.Maybe Prelude.Text)
dataPoint_timestamp :: Lens' DataPoint (Maybe Text)
dataPoint_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataPoint' {Maybe Text
timestamp :: Maybe Text
$sel:timestamp:DataPoint' :: DataPoint -> Maybe Text
timestamp} -> Maybe Text
timestamp) (\s :: DataPoint
s@DataPoint' {} Maybe Text
a -> DataPoint
s {$sel:timestamp:DataPoint' :: Maybe Text
timestamp = Maybe Text
a} :: DataPoint)

-- | The forecast value.
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 Text -> 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 Text
value :: Maybe Double
timestamp :: Maybe Text
$sel:value:DataPoint' :: DataPoint -> Maybe Double
$sel:timestamp:DataPoint' :: DataPoint -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
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 Text
value :: Maybe Double
timestamp :: Maybe Text
$sel:value:DataPoint' :: DataPoint -> Maybe Double
$sel:timestamp:DataPoint' :: DataPoint -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
timestamp
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
value