{-# 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.AwsEcsServiceLoadBalancersDetails
-- 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.AwsEcsServiceLoadBalancersDetails where

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

-- | Information about a load balancer that the service uses.
--
-- /See:/ 'newAwsEcsServiceLoadBalancersDetails' smart constructor.
data AwsEcsServiceLoadBalancersDetails = AwsEcsServiceLoadBalancersDetails'
  { -- | The name of the load balancer to associate with the Amazon ECS service
    -- or task set.
    --
    -- Only specified when using a Classic Load Balancer. For an Application
    -- Load Balancer or a Network Load Balancer, the load balancer name is
    -- omitted.
    AwsEcsServiceLoadBalancersDetails -> Maybe Text
loadBalancerName :: Prelude.Maybe Prelude.Text,
    -- | The name of the container to associate with the load balancer.
    AwsEcsServiceLoadBalancersDetails -> Maybe Text
containerName :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the Elastic Load Balancing target group or groups associated
    -- with a service or task set.
    --
    -- Only specified when using an Application Load Balancer or a Network Load
    -- Balancer. For a Classic Load Balancer, the target group ARN is omitted.
    AwsEcsServiceLoadBalancersDetails -> Maybe Text
targetGroupArn :: Prelude.Maybe Prelude.Text,
    -- | The port on the container to associate with the load balancer. This port
    -- must correspond to a @containerPort@ in the task definition the tasks in
    -- the service are using. For tasks that use the EC2 launch type, the
    -- container instance they are launched on must allow ingress traffic on
    -- the @hostPort@ of the port mapping.
    AwsEcsServiceLoadBalancersDetails -> Maybe Int
containerPort :: Prelude.Maybe Prelude.Int
  }
  deriving (AwsEcsServiceLoadBalancersDetails
-> AwsEcsServiceLoadBalancersDetails -> Bool
(AwsEcsServiceLoadBalancersDetails
 -> AwsEcsServiceLoadBalancersDetails -> Bool)
-> (AwsEcsServiceLoadBalancersDetails
    -> AwsEcsServiceLoadBalancersDetails -> Bool)
-> Eq AwsEcsServiceLoadBalancersDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsEcsServiceLoadBalancersDetails
-> AwsEcsServiceLoadBalancersDetails -> Bool
$c/= :: AwsEcsServiceLoadBalancersDetails
-> AwsEcsServiceLoadBalancersDetails -> Bool
== :: AwsEcsServiceLoadBalancersDetails
-> AwsEcsServiceLoadBalancersDetails -> Bool
$c== :: AwsEcsServiceLoadBalancersDetails
-> AwsEcsServiceLoadBalancersDetails -> Bool
Prelude.Eq, ReadPrec [AwsEcsServiceLoadBalancersDetails]
ReadPrec AwsEcsServiceLoadBalancersDetails
Int -> ReadS AwsEcsServiceLoadBalancersDetails
ReadS [AwsEcsServiceLoadBalancersDetails]
(Int -> ReadS AwsEcsServiceLoadBalancersDetails)
-> ReadS [AwsEcsServiceLoadBalancersDetails]
-> ReadPrec AwsEcsServiceLoadBalancersDetails
-> ReadPrec [AwsEcsServiceLoadBalancersDetails]
-> Read AwsEcsServiceLoadBalancersDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsEcsServiceLoadBalancersDetails]
$creadListPrec :: ReadPrec [AwsEcsServiceLoadBalancersDetails]
readPrec :: ReadPrec AwsEcsServiceLoadBalancersDetails
$creadPrec :: ReadPrec AwsEcsServiceLoadBalancersDetails
readList :: ReadS [AwsEcsServiceLoadBalancersDetails]
$creadList :: ReadS [AwsEcsServiceLoadBalancersDetails]
readsPrec :: Int -> ReadS AwsEcsServiceLoadBalancersDetails
$creadsPrec :: Int -> ReadS AwsEcsServiceLoadBalancersDetails
Prelude.Read, Int -> AwsEcsServiceLoadBalancersDetails -> ShowS
[AwsEcsServiceLoadBalancersDetails] -> ShowS
AwsEcsServiceLoadBalancersDetails -> String
(Int -> AwsEcsServiceLoadBalancersDetails -> ShowS)
-> (AwsEcsServiceLoadBalancersDetails -> String)
-> ([AwsEcsServiceLoadBalancersDetails] -> ShowS)
-> Show AwsEcsServiceLoadBalancersDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsEcsServiceLoadBalancersDetails] -> ShowS
$cshowList :: [AwsEcsServiceLoadBalancersDetails] -> ShowS
show :: AwsEcsServiceLoadBalancersDetails -> String
$cshow :: AwsEcsServiceLoadBalancersDetails -> String
showsPrec :: Int -> AwsEcsServiceLoadBalancersDetails -> ShowS
$cshowsPrec :: Int -> AwsEcsServiceLoadBalancersDetails -> ShowS
Prelude.Show, (forall x.
 AwsEcsServiceLoadBalancersDetails
 -> Rep AwsEcsServiceLoadBalancersDetails x)
