{-# 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.IoT.Types.AssetPropertyTimestamp
-- 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.IoT.Types.AssetPropertyTimestamp 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

-- | An asset property timestamp entry containing the following information.
--
-- /See:/ 'newAssetPropertyTimestamp' smart constructor.
data AssetPropertyTimestamp = AssetPropertyTimestamp'
  { -- | Optional. A string that contains the nanosecond time offset. Accepts
    -- substitution templates.
    AssetPropertyTimestamp -> Maybe Text
offsetInNanos :: Prelude.Maybe Prelude.Text,
    -- | A string that contains the time in seconds since epoch. Accepts
    -- substitution templates.
    AssetPropertyTimestamp -> Text
timeInSeconds :: Prelude.Text
  }
  deriving (AssetPropertyTimestamp -> AssetPropertyTimestamp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssetPropertyTimestamp -> AssetPropertyTimestamp -> Bool
$c/= :: AssetPropertyTimestamp -> AssetPropertyTimestamp -> Bool
== :: AssetPropertyTimestamp -> AssetPropertyTimestamp -> Bool
$c== :: AssetPropertyTimestamp -> AssetPropertyTimestamp -> Bool
Prelude.Eq, ReadPrec [AssetPropertyTimestamp]
ReadPrec AssetPropertyTimestamp
Int -> ReadS AssetPropertyTimestamp
ReadS [AssetPropertyTimestamp]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssetPropertyTimestamp]
$creadListPrec :: ReadPrec [AssetPropertyTimestamp]
readPrec :: ReadPrec AssetPropertyTimestamp
$creadPrec :: ReadPrec AssetPropertyTimestamp
readList :: ReadS [AssetPropertyTimestamp]
$creadList :: ReadS [AssetPropertyTimestamp]
readsPrec :: Int -> ReadS AssetPropertyTimestamp
$creadsPrec :: Int -> ReadS AssetPropertyTimestamp
Prelude.Read, Int -> AssetPropertyTimestamp -> ShowS
[AssetPropertyTimestamp] -> ShowS
AssetPropertyTimestamp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssetPropertyTimestamp] -> ShowS
$cshowList :: [AssetPropertyTimestamp] -> ShowS
show :: AssetPropertyTimestamp -> String
$cshow :: AssetPropertyTimestamp -> String
showsPrec :: Int -> AssetPropertyTimestamp -> ShowS
$cshowsPrec :: Int -> AssetPropertyTimestamp -> ShowS
Prelude.Show, forall x. Rep AssetPropertyTimestamp x -> AssetPropertyTimestamp
forall x. AssetPropertyTimestamp -> Rep AssetPropertyTimestamp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssetPropertyTimestamp x -> AssetPropertyTimestamp
$cfrom :: forall x. AssetPropertyTimestamp -> Rep AssetPropertyTimestamp x
Prelude.Generic)

-- |
-- Create a value of 'AssetPropertyTimestamp' 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:
--
-- 'offsetInNanos', 'assetPropertyTimestamp_offsetInNanos' - Optional. A string that contains the nanosecond time offset. Accepts
-- substitution templates.
--
-- 'timeInSeconds', 'assetPropertyTimestamp_timeInSeconds' - A string that contains the time in seconds since epoch. Accepts
-- substitution templates.
newAssetPropertyTimestamp ::
  -- | 'timeInSeconds'
  Prelude.Text ->
  AssetPropertyTimestamp
newAssetPropertyTimestamp :: Text -> AssetPropertyTimestamp
newAssetPropertyTimestamp Text
pTimeInSeconds_ =
  AssetPropertyTimestamp'
    { $sel:offsetInNanos:AssetPropertyTimestamp' :: Maybe Text
offsetInNanos =
        forall a. Maybe a
Prelude.Nothing,
      $sel:timeInSeconds:AssetPropertyTimestamp' :: Text
timeInSeconds = Text
pTimeInSeconds_
    }

