{-# 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.SecurityHub.Types.AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SecurityHub.Types.AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A port mapping for the container.
--
-- /See:/ 'newAwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' smart constructor.
data AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails = AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails'
  { -- | The protocol used for the port mapping. The default is @tcp@.
    AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Maybe Text
protocol :: Prelude.Maybe Prelude.Text,
    -- | The port number on the container instance to reserve for the container.
    AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Maybe Int
hostPort :: Prelude.Maybe Prelude.Int,
    -- | The port number on the container that is bound to the user-specified or
    -- automatically assigned host port.
    AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Maybe Int
containerPort :: Prelude.Maybe Prelude.Int
  }
  deriving (AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Bool
(AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
 -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
 -> Bool)
-> (AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
    -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
    -> Bool)
-> Eq AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Bool
$c/= :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Bool
== :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Bool
$c== :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Bool
Prelude.Eq, ReadPrec
  [AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
ReadPrec
  AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
Int
-> ReadS
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
ReadS [AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
(Int
 -> ReadS
      AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)
-> ReadS
     [AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
-> ReadPrec
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> ReadPrec
     [AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
-> Read AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec
  [AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
$creadListPrec :: ReadPrec
  [AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
readPrec :: ReadPrec
  AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
$creadPrec :: ReadPrec
  AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
readList :: ReadS [AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
$creadList :: ReadS [AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
readsPrec :: Int
-> ReadS
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
$creadsPrec :: Int
-> ReadS
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
Prelude.Read, Int
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> ShowS
[AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
-> ShowS
AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> String
(Int
 -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
 -> ShowS)
-> (AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
    -> String)
-> ([AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
    -> ShowS)
-> Show AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
-> ShowS
$cshowList :: [AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails]
-> ShowS
show :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> String
$cshow :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> String
showsPrec :: Int
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> ShowS
$cshowsPrec :: Int
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> ShowS
Prelude.Show, (forall x.
 AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
 -> Rep
      AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails x)
-> (forall x.
    Rep AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails x
    -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)
-> Generic
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
forall x.
Rep AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails x
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
forall x.
AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Rep
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails x
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
$cfrom :: forall x.
AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Rep
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails x
Prelude.Generic)

-- |
-- Create a value of 'AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' 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:
--
-- 'protocol', 'awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_protocol' - The protocol used for the port mapping. The default is @tcp@.
--
-- 'hostPort', 'awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_hostPort' - The port number on the container instance to reserve for the container.
--
-- 'containerPort', 'awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_containerPort' - The port number on the container that is bound to the user-specified or
-- automatically assigned host port.
newAwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails ::
  AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
newAwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
newAwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails =
  AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: Maybe Text
-> Maybe Int
-> Maybe Int
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails'
    { $sel:protocol:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: Maybe Text
protocol =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:hostPort:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: Maybe Int
hostPort =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:containerPort:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: Maybe Int
containerPort =
        Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The protocol used for the port mapping. The default is @tcp@.
awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_protocol :: Lens.Lens' AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails (Prelude.Maybe Prelude.Text)
awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_protocol :: (Maybe Text -> f (Maybe Text))
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> f AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_protocol = (AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
 -> Maybe Text)
-> (AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
    -> Maybe Text
    -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)
-> Lens
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' {Maybe Text
protocol :: Maybe Text
$sel:protocol:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Maybe Text
protocol} -> Maybe Text
protocol) (\s :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
s@AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' {} Maybe Text
a -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
s {$sel:protocol:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: Maybe Text
protocol = Maybe Text
a} :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)

-- | The port number on the container instance to reserve for the container.
awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_hostPort :: Lens.Lens' AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails (Prelude.Maybe Prelude.Int)
awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_hostPort :: (Maybe Int -> f (Maybe Int))
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> f AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_hostPort = (AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
 -> Maybe Int)
-> (AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
    -> Maybe Int
    -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)
-> Lens
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' {Maybe Int
hostPort :: Maybe Int
$sel:hostPort:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Maybe Int
hostPort} -> Maybe Int
hostPort) (\s :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
s@AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' {} Maybe Int
a -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
s {$sel:hostPort:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: Maybe Int
hostPort = Maybe Int
a} :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)

-- | The port number on the container that is bound to the user-specified or
-- automatically assigned host port.
awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_containerPort :: Lens.Lens' AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails (Prelude.Maybe Prelude.Int)
awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_containerPort :: (Maybe Int -> f (Maybe Int))
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> f AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
awsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails_containerPort = (AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
 -> Maybe Int)
-> (AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
    -> Maybe Int
    -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)
-> Lens
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' {Maybe Int
containerPort :: Maybe Int
$sel:containerPort:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Maybe Int
containerPort} -> Maybe Int
containerPort) (\s :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
s@AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' {} Maybe Int
a -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
s {$sel:containerPort:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: Maybe Int
containerPort = Maybe Int
a} :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)

instance
  Core.FromJSON
    AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
  where
  parseJSON :: Value
-> Parser
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
parseJSON =
    String
-> (Object
    -> Parser
         AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)
-> Value
-> Parser
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe Int
-> Maybe Int
-> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails'
            (Maybe Text
 -> Maybe Int
 -> Maybe Int
 -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Int
      -> Maybe Int
      -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Protocol")
              Parser
  (Maybe Int
   -> Maybe Int
   -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)
-> Parser (Maybe Int)
-> Parser
     (Maybe Int
      -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)
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
"HostPort")
              Parser
  (Maybe Int
   -> AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails)
-> Parser (Maybe Int)
-> Parser
     AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
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
"ContainerPort")
      )

instance
  Prelude.Hashable
    AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails

instance
  Prelude.NFData
    AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails

instance
  Core.ToJSON
    AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
  where
  toJSON :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Value
toJSON
    AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' {Maybe Int
Maybe Text
containerPort :: Maybe Int
hostPort :: Maybe Int
protocol :: Maybe Text
$sel:containerPort:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Maybe Int
$sel:hostPort:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Maybe Int
$sel:protocol:AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails' :: AwsEcsTaskDefinitionContainerDefinitionsPortMappingsDetails
-> Maybe Text
..} =
      [Pair] -> Value
Core.object
        ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (Text
"Protocol" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
protocol,
              (Text
"HostPort" 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
hostPort,
              (Text
"ContainerPort" 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
containerPort
            ]
        )