{-# 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.AlexaBusiness.Types.DeviceEvent where
import Amazonka.AlexaBusiness.Types.DeviceEventType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data DeviceEvent = DeviceEvent'
{
DeviceEvent -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
DeviceEvent -> Maybe DeviceEventType
type' :: Prelude.Maybe DeviceEventType,
DeviceEvent -> Maybe POSIX
timestamp :: Prelude.Maybe Core.POSIX
}
deriving (DeviceEvent -> DeviceEvent -> Bool
(DeviceEvent -> DeviceEvent -> Bool)
-> (DeviceEvent -> DeviceEvent -> Bool) -> Eq DeviceEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeviceEvent -> DeviceEvent -> Bool
$c/= :: DeviceEvent -> DeviceEvent -> Bool
== :: DeviceEvent -> DeviceEvent -> Bool
$c== :: DeviceEvent -> DeviceEvent -> Bool
Prelude.Eq, ReadPrec [DeviceEvent]
ReadPrec DeviceEvent
Int -> ReadS DeviceEvent
ReadS [DeviceEvent]
(Int -> ReadS DeviceEvent)
-> ReadS [DeviceEvent]
-> ReadPrec DeviceEvent
-> ReadPrec [DeviceEvent]
-> Read DeviceEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeviceEvent]
$creadListPrec :: ReadPrec [DeviceEvent]
readPrec :: ReadPrec DeviceEvent
$creadPrec :: ReadPrec DeviceEvent
readList :: ReadS [DeviceEvent]
$creadList :: ReadS [DeviceEvent]
readsPrec :: Int -> ReadS DeviceEvent
$creadsPrec :: Int -> ReadS DeviceEvent
Prelude.Read, Int -> DeviceEvent -> ShowS
[DeviceEvent] -> ShowS
DeviceEvent -> String
(Int -> DeviceEvent -> ShowS)
-> (DeviceEvent -> String)
-> ([DeviceEvent] -> ShowS)
-> Show DeviceEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeviceEvent] -> ShowS
$cshowList :: [DeviceEvent] -> ShowS
show :: DeviceEvent -> String
$cshow :: DeviceEvent -> String
showsPrec :: Int -> DeviceEvent -> ShowS
$cshowsPrec :: Int -> DeviceEvent -> ShowS
Prelude.Show, (forall x. DeviceEvent -> Rep DeviceEvent x)
-> (forall x. Rep DeviceEvent x -> DeviceEvent)
-> Generic DeviceEvent
forall x. Rep DeviceEvent x -> DeviceEvent
forall x. DeviceEvent -> Rep DeviceEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeviceEvent x -> DeviceEvent
$cfrom :: forall x. DeviceEvent -> Rep DeviceEvent x
Prelude.Generic)
newDeviceEvent ::
DeviceEvent
newDeviceEvent :: DeviceEvent
newDeviceEvent =
DeviceEvent' :: Maybe Text -> Maybe DeviceEventType -> Maybe POSIX -> DeviceEvent
DeviceEvent'
{ $sel:value:DeviceEvent' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:type':DeviceEvent' :: Maybe DeviceEventType
type' = Maybe DeviceEventType
forall a. Maybe a
Prelude.Nothing,
$sel:timestamp:DeviceEvent' :: Maybe POSIX
timestamp = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
}
deviceEvent_value :: Lens.Lens' DeviceEvent (Prelude.Maybe Prelude.Text)
deviceEvent_value :: (Maybe Text -> f (Maybe Text)) -> DeviceEvent -> f DeviceEvent
deviceEvent_value = (DeviceEvent -> Maybe Text)
-> (DeviceEvent -> Maybe Text -> DeviceEvent)
-> Lens DeviceEvent DeviceEvent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceEvent' {Maybe Text
value :: Maybe Text
$sel:value:DeviceEvent' :: DeviceEvent -> Maybe Text
value} -> Maybe Text
value) (\s :: DeviceEvent
s@DeviceEvent' {} Maybe Text
a -> DeviceEvent
s {$sel:value:DeviceEvent' :: Maybe Text
value = Maybe Text
a} :: DeviceEvent)
deviceEvent_type :: Lens.Lens' DeviceEvent (Prelude.Maybe DeviceEventType)
deviceEvent_type :: (Maybe DeviceEventType -> f (Maybe DeviceEventType))
-> DeviceEvent -> f DeviceEvent
deviceEvent_type = (DeviceEvent -> Maybe DeviceEventType)
-> (DeviceEvent -> Maybe DeviceEventType -> DeviceEvent)
-> Lens
DeviceEvent
DeviceEvent
(Maybe DeviceEventType)
(Maybe DeviceEventType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceEvent' {Maybe DeviceEventType
type' :: Maybe DeviceEventType
$sel:type':DeviceEvent' :: DeviceEvent -> Maybe DeviceEventType
type'} -> Maybe DeviceEventType
type') (\s :: DeviceEvent
s@DeviceEvent' {} Maybe DeviceEventType
a -> DeviceEvent
s {$sel:type':DeviceEvent' :: Maybe DeviceEventType
type' = Maybe DeviceEventType
a} :: DeviceEvent)
deviceEvent_timestamp :: Lens.Lens' DeviceEvent (Prelude.Maybe Prelude.UTCTime)
deviceEvent_timestamp :: (Maybe UTCTime -> f (Maybe UTCTime))
-> DeviceEvent -> f DeviceEvent
deviceEvent_timestamp = (DeviceEvent -> Maybe POSIX)
-> (DeviceEvent -> Maybe POSIX -> DeviceEvent)
-> Lens DeviceEvent DeviceEvent (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeviceEvent' {Maybe POSIX
timestamp :: Maybe POSIX
$sel:timestamp:DeviceEvent' :: DeviceEvent -> Maybe POSIX
timestamp} -> Maybe POSIX
timestamp) (\s :: DeviceEvent
s@DeviceEvent' {} Maybe POSIX
a -> DeviceEvent
s {$sel:timestamp:DeviceEvent' :: Maybe POSIX
timestamp = Maybe POSIX
a} :: DeviceEvent) ((Maybe POSIX -> f (Maybe POSIX)) -> DeviceEvent -> f DeviceEvent)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
-> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> DeviceEvent
-> f DeviceEvent
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time
instance Core.FromJSON DeviceEvent where
parseJSON :: Value -> Parser DeviceEvent
parseJSON =
String
-> (Object -> Parser DeviceEvent) -> Value -> Parser DeviceEvent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"DeviceEvent"
( \Object
x ->
Maybe Text -> Maybe DeviceEventType -> Maybe POSIX -> DeviceEvent
DeviceEvent'
(Maybe Text -> Maybe DeviceEventType -> Maybe POSIX -> DeviceEvent)
-> Parser (Maybe Text)
-> Parser (Maybe DeviceEventType -> Maybe POSIX -> DeviceEvent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Value")
Parser (Maybe DeviceEventType -> Maybe POSIX -> DeviceEvent)
-> Parser (Maybe DeviceEventType)
-> Parser (Maybe POSIX -> DeviceEvent)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DeviceEventType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
Parser (Maybe POSIX -> DeviceEvent)
-> Parser (Maybe POSIX) -> Parser DeviceEvent
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Timestamp")
)
instance Prelude.Hashable DeviceEvent
instance Prelude.NFData DeviceEvent