-- | Optional. A string that contains the nanosecond time offset. Accepts
-- substitution templates.
assetPropertyTimestamp_offsetInNanos :: Lens.Lens' AssetPropertyTimestamp (Prelude.Maybe Prelude.Text)
assetPropertyTimestamp_offsetInNanos :: Lens' AssetPropertyTimestamp (Maybe Text)
assetPropertyTimestamp_offsetInNanos = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetPropertyTimestamp' {Maybe Text
offsetInNanos :: Maybe Text
$sel:offsetInNanos:AssetPropertyTimestamp' :: AssetPropertyTimestamp -> Maybe Text
offsetInNanos} -> Maybe Text
offsetInNanos) (\s :: AssetPropertyTimestamp
s@AssetPropertyTimestamp' {} Maybe Text
a -> AssetPropertyTimestamp
s {$sel:offsetInNanos:AssetPropertyTimestamp' :: Maybe Text
offsetInNanos = Maybe Text
a} :: AssetPropertyTimestamp)

-- | A string that contains the time in seconds since epoch. Accepts
-- substitution templates.
assetPropertyTimestamp_timeInSeconds :: Lens.Lens' AssetPropertyTimestamp Prelude.Text
assetPropertyTimestamp_timeInSeconds :: Lens' AssetPropertyTimestamp Text
assetPropertyTimestamp_timeInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssetPropertyTimestamp' {Text
timeInSeconds :: Text
$sel:timeInSeconds:AssetPropertyTimestamp' :: AssetPropertyTimestamp -> Text
timeInSeconds} -> Text
timeInSeconds) (\s :: AssetPropertyTimestamp
s@AssetPropertyTimestamp' {} Text
a -> AssetPropertyTimestamp
s {$sel:timeInSeconds:AssetPropertyTimestamp' :: Text
timeInSeconds = Text
a} :: AssetPropertyTimestamp)

instance Data.FromJSON AssetPropertyTimestamp where
  parseJSON :: Value -> Parser AssetPropertyTimestamp
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AssetPropertyTimestamp"
      ( \Object
x ->
          Maybe Text -> Text -> AssetPropertyTimestamp
AssetPropertyTimestamp'
            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
"offsetInNanos")
            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
"timeInSeconds")
      )

instance Prelude.Hashable AssetPropertyTimestamp where
  hashWithSalt :: Int -> AssetPropertyTimestamp -> Int
hashWithSalt Int
_salt AssetPropertyTimestamp' {Maybe Text
Text
timeInSeconds :: Text
offsetInNanos :: Maybe Text
$sel:timeInSeconds:AssetPropertyTimestamp' :: AssetPropertyTimestamp -> Text
$sel:offsetInNanos:AssetPropertyTimestamp' :: AssetPropertyTimestamp -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
offsetInNanos
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
timeInSeconds

instance Prelude.NFData AssetPropertyTimestamp where
  rnf :: AssetPropertyTimestamp -> ()
rnf AssetPropertyTimestamp' {Maybe Text
Text
timeInSeconds :: Text
offsetInNanos :: Maybe Text
$sel:timeInSeconds:AssetPropertyTimestamp' :: AssetPropertyTimestamp -> Text
$sel:offsetInNanos:AssetPropertyTimestamp' :: AssetPropertyTimestamp -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
offsetInNanos
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
timeInSeconds

instance Data.ToJSON AssetPropertyTimestamp where
  toJSON :: AssetPropertyTimestamp -> Value
toJSON AssetPropertyTimestamp' {Maybe Text
Text
timeInSeconds :: Text
offsetInNanos :: Maybe Text
$sel:timeInSeconds:AssetPropertyTimestamp' :: AssetPropertyTimestamp -> Text
$sel:offsetInNanos:AssetPropertyTimestamp' :: AssetPropertyTimestamp -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"offsetInNanos" 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 Text
offsetInNanos,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"timeInSeconds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
timeInSeconds)
          ]
      )