{-# 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.NetworkFirewall.Types.CustomAction where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.NetworkFirewall.Types.ActionDefinition
import qualified Amazonka.Prelude as Prelude
data CustomAction = CustomAction'
{
CustomAction -> Text
actionName :: Prelude.Text,
CustomAction -> ActionDefinition
actionDefinition :: ActionDefinition
}
deriving (CustomAction -> CustomAction -> Bool
(CustomAction -> CustomAction -> Bool)
-> (CustomAction -> CustomAction -> Bool) -> Eq CustomAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomAction -> CustomAction -> Bool
$c/= :: CustomAction -> CustomAction -> Bool
== :: CustomAction -> CustomAction -> Bool
$c== :: CustomAction -> CustomAction -> Bool
Prelude.Eq, ReadPrec [CustomAction]
ReadPrec CustomAction
Int -> ReadS CustomAction
ReadS [CustomAction]
(Int -> ReadS CustomAction)
-> ReadS [CustomAction]
-> ReadPrec CustomAction
-> ReadPrec [CustomAction]
-> Read CustomAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomAction]
$creadListPrec :: ReadPrec [CustomAction]
readPrec :: ReadPrec CustomAction
$creadPrec :: ReadPrec CustomAction
readList :: ReadS [CustomAction]
$creadList :: ReadS [CustomAction]
readsPrec :: Int -> ReadS CustomAction
$creadsPrec :: Int -> ReadS CustomAction
Prelude.Read, Int -> CustomAction -> ShowS
[CustomAction] -> ShowS
CustomAction -> String
(Int -> CustomAction -> ShowS)
-> (CustomAction -> String)
-> ([CustomAction] -> ShowS)
-> Show CustomAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomAction] -> ShowS
$cshowList :: [CustomAction] -> ShowS
show :: CustomAction -> String
$cshow :: CustomAction -> String
showsPrec :: Int -> CustomAction -> ShowS
$cshowsPrec :: Int -> CustomAction -> ShowS
Prelude.Show, (forall x. CustomAction -> Rep CustomAction x)
-> (forall x. Rep CustomAction x -> CustomAction)
-> Generic CustomAction
forall x. Rep CustomAction x -> CustomAction
forall x. CustomAction -> Rep CustomAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomAction x -> CustomAction
$cfrom :: forall x. CustomAction -> Rep CustomAction x
Prelude.Generic)
newCustomAction ::
Prelude.Text ->
ActionDefinition ->
CustomAction
newCustomAction :: Text -> ActionDefinition -> CustomAction
newCustomAction Text
pActionName_ ActionDefinition
pActionDefinition_ =
CustomAction' :: Text -> ActionDefinition -> CustomAction
CustomAction'
{ $sel:actionName:CustomAction' :: Text
actionName = Text
pActionName_,
$sel:actionDefinition:CustomAction' :: ActionDefinition
actionDefinition = ActionDefinition
pActionDefinition_
}
customAction_actionName :: Lens.Lens' CustomAction Prelude.Text
customAction_actionName :: (Text -> f Text) -> CustomAction -> f CustomAction
customAction_actionName = (CustomAction -> Text)
-> (CustomAction -> Text -> CustomAction)
-> Lens CustomAction CustomAction Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomAction' {Text
actionName :: Text
$sel:actionName:CustomAction' :: CustomAction -> Text
actionName} -> Text
actionName) (\s :: CustomAction
s@CustomAction' {} Text
a -> CustomAction
s {$sel:actionName:CustomAction' :: Text
actionName = Text
a} :: CustomAction)
customAction_actionDefinition :: Lens.Lens' CustomAction ActionDefinition
customAction_actionDefinition :: (ActionDefinition -> f ActionDefinition)
-> CustomAction -> f CustomAction
customAction_actionDefinition = (CustomAction -> ActionDefinition)
-> (CustomAction -> ActionDefinition -> CustomAction)
-> Lens CustomAction CustomAction ActionDefinition ActionDefinition
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomAction' {ActionDefinition
actionDefinition :: ActionDefinition
$sel:actionDefinition:CustomAction' :: CustomAction -> ActionDefinition
actionDefinition} -> ActionDefinition
actionDefinition) (\s :: CustomAction
s@CustomAction' {} ActionDefinition
a -> CustomAction
s {$sel:actionDefinition:CustomAction' :: ActionDefinition
actionDefinition = ActionDefinition
a} :: CustomAction)
instance Core.FromJSON CustomAction where
parseJSON :: Value -> Parser CustomAction
parseJSON =
String
-> (Object -> Parser CustomAction) -> Value -> Parser CustomAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"CustomAction"
( \Object
x ->
Text -> ActionDefinition -> CustomAction
CustomAction'
(Text -> ActionDefinition -> CustomAction)
-> Parser Text -> Parser (ActionDefinition -> CustomAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ActionName")
Parser (ActionDefinition -> CustomAction)
-> Parser ActionDefinition -> Parser CustomAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ActionDefinition
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ActionDefinition")
)
instance Prelude.Hashable CustomAction
instance Prelude.NFData CustomAction
instance Core.ToJSON CustomAction where
toJSON :: CustomAction -> Value
toJSON CustomAction' {Text
ActionDefinition
actionDefinition :: ActionDefinition
actionName :: Text
$sel:actionDefinition:CustomAction' :: CustomAction -> ActionDefinition
$sel:actionName:CustomAction' :: CustomAction -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ActionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
actionName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ActionDefinition" Text -> ActionDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ActionDefinition
actionDefinition)
]
)