{-# 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.AppMesh.Types.PortMapping where
import Amazonka.AppMesh.Types.PortProtocol
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
data PortMapping = PortMapping'
{
PortMapping -> Natural
port :: Prelude.Natural,
PortMapping -> PortProtocol
protocol :: PortProtocol
}
deriving (PortMapping -> PortMapping -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PortMapping -> PortMapping -> Bool
$c/= :: PortMapping -> PortMapping -> Bool
== :: PortMapping -> PortMapping -> Bool
$c== :: PortMapping -> PortMapping -> Bool
Prelude.Eq, ReadPrec [PortMapping]
ReadPrec PortMapping
Int -> ReadS PortMapping
ReadS [PortMapping]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PortMapping]
$creadListPrec :: ReadPrec [PortMapping]
readPrec :: ReadPrec PortMapping
$creadPrec :: ReadPrec PortMapping
readList :: ReadS [PortMapping]
$creadList :: ReadS [PortMapping]
readsPrec :: Int -> ReadS PortMapping
$creadsPrec :: Int -> ReadS PortMapping
Prelude.Read, Int -> PortMapping -> ShowS
[PortMapping] -> ShowS
PortMapping -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PortMapping] -> ShowS
$cshowList :: [PortMapping] -> ShowS
show :: PortMapping -> String
$cshow :: PortMapping -> String
showsPrec :: Int -> PortMapping -> ShowS
$cshowsPrec :: Int -> PortMapping -> ShowS
Prelude.Show, forall x. Rep PortMapping x -> PortMapping
forall x. PortMapping -> Rep PortMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PortMapping x -> PortMapping
$cfrom :: forall x. PortMapping -> Rep PortMapping x
Prelude.Generic)
newPortMapping ::
Prelude.Natural ->
PortProtocol ->
PortMapping
newPortMapping :: Natural -> PortProtocol -> PortMapping
newPortMapping Natural
pPort_ PortProtocol
pProtocol_ =
PortMapping' {$sel:port:PortMapping' :: Natural
port = Natural
pPort_, $sel:protocol:PortMapping' :: PortProtocol
protocol = PortProtocol
pProtocol_}
portMapping_port :: Lens.Lens' PortMapping Prelude.Natural
portMapping_port :: Lens' PortMapping Natural
portMapping_port = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortMapping' {Natural
port :: Natural
$sel:port:PortMapping' :: PortMapping -> Natural
port} -> Natural
port) (\s :: PortMapping
s@PortMapping' {} Natural
a -> PortMapping
s {$sel:port:PortMapping' :: Natural
port = Natural
a} :: PortMapping)
portMapping_protocol :: Lens.Lens' PortMapping PortProtocol
portMapping_protocol :: Lens' PortMapping PortProtocol
portMapping_protocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PortMapping' {PortProtocol
protocol :: PortProtocol
$sel:protocol:PortMapping' :: PortMapping -> PortProtocol
protocol} -> PortProtocol
protocol) (\s :: PortMapping
s@PortMapping' {} PortProtocol
a -> PortMapping
s {$sel:protocol:PortMapping' :: PortProtocol
protocol = PortProtocol
a} :: PortMapping)
instance Data.FromJSON PortMapping where
parseJSON :: Value -> Parser PortMapping
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"PortMapping"
( \Object
x ->
Natural -> PortProtocol -> PortMapping
PortMapping'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"port")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"protocol")
)
instance Prelude.Hashable PortMapping where
hashWithSalt :: Int -> PortMapping -> Int
hashWithSalt Int
_salt PortMapping' {Natural
PortProtocol
protocol :: PortProtocol
port :: Natural
$sel:protocol:PortMapping' :: PortMapping -> PortProtocol
$sel:port:PortMapping' :: PortMapping -> Natural
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
port
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PortProtocol
protocol
instance Prelude.NFData PortMapping where
rnf :: PortMapping -> ()
rnf PortMapping' {Natural
PortProtocol
protocol :: PortProtocol
port :: Natural
$sel:protocol:PortMapping' :: PortMapping -> PortProtocol
$sel:port:PortMapping' :: PortMapping -> Natural
..} =
forall a. NFData a => a -> ()
Prelude.rnf Natural
port seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PortProtocol
protocol
instance Data.ToJSON PortMapping where
toJSON :: PortMapping -> Value
toJSON PortMapping' {Natural
PortProtocol
protocol :: PortProtocol
port :: Natural
$sel:protocol:PortMapping' :: PortMapping -> PortProtocol
$sel:port:PortMapping' :: PortMapping -> Natural
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"port" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
port),
forall a. a -> Maybe a
Prelude.Just (Key
"protocol" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= PortProtocol
protocol)
]
)