{-# 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.SecurityHub.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 -> Maybe Int
begin :: Prelude.Maybe Prelude.Int,
PortRange -> Maybe Int
end :: Prelude.Maybe Prelude.Int
}
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 ::
PortRange
newPortRange :: PortRange
newPortRange =
PortRange' :: Maybe Int -> Maybe Int -> PortRange
PortRange'
{ $sel:begin:PortRange' :: Maybe Int
begin = Maybe Int
forall a. Maybe a
Prelude.Nothing,
$sel:end:PortRange' :: Maybe Int
end = Maybe Int
forall a. Maybe a
Prelude.Nothing
}
portRange_begin :: Lens.Lens' PortRange (Prelude.Maybe Prelude.Int)
portRange_begin :: (Maybe Int -> f (Maybe Int)) -> PortRange -> f PortRange
portRange_begin = (PortRange -> Maybe Int)
-> (PortRange -> Maybe Int -> PortRange)
-> Lens PortRange PortRange (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortRange' {Maybe Int
begin :: Maybe Int
$sel:begin:PortRange' :: PortRange -> Maybe Int
begin} -> Maybe Int
begin) (\s :: PortRange
s@PortRange' {} Maybe Int
a -> PortRange
s {$sel:begin:PortRange' :: Maybe Int
begin = Maybe Int
a} :: PortRange)
portRange_end :: Lens.Lens' PortRange (Prelude.Maybe Prelude.Int)
portRange_end :: (Maybe Int -> f (Maybe Int)) -> PortRange -> f PortRange
portRange_end = (PortRange -> Maybe Int)
-> (PortRange -> Maybe Int -> PortRange)
-> Lens PortRange PortRange (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortRange' {Maybe Int
end :: Maybe Int
$sel:end:PortRange' :: PortRange -> Maybe Int
end} -> Maybe Int
end) (\s :: PortRange
s@PortRange' {} Maybe Int
a -> PortRange
s {$sel:end:PortRange' :: Maybe Int
end = Maybe Int
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 ->
Maybe Int -> Maybe Int -> PortRange
PortRange'
(Maybe Int -> Maybe Int -> PortRange)
-> Parser (Maybe Int) -> Parser (Maybe Int -> PortRange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Begin") Parser (Maybe Int -> PortRange)
-> Parser (Maybe Int) -> Parser PortRange
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"End")
)
instance Prelude.Hashable PortRange
instance Prelude.NFData PortRange
instance Core.ToJSON PortRange where
toJSON :: PortRange -> Value
toJSON PortRange' {Maybe Int
end :: Maybe Int
begin :: Maybe Int
$sel:end:PortRange' :: PortRange -> Maybe Int
$sel:begin:PortRange' :: PortRange -> Maybe Int
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Begin" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
begin,
(Text
"End" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
end
]
)