{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SimSpaceWeaver.Types.SimulationAppPortMapping
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SimSpaceWeaver.Types.SimulationAppPortMapping where

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

-- | A collection of TCP\/UDP ports for a custom or service app.
--
-- /See:/ 'newSimulationAppPortMapping' smart constructor.
data SimulationAppPortMapping = SimulationAppPortMapping'
  { -- | The TCP\/UDP port number of the running app. SimSpace Weaver dynamically
    -- assigns this port number when the app starts. SimSpace Weaver maps the
    -- @Declared@ port to the @Actual@ port. Clients connect to the app using
    -- the app\'s IP address and the @Actual@ port number.
    SimulationAppPortMapping -> Maybe Natural
actual :: Prelude.Maybe Prelude.Natural,
    -- | The TCP\/UDP port number of the app, declared in the simulation schema.
    -- SimSpace Weaver maps the @Declared@ port to the @Actual@ port. The
    -- source code for the app should bind to the @Declared@ port.
    SimulationAppPortMapping -> Maybe Natural
declared :: Prelude.Maybe Prelude.Natural
  }
  deriving (SimulationAppPortMapping -> SimulationAppPortMapping -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SimulationAppPortMapping -> SimulationAppPortMapping -> Bool
$c/= :: SimulationAppPortMapping -> SimulationAppPortMapping -> Bool
== :: SimulationAppPortMapping -> SimulationAppPortMapping -> Bool
$c== :: SimulationAppPortMapping -> SimulationAppPortMapping -> Bool
Prelude.Eq, ReadPrec [SimulationAppPortMapping]
ReadPrec SimulationAppPortMapping
Int -> ReadS SimulationAppPortMapping
ReadS [SimulationAppPortMapping]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SimulationAppPortMapping]
$creadListPrec :: ReadPrec [SimulationAppPortMapping]
readPrec :: ReadPrec SimulationAppPortMapping
$creadPrec :: ReadPrec SimulationAppPortMapping
readList :: ReadS [SimulationAppPortMapping]
$creadList :: ReadS [SimulationAppPortMapping]
readsPrec :: Int -> ReadS SimulationAppPortMapping
$creadsPrec :: Int -> ReadS SimulationAppPortMapping
Prelude.Read, Int -> SimulationAppPortMapping -> ShowS
[SimulationAppPortMapping] -> ShowS
SimulationAppPortMapping -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SimulationAppPortMapping] -> ShowS
$cshowList :: [SimulationAppPortMapping] -> ShowS
show :: SimulationAppPortMapping -> String
$cshow :: SimulationAppPortMapping -> String
showsPrec :: Int -> SimulationAppPortMapping -> ShowS
$cshowsPrec :: Int -> SimulationAppPortMapping -> ShowS
Prelude.Show, forall x.
Rep SimulationAppPortMapping x -> SimulationAppPortMapping
forall x.
SimulationAppPortMapping -> Rep SimulationAppPortMapping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SimulationAppPortMapping x -> SimulationAppPortMapping
$cfrom :: forall x.
SimulationAppPortMapping -> Rep SimulationAppPortMapping x
Prelude.Generic)

-- |
-- Create a value of 'SimulationAppPortMapping' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'actual', 'simulationAppPortMapping_actual' - The TCP\/UDP port number of the running app. SimSpace Weaver dynamically
-- assigns this port number when the app starts. SimSpace Weaver maps the
-- @Declared@ port to the @Actual@ port. Clients connect to the app using
-- the app\'s IP address and the @Actual@ port number.
--
-- 'declared', 'simulationAppPortMapping_declared' - The TCP\/UDP port number of the app, declared in the simulation schema.
-- SimSpace Weaver maps the @Declared@ port to the @Actual@ port. The
-- source code for the app should bind to the @Declared@ port.
newSimulationAppPortMapping ::
  SimulationAppPortMapping
newSimulationAppPortMapping :: SimulationAppPortMapping
newSimulationAppPortMapping =
  SimulationAppPortMapping'
    { $sel:actual:SimulationAppPortMapping' :: Maybe Natural
actual = forall a. Maybe a
Prelude.Nothing,
      $sel:declared:SimulationAppPortMapping' :: Maybe Natural
declared = forall a. Maybe a
Prelude.Nothing
    }

-- | The TCP\/UDP port number of the running app. SimSpace Weaver dynamically
-- assigns this port number when the app starts. SimSpace Weaver maps the
-- @Declared@ port to the @Actual@ port. Clients connect to the app using
-- the app\'s IP address and the @Actual@ port number.
simulationAppPortMapping_actual :: Lens.Lens' SimulationAppPortMapping (Prelude.Maybe Prelude.Natural)
simulationAppPortMapping_actual :: Lens' SimulationAppPortMapping (Maybe Natural)
simulationAppPortMapping_actual = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimulationAppPortMapping' {Maybe Natural
actual :: Maybe Natural
$sel:actual:SimulationAppPortMapping' :: SimulationAppPortMapping -> Maybe Natural
actual} -> Maybe Natural
actual) (\s :: SimulationAppPortMapping
s@SimulationAppPortMapping' {} Maybe Natural
a -> SimulationAppPortMapping
s {$sel:actual:SimulationAppPortMapping' :: Maybe Natural
actual = Maybe Natural
a} :: SimulationAppPortMapping)

-- | The TCP\/UDP port number of the app, declared in the simulation schema.
-- SimSpace Weaver maps the @Declared@ port to the @Actual@ port. The
-- source code for the app should bind to the @Declared@ port.
simulationAppPortMapping_declared :: Lens.Lens' SimulationAppPortMapping (Prelude.Maybe Prelude.Natural)
simulationAppPortMapping_declared :: Lens' SimulationAppPortMapping (Maybe Natural)
simulationAppPortMapping_declared = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimulationAppPortMapping' {Maybe Natural
declared :: Maybe Natural
$sel:declared:SimulationAppPortMapping' :: SimulationAppPortMapping -> Maybe Natural
declared} -> Maybe Natural
declared) (\s :: SimulationAppPortMapping
s@SimulationAppPortMapping' {} Maybe Natural
a -> SimulationAppPortMapping
s {$sel:declared:SimulationAppPortMapping' :: Maybe Natural
declared = Maybe Natural
a} :: SimulationAppPortMapping)

instance Data.FromJSON SimulationAppPortMapping where
  parseJSON :: Value -> Parser SimulationAppPortMapping
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SimulationAppPortMapping"
      ( \Object
x ->
          Maybe Natural -> Maybe Natural -> SimulationAppPortMapping
SimulationAppPortMapping'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Actual")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Declared")
      )

instance Prelude.Hashable SimulationAppPortMapping where
  hashWithSalt :: Int -> SimulationAppPortMapping -> Int
hashWithSalt Int
_salt SimulationAppPortMapping' {Maybe Natural
declared :: Maybe Natural
actual :: Maybe Natural
$sel:declared:SimulationAppPortMapping' :: SimulationAppPortMapping -> Maybe Natural
$sel:actual:SimulationAppPortMapping' :: SimulationAppPortMapping -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
actual
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
declared

instance Prelude.NFData SimulationAppPortMapping where
  rnf :: SimulationAppPortMapping -> ()
rnf SimulationAppPortMapping' {Maybe Natural
declared :: Maybe Natural
actual :: Maybe Natural
$sel:declared:SimulationAppPortMapping' :: SimulationAppPortMapping -> Maybe Natural
$sel:actual:SimulationAppPortMapping' :: SimulationAppPortMapping -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
actual
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
declared