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

-- | 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
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]
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
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. 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' {$sel:timeInMillis:TimestampValue' :: Maybe Natural
timeInMillis = 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 :: Lens' TimestampValue (Maybe Natural)
timestampValue_timeInMillis = 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 where
  hashWithSalt :: Int -> TimestampValue -> Int
hashWithSalt Int
_salt TimestampValue' {Maybe Natural
timeInMillis :: Maybe Natural
$sel:timeInMillis:TimestampValue' :: TimestampValue -> Maybe Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
timeInMillis

instance Prelude.NFData TimestampValue where
  rnf :: TimestampValue -> ()
rnf TimestampValue' {Maybe Natural
timeInMillis :: Maybe Natural
$sel:timeInMillis:TimestampValue' :: TimestampValue -> Maybe Natural
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
timeInMillis

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