{-# 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.DLM.Types.EventSource where
import qualified Amazonka.Core as Core
import Amazonka.DLM.Types.EventParameters
import Amazonka.DLM.Types.EventSourceValues
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data EventSource = EventSource'
{
EventSource -> Maybe EventParameters
parameters :: Prelude.Maybe EventParameters,
EventSource -> EventSourceValues
type' :: EventSourceValues
}
deriving (EventSource -> EventSource -> Bool
(EventSource -> EventSource -> Bool)
-> (EventSource -> EventSource -> Bool) -> Eq EventSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EventSource -> EventSource -> Bool
$c/= :: EventSource -> EventSource -> Bool
== :: EventSource -> EventSource -> Bool
$c== :: EventSource -> EventSource -> Bool
Prelude.Eq, ReadPrec [EventSource]
ReadPrec EventSource
Int -> ReadS EventSource
ReadS [EventSource]
(Int -> ReadS EventSource)
-> ReadS [EventSource]
-> ReadPrec EventSource
-> ReadPrec [EventSource]
-> Read EventSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EventSource]
$creadListPrec :: ReadPrec [EventSource]
readPrec :: ReadPrec EventSource
$creadPrec :: ReadPrec EventSource
readList :: ReadS [EventSource]
$creadList :: ReadS [EventSource]
readsPrec :: Int -> ReadS EventSource
$creadsPrec :: Int -> ReadS EventSource
Prelude.Read, Int -> EventSource -> ShowS
[EventSource] -> ShowS
EventSource -> String
(Int -> EventSource -> ShowS)
-> (EventSource -> String)
-> ([EventSource] -> ShowS)
-> Show EventSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EventSource] -> ShowS
$cshowList :: [EventSource] -> ShowS
show :: EventSource -> String
$cshow :: EventSource -> String
showsPrec :: Int -> EventSource -> ShowS
$cshowsPrec :: Int -> EventSource -> ShowS
Prelude.Show, (forall x. EventSource -> Rep EventSource x)
-> (forall x. Rep EventSource x -> EventSource)
-> Generic EventSource
forall x. Rep EventSource x -> EventSource
forall x. EventSource -> Rep EventSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EventSource x -> EventSource
$cfrom :: forall x. EventSource -> Rep EventSource x
Prelude.Generic)
newEventSource ::
EventSourceValues ->
EventSource
newEventSource :: EventSourceValues -> EventSource
newEventSource EventSourceValues
pType_ =
EventSource' :: Maybe EventParameters -> EventSourceValues -> EventSource
EventSource'
{ $sel:parameters:EventSource' :: Maybe EventParameters
parameters = Maybe EventParameters
forall a. Maybe a
Prelude.Nothing,
$sel:type':EventSource' :: EventSourceValues
type' = EventSourceValues
pType_
}
eventSource_parameters :: Lens.Lens' EventSource (Prelude.Maybe EventParameters)
eventSource_parameters :: (Maybe EventParameters -> f (Maybe EventParameters))
-> EventSource -> f EventSource
eventSource_parameters = (EventSource -> Maybe EventParameters)
-> (EventSource -> Maybe EventParameters -> EventSource)
-> Lens
EventSource
EventSource
(Maybe EventParameters)
(Maybe EventParameters)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventSource' {Maybe EventParameters
parameters :: Maybe EventParameters
$sel:parameters:EventSource' :: EventSource -> Maybe EventParameters
parameters} -> Maybe EventParameters
parameters) (\s :: EventSource
s@EventSource' {} Maybe EventParameters
a -> EventSource
s {$sel:parameters:EventSource' :: Maybe EventParameters
parameters = Maybe EventParameters
a} :: EventSource)
eventSource_type :: Lens.Lens' EventSource EventSourceValues
eventSource_type :: (EventSourceValues -> f EventSourceValues)
-> EventSource -> f EventSource
eventSource_type = (EventSource -> EventSourceValues)
-> (EventSource -> EventSourceValues -> EventSource)
-> Lens EventSource EventSource EventSourceValues EventSourceValues
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EventSource' {EventSourceValues
type' :: EventSourceValues
$sel:type':EventSource' :: EventSource -> EventSourceValues
type'} -> EventSourceValues
type') (\s :: EventSource
s@EventSource' {} EventSourceValues
a -> EventSource
s {$sel:type':EventSource' :: EventSourceValues
type' = EventSourceValues
a} :: EventSource)
instance Core.FromJSON EventSource where
parseJSON :: Value -> Parser EventSource
parseJSON =
String
-> (Object -> Parser EventSource) -> Value -> Parser EventSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"EventSource"
( \Object
x ->
Maybe EventParameters -> EventSourceValues -> EventSource
EventSource'
(Maybe EventParameters -> EventSourceValues -> EventSource)
-> Parser (Maybe EventParameters)
-> Parser (EventSourceValues -> EventSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EventParameters)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Parameters")
Parser (EventSourceValues -> EventSource)
-> Parser EventSourceValues -> Parser EventSource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser EventSourceValues
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
)
instance Prelude.Hashable EventSource
instance Prelude.NFData EventSource
instance Core.ToJSON EventSource where
toJSON :: EventSource -> Value
toJSON EventSource' {Maybe EventParameters
EventSourceValues
type' :: EventSourceValues
parameters :: Maybe EventParameters
$sel:type':EventSource' :: EventSource -> EventSourceValues
$sel:parameters:EventSource' :: EventSource -> Maybe EventParameters
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Parameters" Text -> EventParameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (EventParameters -> Pair) -> Maybe EventParameters -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EventParameters
parameters,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> EventSourceValues -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EventSourceValues
type')
]
)