-> (forall x.
    Rep AwsEcsServiceLoadBalancersDetails x
    -> AwsEcsServiceLoadBalancersDetails)
-> Generic AwsEcsServiceLoadBalancersDetails
forall x.
Rep AwsEcsServiceLoadBalancersDetails x
-> AwsEcsServiceLoadBalancersDetails
forall x.
AwsEcsServiceLoadBalancersDetails
-> Rep AwsEcsServiceLoadBalancersDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsEcsServiceLoadBalancersDetails x
-> AwsEcsServiceLoadBalancersDetails
$cfrom :: forall x.
AwsEcsServiceLoadBalancersDetails
-> Rep AwsEcsServiceLoadBalancersDetails x
Prelude.Generic)

-- |
-- Create a value of 'AwsEcsServiceLoadBalancersDetails' 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:
--
-- 'loadBalancerName', 'awsEcsServiceLoadBalancersDetails_loadBalancerName' - The name of the load balancer to associate with the Amazon ECS service
-- or task set.
--
-- Only specified when using a Classic Load Balancer. For an Application
-- Load Balancer or a Network Load Balancer, the load balancer name is
-- omitted.
--
-- 'containerName', 'awsEcsServiceLoadBalancersDetails_containerName' - The name of the container to associate with the load balancer.
--
-- 'targetGroupArn', 'awsEcsServiceLoadBalancersDetails_targetGroupArn' - The ARN of the Elastic Load Balancing target group or groups associated
-- with a service or task set.
--
-- Only specified when using an Application Load Balancer or a Network Load
-- Balancer. For a Classic Load Balancer, the target group ARN is omitted.
--
-- 'containerPort', 'awsEcsServiceLoadBalancersDetails_containerPort' - The port on the container to associate with the load balancer. This port
-- must correspond to a @containerPort@ in the task definition the tasks in
-- the service are using. For tasks that use the EC2 launch type, the
-- container instance they are launched on must allow ingress traffic on
-- the @hostPort@ of the port mapping.
newAwsEcsServiceLoadBalancersDetails ::
  AwsEcsServiceLoadBalancersDetails
newAwsEcsServiceLoadBalancersDetails :: AwsEcsServiceLoadBalancersDetails
newAwsEcsServiceLoadBalancersDetails =
  AwsEcsServiceLoadBalancersDetails' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> AwsEcsServiceLoadBalancersDetails
AwsEcsServiceLoadBalancersDetails'
    { $sel:loadBalancerName:AwsEcsServiceLoadBalancersDetails' :: Maybe Text
loadBalancerName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:containerName:AwsEcsServiceLoadBalancersDetails' :: Maybe Text
containerName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetGroupArn:AwsEcsServiceLoadBalancersDetails' :: Maybe Text
targetGroupArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:containerPort:AwsEcsServiceLoadBalancersDetails' :: Maybe Int
containerPort = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the load balancer to associate with the Amazon ECS service
-- or task set.
--
-- Only specified when using a Classic Load Balancer. For an Application
-- Load Balancer or a Network Load Balancer, the load balancer name is
-- omitted.
awsEcsServiceLoadBalancersDetails_loadBalancerName :: Lens.Lens' AwsEcsServiceLoadBalancersDetails (Prelude.Maybe Prelude.Text)
awsEcsServiceLoadBalancersDetails_loadBalancerName :: (Maybe Text -> f (Maybe Text))
-> AwsEcsServiceLoadBalancersDetails
-> f AwsEcsServiceLoadBalancersDetails
awsEcsServiceLoadBalancersDetails_loadBalancerName = (AwsEcsServiceLoadBalancersDetails -> Maybe Text)
-> (AwsEcsServiceLoadBalancersDetails
    -> Maybe Text -> AwsEcsServiceLoadBalancersDetails)
-> Lens
     AwsEcsServiceLoadBalancersDetails
     AwsEcsServiceLoadBalancersDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceLoadBalancersDetails' {Maybe Text
loadBalancerName :: Maybe Text
$sel:loadBalancerName:AwsEcsServiceLoadBalancersDetails' :: AwsEcsServiceLoadBalancersDetails -> Maybe Text
loadBalancerName} -> Maybe Text
loadBalancerName) (\s :: AwsEcsServiceLoadBalancersDetails
s@AwsEcsServiceLoadBalancersDetails' {} Maybe Text
a -> AwsEcsServiceLoadBalancersDetails
s {$sel:loadBalancerName:AwsEcsServiceLoadBalancersDetails' :: Maybe Text
loadBalancerName = Maybe Text
a} :: AwsEcsServiceLoadBalancersDetails)

