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