{-# 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.SimulationAppEndpointInfo
-- 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.SimulationAppEndpointInfo 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
import Amazonka.SimSpaceWeaver.Types.SimulationAppPortMapping

-- | Information about the network endpoint that you can use to connect to
-- your custom or service app.
--
-- /See:/ 'newSimulationAppEndpointInfo' smart constructor.
data SimulationAppEndpointInfo = SimulationAppEndpointInfo'
  { -- | The IP address of the app. SimSpace Weaver dynamically assigns this IP
    -- address when the app starts.
    SimulationAppEndpointInfo -> Maybe Text
address :: Prelude.Maybe Prelude.Text,
    -- | The inbound TCP\/UDP port numbers of the app. The combination of an IP
    -- address and a port number form a network endpoint.
    SimulationAppEndpointInfo -> Maybe [SimulationAppPortMapping]
ingressPortMappings :: Prelude.Maybe [SimulationAppPortMapping]
  }
  deriving (SimulationAppEndpointInfo -> SimulationAppEndpointInfo -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SimulationAppEndpointInfo -> SimulationAppEndpointInfo -> Bool
$c/= :: SimulationAppEndpointInfo -> SimulationAppEndpointInfo -> Bool
== :: SimulationAppEndpointInfo -> SimulationAppEndpointInfo -> Bool
$c== :: SimulationAppEndpointInfo -> SimulationAppEndpointInfo -> Bool
Prelude.Eq, ReadPrec [SimulationAppEndpointInfo]
ReadPrec SimulationAppEndpointInfo
Int -> ReadS SimulationAppEndpointInfo
ReadS [SimulationAppEndpointInfo]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SimulationAppEndpointInfo]
$creadListPrec :: ReadPrec [SimulationAppEndpointInfo]
readPrec :: ReadPrec SimulationAppEndpointInfo
$creadPrec :: ReadPrec SimulationAppEndpointInfo
readList :: ReadS [SimulationAppEndpointInfo]
$creadList :: ReadS [SimulationAppEndpointInfo]
readsPrec :: Int -> ReadS SimulationAppEndpointInfo
$creadsPrec :: Int -> ReadS SimulationAppEndpointInfo
Prelude.Read, Int -> SimulationAppEndpointInfo -> ShowS
[SimulationAppEndpointInfo] -> ShowS
SimulationAppEndpointInfo -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SimulationAppEndpointInfo] -> ShowS
$cshowList :: [SimulationAppEndpointInfo] -> ShowS
show :: SimulationAppEndpointInfo -> String
$cshow :: SimulationAppEndpointInfo -> String
showsPrec :: Int -> SimulationAppEndpointInfo -> ShowS
$cshowsPrec :: Int -> SimulationAppEndpointInfo -> ShowS
Prelude.Show, forall x.
Rep SimulationAppEndpointInfo x -> SimulationAppEndpointInfo
forall x.
SimulationAppEndpointInfo -> Rep SimulationAppEndpointInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SimulationAppEndpointInfo x -> SimulationAppEndpointInfo
$cfrom :: forall x.
SimulationAppEndpointInfo -> Rep SimulationAppEndpointInfo x
Prelude.Generic)

-- |
-- Create a value of 'SimulationAppEndpointInfo' 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:
--
-- 'address', 'simulationAppEndpointInfo_address' - The IP address of the app. SimSpace Weaver dynamically assigns this IP
-- address when the app starts.
--
-- 'ingressPortMappings', 'simulationAppEndpointInfo_ingressPortMappings' - The inbound TCP\/UDP port numbers of the app. The combination of an IP
-- address and a port number form a network endpoint.
newSimulationAppEndpointInfo ::
  SimulationAppEndpointInfo
newSimulationAppEndpointInfo :: SimulationAppEndpointInfo
newSimulationAppEndpointInfo =
  SimulationAppEndpointInfo'
    { $sel:address:SimulationAppEndpointInfo' :: Maybe Text
address =
        forall a. Maybe a
Prelude.Nothing,
      $sel:ingressPortMappings:SimulationAppEndpointInfo' :: Maybe [SimulationAppPortMapping]
ingressPortMappings = forall a. Maybe a
Prelude.Nothing
    }