-- | The name of the container to associate with the load balancer.
awsEcsServiceLoadBalancersDetails_containerName :: Lens.Lens' AwsEcsServiceLoadBalancersDetails (Prelude.Maybe Prelude.Text)
awsEcsServiceLoadBalancersDetails_containerName :: (Maybe Text -> f (Maybe Text))
-> AwsEcsServiceLoadBalancersDetails
-> f AwsEcsServiceLoadBalancersDetails
awsEcsServiceLoadBalancersDetails_containerName = (AwsEcsServiceLoadBalancersDetails -> Maybe Text)
-> (AwsEcsServiceLoadBalancersDetails
    -> Maybe Text -> AwsEcsServiceLoadBalancersDetails)
-> Lens
     AwsEcsServiceLoadBalancersDetails
     AwsEcsServiceLoadBalancersDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceLoadBalancersDetails' {Maybe Text
containerName :: Maybe Text
$sel:containerName:AwsEcsServiceLoadBalancersDetails' :: AwsEcsServiceLoadBalancersDetails -> Maybe Text
containerName} -> Maybe Text
containerName) (\s :: AwsEcsServiceLoadBalancersDetails
s@AwsEcsServiceLoadBalancersDetails' {} Maybe Text
a -> AwsEcsServiceLoadBalancersDetails
s {$sel:containerName:AwsEcsServiceLoadBalancersDetails' :: Maybe Text
containerName = Maybe Text
a} :: AwsEcsServiceLoadBalancersDetails)

-- | The ARN of the Elastic Load Balancing target group or groups associated
-- with a service or task set.
--
-- Only specified when using an Application Load Balancer or a Network Load
-- Balancer. For a Classic Load Balancer, the target group ARN is omitted.
awsEcsServiceLoadBalancersDetails_targetGroupArn :: Lens.Lens' AwsEcsServiceLoadBalancersDetails (Prelude.Maybe Prelude.Text)
awsEcsServiceLoadBalancersDetails_targetGroupArn :: (Maybe Text -> f (Maybe Text))
-> AwsEcsServiceLoadBalancersDetails
-> f AwsEcsServiceLoadBalancersDetails
awsEcsServiceLoadBalancersDetails_targetGroupArn = (AwsEcsServiceLoadBalancersDetails -> Maybe Text)
-> (AwsEcsServiceLoadBalancersDetails
    -> Maybe Text -> AwsEcsServiceLoadBalancersDetails)
-> Lens
     AwsEcsServiceLoadBalancersDetails
     AwsEcsServiceLoadBalancersDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceLoadBalancersDetails' {Maybe Text
targetGroupArn :: Maybe Text
$sel:targetGroupArn:AwsEcsServiceLoadBalancersDetails' :: AwsEcsServiceLoadBalancersDetails -> Maybe Text
targetGroupArn} -> Maybe Text
targetGroupArn) (\s :: AwsEcsServiceLoadBalancersDetails
s@AwsEcsServiceLoadBalancersDetails' {} Maybe Text
a -> AwsEcsServiceLoadBalancersDetails
s {$sel:targetGroupArn:AwsEcsServiceLoadBalancersDetails' :: Maybe Text
targetGroupArn = Maybe Text
a} :: AwsEcsServiceLoadBalancersDetails)

