{-# 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.IoTEvents.Types.OnExitLifecycle where
import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.Types.Event
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data OnExitLifecycle = OnExitLifecycle'
{
OnExitLifecycle -> Maybe [Event]
events :: Prelude.Maybe [Event]
}
deriving (OnExitLifecycle -> OnExitLifecycle -> Bool
(OnExitLifecycle -> OnExitLifecycle -> Bool)
-> (OnExitLifecycle -> OnExitLifecycle -> Bool)
-> Eq OnExitLifecycle
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OnExitLifecycle -> OnExitLifecycle -> Bool
$c/= :: OnExitLifecycle -> OnExitLifecycle -> Bool
== :: OnExitLifecycle -> OnExitLifecycle -> Bool
$c== :: OnExitLifecycle -> OnExitLifecycle -> Bool
Prelude.Eq, ReadPrec [OnExitLifecycle]
ReadPrec OnExitLifecycle
Int -> ReadS OnExitLifecycle
ReadS [OnExitLifecycle]
(Int -> ReadS OnExitLifecycle)
-> ReadS [OnExitLifecycle]
-> ReadPrec OnExitLifecycle
-> ReadPrec [OnExitLifecycle]
-> Read OnExitLifecycle
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OnExitLifecycle]
$creadListPrec :: ReadPrec [OnExitLifecycle]
readPrec :: ReadPrec OnExitLifecycle
$creadPrec :: ReadPrec OnExitLifecycle
readList :: ReadS [OnExitLifecycle]
$creadList :: ReadS [OnExitLifecycle]
readsPrec :: Int -> ReadS OnExitLifecycle
$creadsPrec :: Int -> ReadS OnExitLifecycle
Prelude.Read, Int -> OnExitLifecycle -> ShowS
[OnExitLifecycle] -> ShowS
OnExitLifecycle -> String
(Int -> OnExitLifecycle -> ShowS)
-> (OnExitLifecycle -> String)
-> ([OnExitLifecycle] -> ShowS)
-> Show OnExitLifecycle
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OnExitLifecycle] -> ShowS
$cshowList :: [OnExitLifecycle] -> ShowS
show :: OnExitLifecycle -> String
$cshow :: OnExitLifecycle -> String
showsPrec :: Int -> OnExitLifecycle -> ShowS
$cshowsPrec :: Int -> OnExitLifecycle -> ShowS
Prelude.Show, (forall x. OnExitLifecycle -> Rep OnExitLifecycle x)
-> (forall x. Rep OnExitLifecycle x -> OnExitLifecycle)
-> Generic OnExitLifecycle
forall x. Rep OnExitLifecycle x -> OnExitLifecycle
forall x. OnExitLifecycle -> Rep OnExitLifecycle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OnExitLifecycle x -> OnExitLifecycle
$cfrom :: forall x. OnExitLifecycle -> Rep OnExitLifecycle x
Prelude.Generic)
newOnExitLifecycle ::
OnExitLifecycle
newOnExitLifecycle :: OnExitLifecycle
newOnExitLifecycle =
OnExitLifecycle' :: Maybe [Event] -> OnExitLifecycle
OnExitLifecycle' {$sel:events:OnExitLifecycle' :: Maybe [Event]
events = Maybe [Event]
forall a. Maybe a
Prelude.Nothing}
onExitLifecycle_events :: Lens.Lens' OnExitLifecycle (Prelude.Maybe [Event])
onExitLifecycle_events :: (Maybe [Event] -> f (Maybe [Event]))
-> OnExitLifecycle -> f OnExitLifecycle
onExitLifecycle_events = (OnExitLifecycle -> Maybe [Event])
-> (OnExitLifecycle -> Maybe [Event] -> OnExitLifecycle)
-> Lens
OnExitLifecycle OnExitLifecycle (Maybe [Event]) (Maybe [Event])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OnExitLifecycle' {Maybe [Event]
events :: Maybe [Event]
$sel:events:OnExitLifecycle' :: OnExitLifecycle -> Maybe [Event]
events} -> Maybe [Event]
events) (\s :: OnExitLifecycle
s@OnExitLifecycle' {} Maybe [Event]
a -> OnExitLifecycle
s {$sel:events:OnExitLifecycle' :: Maybe [Event]
events = Maybe [Event]
a} :: OnExitLifecycle) ((Maybe [Event] -> f (Maybe [Event]))
-> OnExitLifecycle -> f OnExitLifecycle)
-> ((Maybe [Event] -> f (Maybe [Event]))
-> Maybe [Event] -> f (Maybe [Event]))
-> (Maybe [Event] -> f (Maybe [Event]))
-> OnExitLifecycle
-> f OnExitLifecycle
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Event] [Event] [Event] [Event]
-> Iso
(Maybe [Event]) (Maybe [Event]) (Maybe [Event]) (Maybe [Event])
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 [Event] [Event] [Event] [Event]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON OnExitLifecycle where
parseJSON :: Value -> Parser OnExitLifecycle
parseJSON =
String
-> (Object -> Parser OnExitLifecycle)
-> Value
-> Parser OnExitLifecycle
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"OnExitLifecycle"
( \Object
x ->
Maybe [Event] -> OnExitLifecycle
OnExitLifecycle'
(Maybe [Event] -> OnExitLifecycle)
-> Parser (Maybe [Event]) -> Parser OnExitLifecycle
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Event]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"events" Parser (Maybe (Maybe [Event]))
-> Maybe [Event] -> Parser (Maybe [Event])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Event]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable OnExitLifecycle
instance Prelude.NFData OnExitLifecycle
instance Core.ToJSON OnExitLifecycle where
toJSON :: OnExitLifecycle -> Value
toJSON OnExitLifecycle' {Maybe [Event]
events :: Maybe [Event]
$sel:events:OnExitLifecycle' :: OnExitLifecycle -> Maybe [Event]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[(Text
"events" Text -> [Event] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Event] -> Pair) -> Maybe [Event] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Event]
events]
)