{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $sel:actionName:CustomAction' :: Text
actionName = Text
pActionName_,
$sel:actionDefinition:CustomAction' :: ActionDefinition
actionDefinition = ActionDefinition
pActionDefinition_
}
customAction_actionName :: Lens.Lens' CustomAction Prelude.Text
customAction_actionName :: Lens' CustomAction Text
customAction_actionName = 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 :: Lens' CustomAction ActionDefinition
customAction_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 Data.FromJSON CustomAction where
parseJSON :: Value -> Parser CustomAction
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"CustomAction"
( \Object
x ->
Text -> ActionDefinition -> CustomAction
CustomAction'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ActionName")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ActionDefinition")
)
instance Prelude.Hashable CustomAction where
hashWithSalt :: Int -> CustomAction -> Int
hashWithSalt Int
_salt CustomAction' {Text
ActionDefinition
actionDefinition :: ActionDefinition
actionName :: Text
$sel:actionDefinition:CustomAction' :: CustomAction -> ActionDefinition
$sel:actionName:CustomAction' :: CustomAction -> Text
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
actionName
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ActionDefinition
actionDefinition
instance Prelude.NFData CustomAction where
rnf :: CustomAction -> ()
rnf CustomAction' {Text
ActionDefinition
actionDefinition :: ActionDefinition
actionName :: Text
$sel:actionDefinition:CustomAction' :: CustomAction -> ActionDefinition
$sel:actionName:CustomAction' :: CustomAction -> Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Text
actionName
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ActionDefinition
actionDefinition
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"ActionName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
actionName),
forall a. a -> Maybe a
Prelude.Just
(Key
"ActionDefinition" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ActionDefinition
actionDefinition)
]
)