{-# 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.PortRange where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data PortRange = PortRange'
{
PortRange -> Natural
fromPort :: Prelude.Natural,
PortRange -> Natural
toPort :: Prelude.Natural
}
deriving (PortRange -> PortRange -> Bool
(PortRange -> PortRange -> Bool)
-> (PortRange -> PortRange -> Bool) -> Eq PortRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortRange -> PortRange -> Bool
$c/= :: PortRange -> PortRange -> Bool
== :: PortRange -> PortRange -> Bool
$c== :: PortRange -> PortRange -> Bool
Prelude.Eq, ReadPrec [PortRange]
ReadPrec PortRange
Int -> ReadS PortRange
ReadS [PortRange]
(Int -> ReadS PortRange)
-> ReadS [PortRange]
-> ReadPrec PortRange
-> ReadPrec [PortRange]
-> Read PortRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PortRange]
$creadListPrec :: ReadPrec [PortRange]
readPrec :: ReadPrec PortRange
$creadPrec :: ReadPrec PortRange
readList :: ReadS [PortRange]
$creadList :: ReadS [PortRange]
readsPrec :: Int -> ReadS PortRange
$creadsPrec :: Int -> ReadS PortRange
Prelude.Read, Int -> PortRange -> ShowS
[PortRange] -> ShowS
PortRange -> String
(Int -> PortRange -> ShowS)
-> (PortRange -> String)
-> ([PortRange] -> ShowS)
-> Show PortRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortRange] -> ShowS
$cshowList :: [PortRange] -> ShowS
show :: PortRange -> String
$cshow :: PortRange -> String
showsPrec :: Int -> PortRange -> ShowS
$cshowsPrec :: Int -> PortRange -> ShowS
Prelude.Show, (forall x. PortRange -> Rep PortRange x)
-> (forall x. Rep PortRange x -> PortRange) -> Generic PortRange
forall x. Rep PortRange x -> PortRange
forall x. PortRange -> Rep PortRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PortRange x -> PortRange
$cfrom :: forall x. PortRange -> Rep PortRange x
Prelude.Generic)
newPortRange ::
Prelude.Natural ->
Prelude.Natural ->
PortRange
newPortRange :: Natural -> Natural -> PortRange
newPortRange Natural
pFromPort_ Natural
pToPort_ =
PortRange' :: Natural -> Natural -> PortRange
PortRange'
{ $sel:fromPort:PortRange' :: Natural
fromPort = Natural
pFromPort_,
$sel:toPort:PortRange' :: Natural
toPort = Natural
pToPort_
}
portRange_fromPort :: Lens.Lens' PortRange Prelude.Natural
portRange_fromPort :: (Natural -> f Natural) -> PortRange -> f PortRange
portRange_fromPort = (PortRange -> Natural)
-> (PortRange -> Natural -> PortRange)
-> Lens PortRange PortRange Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortRange' {Natural
fromPort :: Natural
$sel:fromPort:PortRange' :: PortRange -> Natural
fromPort} -> Natural
fromPort) (\s :: PortRange
s@PortRange' {} Natural
a -> PortRange
s {$sel:fromPort:PortRange' :: Natural
fromPort = Natural
a} :: PortRange)
portRange_toPort :: Lens.Lens' PortRange Prelude.Natural
portRange_toPort :: (Natural -> f Natural) -> PortRange -> f PortRange
portRange_toPort = (PortRange -> Natural)
-> (PortRange -> Natural -> PortRange)
-> Lens PortRange PortRange Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortRange' {Natural
toPort :: Natural
$sel:toPort:PortRange' :: PortRange -> Natural
toPort} -> Natural
toPort) (\s :: PortRange
s@PortRange' {} Natural
a -> PortRange
s {$sel:toPort:PortRange' :: Natural
toPort = Natural
a} :: PortRange)
instance Core.FromJSON PortRange where
parseJSON :: Value -> Parser PortRange
parseJSON =
String -> (Object -> Parser PortRange) -> Value -> Parser PortRange
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"PortRange"
( \Object
x ->
Natural -> Natural -> PortRange
PortRange'
(Natural -> Natural -> PortRange)
-> Parser Natural -> Parser (Natural -> PortRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"FromPort")
Parser (Natural -> PortRange) -> Parser Natural -> Parser PortRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ToPort")
)
instance Prelude.Hashable PortRange
instance Prelude.NFData PortRange
instance Core.ToJSON PortRange where
toJSON :: PortRange -> Value
toJSON PortRange' {Natural
toPort :: Natural
fromPort :: Natural
$sel:toPort:PortRange' :: PortRange -> Natural
$sel:fromPort:PortRange' :: PortRange -> Natural
..} =
[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
"FromPort" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
fromPort),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ToPort" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
toPort)
]
)