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