{-# 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 #-}
module Amazonka.IotTwinMaker.Types.PropertyValue where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IotTwinMaker.Types.DataValue
import qualified Amazonka.Prelude as Prelude
data PropertyValue = PropertyValue'
{
PropertyValue -> Maybe Text
time :: Prelude.Maybe Prelude.Text,
PropertyValue -> Maybe POSIX
timestamp :: Prelude.Maybe Data.POSIX,
PropertyValue -> DataValue
value :: DataValue
}
deriving (PropertyValue -> PropertyValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PropertyValue -> PropertyValue -> Bool
$c/= :: PropertyValue -> PropertyValue -> Bool
== :: PropertyValue -> PropertyValue -> Bool
$c== :: PropertyValue -> PropertyValue -> Bool
Prelude.Eq, ReadPrec [PropertyValue]
ReadPrec PropertyValue
Int -> ReadS PropertyValue
ReadS [PropertyValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PropertyValue]
$creadListPrec :: ReadPrec [PropertyValue]
readPrec :: ReadPrec PropertyValue
$creadPrec :: ReadPrec PropertyValue
readList :: ReadS [PropertyValue]
$creadList :: ReadS [PropertyValue]
readsPrec :: Int -> ReadS PropertyValue
$creadsPrec :: Int -> ReadS PropertyValue
Prelude.Read, Int -> PropertyValue -> ShowS
[PropertyValue] -> ShowS
PropertyValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PropertyValue] -> ShowS
$cshowList :: [PropertyValue] -> ShowS
show :: PropertyValue -> String
$cshow :: PropertyValue -> String
showsPrec :: Int -> PropertyValue -> ShowS
$cshowsPrec :: Int -> PropertyValue -> ShowS
Prelude.Show, forall x. Rep PropertyValue x -> PropertyValue
forall x. PropertyValue -> Rep PropertyValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PropertyValue x -> PropertyValue
$cfrom :: forall x. PropertyValue -> Rep PropertyValue x
Prelude.Generic)
newPropertyValue ::
DataValue ->
PropertyValue
newPropertyValue :: DataValue -> PropertyValue
newPropertyValue DataValue
pValue_ =
PropertyValue'
{ $sel:time:PropertyValue' :: Maybe Text
time = forall a. Maybe a
Prelude.Nothing,
$sel:timestamp:PropertyValue' :: Maybe POSIX
timestamp = forall a. Maybe a
Prelude.Nothing,
$sel:value:PropertyValue' :: DataValue
value = DataValue
pValue_
}
propertyValue_time :: Lens.Lens' PropertyValue (Prelude.Maybe Prelude.Text)
propertyValue_time :: Lens' PropertyValue (Maybe Text)
propertyValue_time = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyValue' {Maybe Text
time :: Maybe Text
$sel:time:PropertyValue' :: PropertyValue -> Maybe Text
time} -> Maybe Text
time) (\s :: PropertyValue
s@PropertyValue' {} Maybe Text
a -> PropertyValue
s {$sel:time:PropertyValue' :: Maybe Text
time = Maybe Text
a} :: PropertyValue)
propertyValue_timestamp :: Lens.Lens' PropertyValue (Prelude.Maybe Prelude.UTCTime)
propertyValue_timestamp :: Lens' PropertyValue (Maybe UTCTime)
propertyValue_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyValue' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:PropertyValue' :: PropertyValue -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: PropertyValue
s@PropertyValue' {} Maybe POSIX
a -> PropertyValue
s {$sel:timestamp:PropertyValue' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: PropertyValue) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time
propertyValue_value :: Lens.Lens' PropertyValue DataValue
propertyValue_value :: Lens' PropertyValue DataValue
propertyValue_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PropertyValue' {DataValue
value :: DataValue
$sel:value:PropertyValue' :: PropertyValue -> DataValue
value} -> DataValue
value) (\s :: PropertyValue
s@PropertyValue' {} DataValue
a -> PropertyValue
s {$sel:value:PropertyValue' :: DataValue
value = DataValue
a} :: PropertyValue)
instance Data.FromJSON PropertyValue where
parseJSON :: Value -> Parser PropertyValue
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"PropertyValue"
( \Object
x ->
Maybe Text -> Maybe POSIX -> DataValue -> PropertyValue
PropertyValue'
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
"time")
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
"timestamp")
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 PropertyValue where
hashWithSalt :: Int -> PropertyValue -> Int
hashWithSalt Int
_salt PropertyValue' {Maybe Text
Maybe POSIX
DataValue
value :: DataValue
timestamp :: Maybe POSIX
time :: Maybe Text
$sel:value:PropertyValue' :: PropertyValue -> DataValue
$sel:timestamp:PropertyValue' :: PropertyValue -> Maybe POSIX
$sel:time:PropertyValue' :: PropertyValue -> Maybe Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
time
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
timestamp
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DataValue
value
instance Prelude.NFData PropertyValue where
rnf :: PropertyValue -> ()
rnf PropertyValue' {Maybe Text
Maybe POSIX
DataValue
value :: DataValue
timestamp :: Maybe POSIX
time :: Maybe Text
$sel:value:PropertyValue' :: PropertyValue -> DataValue
$sel:timestamp:PropertyValue' :: PropertyValue -> Maybe POSIX
$sel:time:PropertyValue' :: PropertyValue -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
time
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
timestamp
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DataValue
value
instance Data.ToJSON PropertyValue where
toJSON :: PropertyValue -> Value
toJSON PropertyValue' {Maybe Text
Maybe POSIX
DataValue
value :: DataValue
timestamp :: Maybe POSIX
time :: Maybe Text
$sel:value:PropertyValue' :: PropertyValue -> DataValue
$sel:timestamp:PropertyValue' :: PropertyValue -> Maybe POSIX
$sel:time:PropertyValue' :: PropertyValue -> Maybe Text
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"time" 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
time,
(Key
"timestamp" 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 POSIX
timestamp,
forall a. a -> Maybe a
Prelude.Just (Key
"value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DataValue
value)
]
)