{-# 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.Header where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.NetworkFirewall.Types.StatefulRuleDirection
import Amazonka.NetworkFirewall.Types.StatefulRuleProtocol
import qualified Amazonka.Prelude as Prelude
data =
{
:: StatefulRuleProtocol,
:: Prelude.Text,
:: Prelude.Text,
:: StatefulRuleDirection,
:: Prelude.Text,
:: Prelude.Text
}
deriving (Header -> Header -> Bool
(Header -> Header -> Bool)
-> (Header -> Header -> Bool) -> Eq Header
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Header -> Header -> Bool
$c/= :: Header -> Header -> Bool
== :: Header -> Header -> Bool
$c== :: Header -> Header -> Bool
Prelude.Eq, ReadPrec [Header]
ReadPrec Header
Int -> ReadS Header
ReadS [Header]
(Int -> ReadS Header)
-> ReadS [Header]
-> ReadPrec Header
-> ReadPrec [Header]
-> Read Header
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Header]
$creadListPrec :: ReadPrec [Header]
readPrec :: ReadPrec Header
$creadPrec :: ReadPrec Header
readList :: ReadS [Header]
$creadList :: ReadS [Header]
readsPrec :: Int -> ReadS Header
$creadsPrec :: Int -> ReadS Header
Prelude.Read, Int -> Header -> ShowS
[Header] -> ShowS
Header -> String
(Int -> Header -> ShowS)
-> (Header -> String) -> ([Header] -> ShowS) -> Show Header
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Header] -> ShowS
$cshowList :: [Header] -> ShowS
show :: Header -> String
$cshow :: Header -> String
showsPrec :: Int -> Header -> ShowS
$cshowsPrec :: Int -> Header -> ShowS
Prelude.Show, (forall x. Header -> Rep Header x)
-> (forall x. Rep Header x -> Header) -> Generic Header
forall x. Rep Header x -> Header
forall x. Header -> Rep Header x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Header x -> Header
$cfrom :: forall x. Header -> Rep Header x
Prelude.Generic)
newHeader ::
StatefulRuleProtocol ->
Prelude.Text ->
Prelude.Text ->
StatefulRuleDirection ->
Prelude.Text ->
Prelude.Text ->
Header
StatefulRuleProtocol
pProtocol_
Text
pSource_
Text
pSourcePort_
StatefulRuleDirection
pDirection_
Text
pDestination_
Text
pDestinationPort_ =
Header' :: StatefulRuleProtocol
-> Text -> Text -> StatefulRuleDirection -> Text -> Text -> Header
Header'
{ $sel:protocol:Header' :: StatefulRuleProtocol
protocol = StatefulRuleProtocol
pProtocol_,
$sel:source:Header' :: Text
source = Text
pSource_,
$sel:sourcePort:Header' :: Text
sourcePort = Text
pSourcePort_,
$sel:direction:Header' :: StatefulRuleDirection
direction = StatefulRuleDirection
pDirection_,
$sel:destination:Header' :: Text
destination = Text
pDestination_,
$sel:destinationPort:Header' :: Text
destinationPort = Text
pDestinationPort_
}
header_protocol :: Lens.Lens' Header StatefulRuleProtocol
= (Header -> StatefulRuleProtocol)
-> (Header -> StatefulRuleProtocol -> Header)
-> Lens Header Header StatefulRuleProtocol StatefulRuleProtocol
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Header' {StatefulRuleProtocol
protocol :: StatefulRuleProtocol
$sel:protocol:Header' :: Header -> StatefulRuleProtocol
protocol} -> StatefulRuleProtocol
protocol) (\s :: Header
s@Header' {} StatefulRuleProtocol
a -> Header
s {$sel:protocol:Header' :: StatefulRuleProtocol
protocol = StatefulRuleProtocol
a} :: Header)
header_source :: Lens.Lens' Header Prelude.Text
= (Header -> Text)
-> (Header -> Text -> Header) -> Lens Header Header Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Header' {Text
source :: Text
$sel:source:Header' :: Header -> Text
source} -> Text
source) (\s :: Header
s@Header' {} Text
a -> Header
s {$sel:source:Header' :: Text
source = Text
a} :: Header)
header_sourcePort :: Lens.Lens' Header Prelude.Text
= (Header -> Text)
-> (Header -> Text -> Header) -> Lens Header Header Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Header' {Text
sourcePort :: Text
$sel:sourcePort:Header' :: Header -> Text
sourcePort} -> Text
sourcePort) (\s :: Header
s@Header' {} Text
a -> Header
s {$sel:sourcePort:Header' :: Text
sourcePort = Text
a} :: Header)
header_direction :: Lens.Lens' Header StatefulRuleDirection
= (Header -> StatefulRuleDirection)
-> (Header -> StatefulRuleDirection -> Header)
-> Lens Header Header StatefulRuleDirection StatefulRuleDirection
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Header' {StatefulRuleDirection
direction :: StatefulRuleDirection
$sel:direction:Header' :: Header -> StatefulRuleDirection
direction} -> StatefulRuleDirection
direction) (\s :: Header
s@Header' {} StatefulRuleDirection
a -> Header
s {$sel:direction:Header' :: StatefulRuleDirection
direction = StatefulRuleDirection
a} :: Header)
header_destination :: Lens.Lens' Header Prelude.Text
= (Header -> Text)
-> (Header -> Text -> Header) -> Lens Header Header Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Header' {Text
destination :: Text
$sel:destination:Header' :: Header -> Text
destination} -> Text
destination) (\s :: Header
s@Header' {} Text
a -> Header
s {$sel:destination:Header' :: Text
destination = Text
a} :: Header)
header_destinationPort :: Lens.Lens' Header Prelude.Text
= (Header -> Text)
-> (Header -> Text -> Header) -> Lens Header Header Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Header' {Text
destinationPort :: Text
$sel:destinationPort:Header' :: Header -> Text
destinationPort} -> Text
destinationPort) (\s :: Header
s@Header' {} Text
a -> Header
s {$sel:destinationPort:Header' :: Text
destinationPort = Text
a} :: Header)
instance Core.FromJSON Header where
parseJSON :: Value -> Parser Header
parseJSON =
String -> (Object -> Parser Header) -> Value -> Parser Header
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Header"
( \Object
x ->
StatefulRuleProtocol
-> Text -> Text -> StatefulRuleDirection -> Text -> Text -> Header
Header'
(StatefulRuleProtocol
-> Text -> Text -> StatefulRuleDirection -> Text -> Text -> Header)
-> Parser StatefulRuleProtocol
-> Parser
(Text -> Text -> StatefulRuleDirection -> Text -> Text -> Header)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser StatefulRuleProtocol
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Protocol")
Parser
(Text -> Text -> StatefulRuleDirection -> Text -> Text -> Header)
-> Parser Text
-> Parser (Text -> StatefulRuleDirection -> Text -> Text -> Header)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Source")
Parser (Text -> StatefulRuleDirection -> Text -> Text -> Header)
-> Parser Text
-> Parser (StatefulRuleDirection -> Text -> Text -> Header)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SourcePort")
Parser (StatefulRuleDirection -> Text -> Text -> Header)
-> Parser StatefulRuleDirection -> Parser (Text -> Text -> Header)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser StatefulRuleDirection
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Direction")
Parser (Text -> Text -> Header)
-> Parser Text -> Parser (Text -> Header)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Destination")
Parser (Text -> Header) -> Parser Text -> Parser Header
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DestinationPort")
)
instance Prelude.Hashable Header
instance Prelude.NFData Header
instance Core.ToJSON Header where
toJSON :: Header -> Value
toJSON Header' {Text
StatefulRuleDirection
StatefulRuleProtocol
destinationPort :: Text
destination :: Text
direction :: StatefulRuleDirection
sourcePort :: Text
source :: Text
protocol :: StatefulRuleProtocol
$sel:destinationPort:Header' :: Header -> Text
$sel:destination:Header' :: Header -> Text
$sel:direction:Header' :: Header -> StatefulRuleDirection
$sel:sourcePort:Header' :: Header -> Text
$sel:source:Header' :: Header -> Text
$sel:protocol:Header' :: Header -> StatefulRuleProtocol
..} =
[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
"Protocol" Text -> StatefulRuleProtocol -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= StatefulRuleProtocol
protocol),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Source" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
source),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SourcePort" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sourcePort),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Direction" Text -> StatefulRuleDirection -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= StatefulRuleDirection
direction),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Destination" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
destination),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"DestinationPort" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
destinationPort)
]
)