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