{-# 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.PortRangeFromTo where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data PortRangeFromTo = PortRangeFromTo'
{
PortRangeFromTo -> Maybe Int
to :: Prelude.Maybe Prelude.Int,
PortRangeFromTo -> Maybe Int
from :: Prelude.Maybe Prelude.Int
}
deriving (PortRangeFromTo -> PortRangeFromTo -> Bool
(PortRangeFromTo -> PortRangeFromTo -> Bool)
-> (PortRangeFromTo -> PortRangeFromTo -> Bool)
-> Eq PortRangeFromTo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortRangeFromTo -> PortRangeFromTo -> Bool
$c/= :: PortRangeFromTo -> PortRangeFromTo -> Bool
== :: PortRangeFromTo -> PortRangeFromTo -> Bool
$c== :: PortRangeFromTo -> PortRangeFromTo -> Bool
Prelude.Eq, ReadPrec [PortRangeFromTo]
ReadPrec PortRangeFromTo
Int -> ReadS PortRangeFromTo
ReadS [PortRangeFromTo]
(Int -> ReadS PortRangeFromTo)
-> ReadS [PortRangeFromTo]
-> ReadPrec PortRangeFromTo
-> ReadPrec [PortRangeFromTo]
-> Read PortRangeFromTo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PortRangeFromTo]
$creadListPrec :: ReadPrec [PortRangeFromTo]
readPrec :: ReadPrec PortRangeFromTo
$creadPrec :: ReadPrec PortRangeFromTo
readList :: ReadS [PortRangeFromTo]
$creadList :: ReadS [PortRangeFromTo]
readsPrec :: Int -> ReadS PortRangeFromTo
$creadsPrec :: Int -> ReadS PortRangeFromTo
Prelude.Read, Int -> PortRangeFromTo -> ShowS
[PortRangeFromTo] -> ShowS
PortRangeFromTo -> String
(Int -> PortRangeFromTo -> ShowS)
-> (PortRangeFromTo -> String)
-> ([PortRangeFromTo] -> ShowS)
-> Show PortRangeFromTo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortRangeFromTo] -> ShowS
$cshowList :: [PortRangeFromTo] -> ShowS
show :: PortRangeFromTo -> String
$cshow :: PortRangeFromTo -> String
showsPrec :: Int -> PortRangeFromTo -> ShowS
$cshowsPrec :: Int -> PortRangeFromTo -> ShowS
Prelude.Show, (forall x. PortRangeFromTo -> Rep PortRangeFromTo x)
-> (forall x. Rep PortRangeFromTo x -> PortRangeFromTo)
-> Generic PortRangeFromTo
forall x. Rep PortRangeFromTo x -> PortRangeFromTo
forall x. PortRangeFromTo -> Rep PortRangeFromTo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PortRangeFromTo x -> PortRangeFromTo
$cfrom :: forall x. PortRangeFromTo -> Rep PortRangeFromTo x
Prelude.Generic)
newPortRangeFromTo ::
PortRangeFromTo
newPortRangeFromTo :: PortRangeFromTo
newPortRangeFromTo =
PortRangeFromTo' :: Maybe Int -> Maybe Int -> PortRangeFromTo
PortRangeFromTo'
{ $sel:to:PortRangeFromTo' :: Maybe Int
to = Maybe Int
forall a. Maybe a
Prelude.Nothing,
$sel:from:PortRangeFromTo' :: Maybe Int
from = Maybe Int
forall a. Maybe a
Prelude.Nothing
}
portRangeFromTo_to :: Lens.Lens' PortRangeFromTo (Prelude.Maybe Prelude.Int)
portRangeFromTo_to :: (Maybe Int -> f (Maybe Int))
-> PortRangeFromTo -> f PortRangeFromTo
portRangeFromTo_to = (PortRangeFromTo -> Maybe Int)
-> (PortRangeFromTo -> Maybe Int -> PortRangeFromTo)
-> Lens PortRangeFromTo PortRangeFromTo (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortRangeFromTo' {Maybe Int
to :: Maybe Int
$sel:to:PortRangeFromTo' :: PortRangeFromTo -> Maybe Int
to} -> Maybe Int
to) (\s :: PortRangeFromTo
s@PortRangeFromTo' {} Maybe Int
a -> PortRangeFromTo
s {$sel:to:PortRangeFromTo' :: Maybe Int
to = Maybe Int
a} :: PortRangeFromTo)
portRangeFromTo_from :: Lens.Lens' PortRangeFromTo (Prelude.Maybe Prelude.Int)
portRangeFromTo_from :: (Maybe Int -> f (Maybe Int))
-> PortRangeFromTo -> f PortRangeFromTo
portRangeFromTo_from = (PortRangeFromTo -> Maybe Int)
-> (PortRangeFromTo -> Maybe Int -> PortRangeFromTo)
-> Lens PortRangeFromTo PortRangeFromTo (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortRangeFromTo' {Maybe Int
from :: Maybe Int
$sel:from:PortRangeFromTo' :: PortRangeFromTo -> Maybe Int
from} -> Maybe Int
from) (\s :: PortRangeFromTo
s@PortRangeFromTo' {} Maybe Int
a -> PortRangeFromTo
s {$sel:from:PortRangeFromTo' :: Maybe Int
from = Maybe Int
a} :: PortRangeFromTo)
instance Core.FromJSON PortRangeFromTo where
parseJSON :: Value -> Parser PortRangeFromTo
parseJSON =
String
-> (Object -> Parser PortRangeFromTo)
-> Value
-> Parser PortRangeFromTo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"PortRangeFromTo"
( \Object
x ->
Maybe Int -> Maybe Int -> PortRangeFromTo
PortRangeFromTo'
(Maybe Int -> Maybe Int -> PortRangeFromTo)
-> Parser (Maybe Int) -> Parser (Maybe Int -> PortRangeFromTo)
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
"To") Parser (Maybe Int -> PortRangeFromTo)
-> Parser (Maybe Int) -> Parser PortRangeFromTo
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
"From")
)
instance Prelude.Hashable PortRangeFromTo
instance Prelude.NFData PortRangeFromTo
instance Core.ToJSON PortRangeFromTo where
toJSON :: PortRangeFromTo -> Value
toJSON PortRangeFromTo' {Maybe Int
from :: Maybe Int
to :: Maybe Int
$sel:from:PortRangeFromTo' :: PortRangeFromTo -> Maybe Int
$sel:to:PortRangeFromTo' :: PortRangeFromTo -> Maybe Int
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"To" 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
to,
(Text
"From" 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
from
]
)