{-# 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.TimeStreamQuery.Types.TimeSeriesDataPoint
-- 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.TimeStreamQuery.Types.TimeSeriesDataPoint 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
import {-# SOURCE #-} Amazonka.TimeStreamQuery.Types.Datum

-- | The timeseries data type represents the values of a measure over time. A
-- time series is an array of rows of timestamps and measure values, with
-- rows sorted in ascending order of time. A TimeSeriesDataPoint is a
-- single data point in the time series. It represents a tuple of (time,
-- measure value) in a time series.
--
-- /See:/ 'newTimeSeriesDataPoint' smart constructor.
data TimeSeriesDataPoint = TimeSeriesDataPoint'
  { -- | The timestamp when the measure value was collected.
    TimeSeriesDataPoint -> Text
time :: Prelude.Text,
    -- | The measure value for the data point.
    TimeSeriesDataPoint -> Datum
value :: Datum
  }
  deriving (TimeSeriesDataPoint -> TimeSeriesDataPoint -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeSeriesDataPoint -> TimeSeriesDataPoint -> Bool
$c/= :: TimeSeriesDataPoint -> TimeSeriesDataPoint -> Bool
== :: TimeSeriesDataPoint -> TimeSeriesDataPoint -> Bool
$c== :: TimeSeriesDataPoint -> TimeSeriesDataPoint -> Bool
Prelude.Eq, ReadPrec [TimeSeriesDataPoint]
ReadPrec TimeSeriesDataPoint
Int -> ReadS TimeSeriesDataPoint
ReadS [TimeSeriesDataPoint]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimeSeriesDataPoint]
$creadListPrec :: ReadPrec [TimeSeriesDataPoint]
readPrec :: ReadPrec TimeSeriesDataPoint
$creadPrec :: ReadPrec TimeSeriesDataPoint
readList :: ReadS [TimeSeriesDataPoint]
$creadList :: ReadS [TimeSeriesDataPoint]
readsPrec :: Int -> ReadS TimeSeriesDataPoint
$creadsPrec :: Int -> ReadS TimeSeriesDataPoint
Prelude.Read, Int -> TimeSeriesDataPoint -> ShowS
[TimeSeriesDataPoint] -> ShowS
TimeSeriesDataPoint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimeSeriesDataPoint] -> ShowS
$cshowList :: [TimeSeriesDataPoint] -> ShowS
show :: TimeSeriesDataPoint -> String
$cshow :: TimeSeriesDataPoint -> String
showsPrec :: Int -> TimeSeriesDataPoint -> ShowS
$cshowsPrec :: Int -> TimeSeriesDataPoint -> ShowS
Prelude.Show, forall x. Rep TimeSeriesDataPoint x -> TimeSeriesDataPoint
forall x. TimeSeriesDataPoint -> Rep TimeSeriesDataPoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimeSeriesDataPoint x -> TimeSeriesDataPoint
$cfrom :: forall x. TimeSeriesDataPoint -> Rep TimeSeriesDataPoint x
Prelude.Generic)

-- |
-- Create a value of 'TimeSeriesDataPoint' 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:
--
-- 'time', 'timeSeriesDataPoint_time' - The timestamp when the measure value was collected.
--
-- 'value', 'timeSeriesDataPoint_value' - The measure value for the data point.
newTimeSeriesDataPoint ::
  -- | 'time'
  Prelude.Text ->
  -- | 'value'
  Datum ->
  TimeSeriesDataPoint
newTimeSeriesDataPoint :: Text -> Datum -> TimeSeriesDataPoint
newTimeSeriesDataPoint Text
pTime_ Datum
pValue_ =
  TimeSeriesDataPoint'
    { $sel:time:TimeSeriesDataPoint' :: Text
time = Text
pTime_,
      $sel:value:TimeSeriesDataPoint' :: Datum
value = Datum
pValue_
    }

-- | The timestamp when the measure value was collected.
timeSeriesDataPoint_time :: Lens.Lens' TimeSeriesDataPoint Prelude.Text
timeSeriesDataPoint_time :: Lens' TimeSeriesDataPoint Text
timeSeriesDataPoint_time = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeSeriesDataPoint' {Text
time :: Text
$sel:time:TimeSeriesDataPoint' :: TimeSeriesDataPoint -> Text
time} -> Text
time) (\s :: TimeSeriesDataPoint
s@TimeSeriesDataPoint' {} Text
a -> TimeSeriesDataPoint
s {$sel:time:TimeSeriesDataPoint' :: Text
time = Text
a} :: TimeSeriesDataPoint)

-- | The measure value for the data point.
timeSeriesDataPoint_value :: Lens.Lens' TimeSeriesDataPoint Datum
timeSeriesDataPoint_value :: Lens' TimeSeriesDataPoint Datum
timeSeriesDataPoint_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimeSeriesDataPoint' {Datum
value :: Datum
$sel:value:TimeSeriesDataPoint' :: TimeSeriesDataPoint -> Datum
value} -> Datum
value) (\s :: TimeSeriesDataPoint
s@TimeSeriesDataPoint' {} Datum
a -> TimeSeriesDataPoint
s {$sel:value:TimeSeriesDataPoint' :: Datum
value = Datum
a} :: TimeSeriesDataPoint)

instance Data.FromJSON TimeSeriesDataPoint where
  parseJSON :: Value -> Parser TimeSeriesDataPoint
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TimeSeriesDataPoint"
      ( \Object
x ->
          Text -> Datum -> TimeSeriesDataPoint
TimeSeriesDataPoint'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Time")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Value")
      )

instance Prelude.Hashable TimeSeriesDataPoint where
  hashWithSalt :: Int -> TimeSeriesDataPoint -> Int
hashWithSalt Int
_salt TimeSeriesDataPoint' {Text
Datum
value :: Datum
time :: Text
$sel:value:TimeSeriesDataPoint' :: TimeSeriesDataPoint -> Datum
$sel:time:TimeSeriesDataPoint' :: TimeSeriesDataPoint -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
time
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Datum
value

instance Prelude.NFData TimeSeriesDataPoint where
  rnf :: TimeSeriesDataPoint -> ()
rnf TimeSeriesDataPoint' {Text
Datum
value :: Datum
time :: Text
$sel:value:TimeSeriesDataPoint' :: TimeSeriesDataPoint -> Datum
$sel:time:TimeSeriesDataPoint' :: TimeSeriesDataPoint -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
time seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Datum
value