{-# 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.IoTEventsData.Types.TimestampValue
-- 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.IoTEventsData.Types.TimestampValue where

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

-- | Contains information about a timestamp.
--
-- /See:/ 'newTimestampValue' smart constructor.
data TimestampValue = TimestampValue'
  { -- | The value of the timestamp, in the Unix epoch format.
    TimestampValue -> Maybe Natural
timeInMillis :: Prelude.Maybe Prelude.Natural
  }
  deriving (TimestampValue -> TimestampValue -> Bool
(TimestampValue -> TimestampValue -> Bool)
-> (TimestampValue -> TimestampValue -> Bool) -> Eq TimestampValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimestampValue -> TimestampValue -> Bool
$c/= :: TimestampValue -> TimestampValue -> Bool
== :: TimestampValue -> TimestampValue -> Bool
$c== :: TimestampValue -> TimestampValue -> Bool
Prelude.Eq, ReadPrec [TimestampValue]
ReadPrec TimestampValue
Int -> ReadS TimestampValue
ReadS [TimestampValue]
(Int -> ReadS TimestampValue)
-> ReadS [TimestampValue]
-> ReadPrec TimestampValue
-> ReadPrec [TimestampValue]
-> Read TimestampValue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TimestampValue]
$creadListPrec :: ReadPrec [TimestampValue]
readPrec :: ReadPrec TimestampValue
$creadPrec :: ReadPrec TimestampValue
readList :: ReadS [TimestampValue]
$creadList :: ReadS [TimestampValue]
readsPrec :: Int -> ReadS TimestampValue
$creadsPrec :: Int -> ReadS TimestampValue
Prelude.Read, Int -> TimestampValue -> ShowS
[TimestampValue] -> ShowS
TimestampValue -> String
(Int -> TimestampValue -> ShowS)
-> (TimestampValue -> String)
-> ([TimestampValue] -> ShowS)
-> Show TimestampValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TimestampValue] -> ShowS
$cshowList :: [TimestampValue] -> ShowS
show :: TimestampValue -> String
$cshow :: TimestampValue -> String
showsPrec :: Int -> TimestampValue -> ShowS
$cshowsPrec :: Int -> TimestampValue -> ShowS
Prelude.Show, (forall x. TimestampValue -> Rep TimestampValue x)
-> (forall x. Rep TimestampValue x -> TimestampValue)
-> Generic TimestampValue
forall x. Rep TimestampValue x -> TimestampValue
forall x. TimestampValue -> Rep TimestampValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TimestampValue x -> TimestampValue
$cfrom :: forall x. TimestampValue -> Rep TimestampValue x
Prelude.Generic)

-- |
-- Create a value of 'TimestampValue' 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:
--
-- 'timeInMillis', 'timestampValue_timeInMillis' - The value of the timestamp, in the Unix epoch format.
newTimestampValue ::
  TimestampValue
newTimestampValue :: TimestampValue
newTimestampValue =
  TimestampValue' :: Maybe Natural -> TimestampValue
TimestampValue' {$sel:timeInMillis:TimestampValue' :: Maybe Natural
timeInMillis = Maybe Natural
forall a. Maybe a
Prelude.Nothing}

-- | The value of the timestamp, in the Unix epoch format.
timestampValue_timeInMillis :: Lens.Lens' TimestampValue (Prelude.Maybe Prelude.Natural)
timestampValue_timeInMillis :: (Maybe Natural -> f (Maybe Natural))
-> TimestampValue -> f TimestampValue
timestampValue_timeInMillis = (TimestampValue -> Maybe Natural)
-> (TimestampValue -> Maybe Natural -> TimestampValue)
-> Lens
     TimestampValue TimestampValue (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TimestampValue' {Maybe Natural
timeInMillis :: Maybe Natural
$sel:timeInMillis:TimestampValue' :: TimestampValue -> Maybe Natural
timeInMillis} -> Maybe Natural
timeInMillis) (\s :: TimestampValue
s@TimestampValue' {} Maybe Natural
a -> TimestampValue
s {$sel:timeInMillis:TimestampValue' :: Maybe Natural
timeInMillis = Maybe Natural
a} :: TimestampValue)

instance Prelude.Hashable TimestampValue

instance Prelude.NFData TimestampValue

instance Core.ToJSON TimestampValue where
  toJSON :: TimestampValue -> Value
toJSON TimestampValue' {Maybe Natural
timeInMillis :: Maybe Natural
$sel:timeInMillis:TimestampValue' :: TimestampValue -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"timeInMillis" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
timeInMillis]
      )