-- | The port on the container to associate with the load balancer. This port
-- must correspond to a @containerPort@ in the task definition the tasks in
-- the service are using. For tasks that use the EC2 launch type, the
-- container instance they are launched on must allow ingress traffic on
-- the @hostPort@ of the port mapping.
awsEcsServiceLoadBalancersDetails_containerPort :: Lens.Lens' AwsEcsServiceLoadBalancersDetails (Prelude.Maybe Prelude.Int)
awsEcsServiceLoadBalancersDetails_containerPort :: (Maybe Int -> f (Maybe Int))
-> AwsEcsServiceLoadBalancersDetails
-> f AwsEcsServiceLoadBalancersDetails
awsEcsServiceLoadBalancersDetails_containerPort = (AwsEcsServiceLoadBalancersDetails -> Maybe Int)
-> (AwsEcsServiceLoadBalancersDetails
    -> Maybe Int -> AwsEcsServiceLoadBalancersDetails)
-> Lens
     AwsEcsServiceLoadBalancersDetails
     AwsEcsServiceLoadBalancersDetails
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServiceLoadBalancersDetails' {Maybe Int
containerPort :: Maybe Int
$sel:containerPort:AwsEcsServiceLoadBalancersDetails' :: AwsEcsServiceLoadBalancersDetails -> Maybe Int
containerPort} -> Maybe Int
containerPort) (\s :: AwsEcsServiceLoadBalancersDetails
s@AwsEcsServiceLoadBalancersDetails' {} Maybe Int
a -> AwsEcsServiceLoadBalancersDetails
s {$sel:containerPort:AwsEcsServiceLoadBalancersDetails' :: Maybe Int
containerPort = Maybe Int
a} :: AwsEcsServiceLoadBalancersDetails)

instance
  Core.FromJSON
    AwsEcsServiceLoadBalancersDetails
  where
  parseJSON :: Value -> Parser AwsEcsServiceLoadBalancersDetails
parseJSON =
    String
-> (Object -> Parser AwsEcsServiceLoadBalancersDetails)
-> Value
-> Parser AwsEcsServiceLoadBalancersDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsEcsServiceLoadBalancersDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> AwsEcsServiceLoadBalancersDetails
AwsEcsServiceLoadBalancersDetails'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Int
 -> AwsEcsServiceLoadBalancersDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Int -> AwsEcsServiceLoadBalancersDetails)
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
"LoadBalancerName")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Int -> AwsEcsServiceLoadBalancersDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Int -> AwsEcsServiceLoadBalancersDetails)
forall (f :: * -> *) a b. Applicative f => 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
"ContainerName")
            Parser
  (Maybe Text -> Maybe Int -> AwsEcsServiceLoadBalancersDetails)
-> Parser (Maybe Text)
-> Parser (Maybe Int -> AwsEcsServiceLoadBalancersDetails)
forall (f :: * -> *) a b. Applicative f => 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
"TargetGroupArn")
            Parser (Maybe Int -> AwsEcsServiceLoadBalancersDetails)
-> Parser (Maybe Int) -> Parser AwsEcsServiceLoadBalancersDetails
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
    AwsEcsServiceLoadBalancersDetails

instance
  Prelude.NFData
    AwsEcsServiceLoadBalancersDetails

instance
  Core.ToJSON
    AwsEcsServiceLoadBalancersDetails
  where
  toJSON :: AwsEcsServiceLoadBalancersDetails -> Value
toJSON AwsEcsServiceLoadBalancersDetails' {Maybe Int
Maybe Text
containerPort :: Maybe Int
targetGroupArn :: Maybe Text
containerName :: Maybe Text
loadBalancerName :: Maybe Text
$sel:containerPort:AwsEcsServiceLoadBalancersDetails' :: AwsEcsServiceLoadBalancersDetails -> Maybe Int
$sel:targetGroupArn:AwsEcsServiceLoadBalancersDetails' :: AwsEcsServiceLoadBalancersDetails -> Maybe Text
$sel:containerName:AwsEcsServiceLoadBalancersDetails' :: AwsEcsServiceLoadBalancersDetails -> Maybe Text
$sel:loadBalancerName:AwsEcsServiceLoadBalancersDetails' :: AwsEcsServiceLoadBalancersDetails -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"LoadBalancerName" 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
loadBalancerName,
            (Text
"ContainerName" 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
containerName,
            (Text
"TargetGroupArn" 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
targetGroupArn,
            (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
          ]
      )