-- | The IP address of the app. SimSpace Weaver dynamically assigns this IP
-- address when the app starts.
simulationAppEndpointInfo_address :: Lens.Lens' SimulationAppEndpointInfo (Prelude.Maybe Prelude.Text)
simulationAppEndpointInfo_address :: Lens' SimulationAppEndpointInfo (Maybe Text)
simulationAppEndpointInfo_address = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimulationAppEndpointInfo' {Maybe Text
address :: Maybe Text
$sel:address:SimulationAppEndpointInfo' :: SimulationAppEndpointInfo -> Maybe Text
address} -> Maybe Text
address) (\s :: SimulationAppEndpointInfo
s@SimulationAppEndpointInfo' {} Maybe Text
a -> SimulationAppEndpointInfo
s {$sel:address:SimulationAppEndpointInfo' :: Maybe Text
address = Maybe Text
a} :: SimulationAppEndpointInfo)

-- | The inbound TCP\/UDP port numbers of the app. The combination of an IP
-- address and a port number form a network endpoint.
simulationAppEndpointInfo_ingressPortMappings :: Lens.Lens' SimulationAppEndpointInfo (Prelude.Maybe [SimulationAppPortMapping])
simulationAppEndpointInfo_ingressPortMappings :: Lens' SimulationAppEndpointInfo (Maybe [SimulationAppPortMapping])
simulationAppEndpointInfo_ingressPortMappings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SimulationAppEndpointInfo' {Maybe [SimulationAppPortMapping]
ingressPortMappings :: Maybe [SimulationAppPortMapping]
$sel:ingressPortMappings:SimulationAppEndpointInfo' :: SimulationAppEndpointInfo -> Maybe [SimulationAppPortMapping]
ingressPortMappings} -> Maybe [SimulationAppPortMapping]
ingressPortMappings) (\s :: SimulationAppEndpointInfo
s@SimulationAppEndpointInfo' {} Maybe [SimulationAppPortMapping]
a -> SimulationAppEndpointInfo
s {$sel:ingressPortMappings:SimulationAppEndpointInfo' :: Maybe [SimulationAppPortMapping]
ingressPortMappings = Maybe [SimulationAppPortMapping]
a} :: SimulationAppEndpointInfo) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON SimulationAppEndpointInfo where
  parseJSON :: Value -> Parser SimulationAppEndpointInfo
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SimulationAppEndpointInfo"
      ( \Object
x ->
          Maybe Text
-> Maybe [SimulationAppPortMapping] -> SimulationAppEndpointInfo
SimulationAppEndpointInfo'
            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
"Address")
            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
"IngressPortMappings"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable SimulationAppEndpointInfo where
  hashWithSalt :: Int -> SimulationAppEndpointInfo -> Int
hashWithSalt Int
_salt SimulationAppEndpointInfo' {Maybe [SimulationAppPortMapping]
Maybe Text
ingressPortMappings :: Maybe [SimulationAppPortMapping]
address :: Maybe Text
$sel:ingressPortMappings:SimulationAppEndpointInfo' :: SimulationAppEndpointInfo -> Maybe [SimulationAppPortMapping]
$sel:address:SimulationAppEndpointInfo' :: SimulationAppEndpointInfo -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
address
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [SimulationAppPortMapping]
ingressPortMappings

instance Prelude.NFData SimulationAppEndpointInfo where
  rnf :: SimulationAppEndpointInfo -> ()
rnf SimulationAppEndpointInfo' {Maybe [SimulationAppPortMapping]
Maybe Text
ingressPortMappings :: Maybe [SimulationAppPortMapping]
address :: Maybe Text
$sel:ingressPortMappings:SimulationAppEndpointInfo' :: SimulationAppEndpointInfo -> Maybe [SimulationAppPortMapping]
$sel:address:SimulationAppEndpointInfo' :: SimulationAppEndpointInfo -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
address
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [SimulationAppPortMapping]
ingressPortMappings