{-# 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.CodeDeploy.Types.LoadBalancerInfo
-- 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.CodeDeploy.Types.LoadBalancerInfo where

import Amazonka.CodeDeploy.Types.ELBInfo
import Amazonka.CodeDeploy.Types.TargetGroupInfo
import Amazonka.CodeDeploy.Types.TargetGroupPairInfo
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the Elastic Load Balancing load balancer or target
-- group used in a deployment.
--
-- /See:/ 'newLoadBalancerInfo' smart constructor.
data LoadBalancerInfo = LoadBalancerInfo'
  { -- | An array that contains information about the load balancer to use for
    -- load balancing in a deployment. In Elastic Load Balancing, load
    -- balancers are used with Classic Load Balancers.
    --
    -- Adding more than one load balancer to the array is not supported.
    LoadBalancerInfo -> Maybe [ELBInfo]
elbInfoList :: Prelude.Maybe [ELBInfo],
    -- | An array that contains information about the target group to use for
    -- load balancing in a deployment. In Elastic Load Balancing, target groups
    -- are used with Application Load Balancers.
    --
    -- Adding more than one target group to the array is not supported.
    LoadBalancerInfo -> Maybe [TargetGroupInfo]
targetGroupInfoList :: Prelude.Maybe [TargetGroupInfo],
    -- | The target group pair information. This is an array of
    -- @TargeGroupPairInfo@ objects with a maximum size of one.
    LoadBalancerInfo -> Maybe [TargetGroupPairInfo]
targetGroupPairInfoList :: Prelude.Maybe [TargetGroupPairInfo]
  }
  deriving (LoadBalancerInfo -> LoadBalancerInfo -> Bool
(LoadBalancerInfo -> LoadBalancerInfo -> Bool)
-> (LoadBalancerInfo -> LoadBalancerInfo -> Bool)
-> Eq LoadBalancerInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoadBalancerInfo -> LoadBalancerInfo -> Bool
$c/= :: LoadBalancerInfo -> LoadBalancerInfo -> Bool
== :: LoadBalancerInfo -> LoadBalancerInfo -> Bool
$c== :: LoadBalancerInfo -> LoadBalancerInfo -> Bool
Prelude.Eq, ReadPrec [LoadBalancerInfo]
ReadPrec LoadBalancerInfo
Int -> ReadS LoadBalancerInfo
ReadS [LoadBalancerInfo]
(Int -> ReadS LoadBalancerInfo)
-> ReadS [LoadBalancerInfo]
-> ReadPrec LoadBalancerInfo
-> ReadPrec [LoadBalancerInfo]
-> Read LoadBalancerInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoadBalancerInfo]
$creadListPrec :: ReadPrec [LoadBalancerInfo]
readPrec :: ReadPrec LoadBalancerInfo
$creadPrec :: ReadPrec LoadBalancerInfo
readList :: ReadS [LoadBalancerInfo]
$creadList :: ReadS [LoadBalancerInfo]
readsPrec :: Int -> ReadS LoadBalancerInfo
$creadsPrec :: Int -> ReadS LoadBalancerInfo
Prelude.Read, Int -> LoadBalancerInfo -> ShowS
[LoadBalancerInfo] -> ShowS
LoadBalancerInfo -> String
(Int -> LoadBalancerInfo -> ShowS)
-> (LoadBalancerInfo -> String)
-> ([LoadBalancerInfo] -> ShowS)
-> Show LoadBalancerInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoadBalancerInfo] -> ShowS
$cshowList :: [LoadBalancerInfo] -> ShowS
show :: LoadBalancerInfo -> String
$cshow :: LoadBalancerInfo -> String
showsPrec :: Int -> LoadBalancerInfo -> ShowS
$cshowsPrec :: Int -> LoadBalancerInfo -> ShowS
Prelude.Show, (forall x. LoadBalancerInfo -> Rep LoadBalancerInfo x)
-> (forall x. Rep LoadBalancerInfo x -> LoadBalancerInfo)
-> Generic LoadBalancerInfo
forall x. Rep LoadBalancerInfo x -> LoadBalancerInfo
forall x. LoadBalancerInfo -> Rep LoadBalancerInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoadBalancerInfo x -> LoadBalancerInfo
$cfrom :: forall x. LoadBalancerInfo -> Rep LoadBalancerInfo x
Prelude.Generic)

-- |
-- Create a value of 'LoadBalancerInfo' 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:
--
-- 'elbInfoList', 'loadBalancerInfo_elbInfoList' - An array that contains information about the load balancer to use for
-- load balancing in a deployment. In Elastic Load Balancing, load
-- balancers are used with Classic Load Balancers.
--
-- Adding more than one load balancer to the array is not supported.
--
-- 'targetGroupInfoList', 'loadBalancerInfo_targetGroupInfoList' - An array that contains information about the target group to use for
-- load balancing in a deployment. In Elastic Load Balancing, target groups
-- are used with Application Load Balancers.
--
-- Adding more than one target group to the array is not supported.
--
-- 'targetGroupPairInfoList', 'loadBalancerInfo_targetGroupPairInfoList' - The target group pair information. This is an array of
-- @TargeGroupPairInfo@ objects with a maximum size of one.
newLoadBalancerInfo ::
  LoadBalancerInfo
newLoadBalancerInfo :: LoadBalancerInfo
newLoadBalancerInfo =
  LoadBalancerInfo' :: Maybe [ELBInfo]
-> Maybe [TargetGroupInfo]
-> Maybe [TargetGroupPairInfo]
-> LoadBalancerInfo
LoadBalancerInfo'
    { $sel:elbInfoList:LoadBalancerInfo' :: Maybe [ELBInfo]
elbInfoList = Maybe [ELBInfo]
forall a. Maybe a
Prelude.Nothing,
      $sel:targetGroupInfoList:LoadBalancerInfo' :: Maybe [TargetGroupInfo]
targetGroupInfoList = Maybe [TargetGroupInfo]
forall a. Maybe a
Prelude.Nothing,
      $sel:targetGroupPairInfoList:LoadBalancerInfo' :: Maybe [TargetGroupPairInfo]
targetGroupPairInfoList = Maybe [TargetGroupPairInfo]
forall a. Maybe a
Prelude.Nothing
    }

-- | An array that contains information about the load balancer to use for
-- load balancing in a deployment. In Elastic Load Balancing, load
-- balancers are used with Classic Load Balancers.
--
-- Adding more than one load balancer to the array is not supported.
loadBalancerInfo_elbInfoList :: Lens.Lens' LoadBalancerInfo (Prelude.Maybe [ELBInfo])
loadBalancerInfo_elbInfoList :: (Maybe [ELBInfo] -> f (Maybe [ELBInfo]))
-> LoadBalancerInfo -> f LoadBalancerInfo
loadBalancerInfo_elbInfoList = (LoadBalancerInfo -> Maybe [ELBInfo])
-> (LoadBalancerInfo -> Maybe [ELBInfo] -> LoadBalancerInfo)
-> Lens
     LoadBalancerInfo
     LoadBalancerInfo
     (Maybe [ELBInfo])
     (Maybe [ELBInfo])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBalancerInfo' {Maybe [ELBInfo]
elbInfoList :: Maybe [ELBInfo]
$sel:elbInfoList:LoadBalancerInfo' :: LoadBalancerInfo -> Maybe [ELBInfo]
elbInfoList} -> Maybe [ELBInfo]
elbInfoList) (\s :: LoadBalancerInfo
s@LoadBalancerInfo' {} Maybe [ELBInfo]
a -> LoadBalancerInfo
s {$sel:elbInfoList:LoadBalancerInfo' :: Maybe [ELBInfo]
elbInfoList = Maybe [ELBInfo]
a} :: LoadBalancerInfo) ((Maybe [ELBInfo] -> f (Maybe [ELBInfo]))
 -> LoadBalancerInfo -> f LoadBalancerInfo)
-> ((Maybe [ELBInfo] -> f (Maybe [ELBInfo]))
    -> Maybe [ELBInfo] -> f (Maybe [ELBInfo]))
-> (Maybe [ELBInfo] -> f (Maybe [ELBInfo]))
-> LoadBalancerInfo
-> f LoadBalancerInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [ELBInfo] [ELBInfo] [ELBInfo] [ELBInfo]
-> Iso
     (Maybe [ELBInfo])
     (Maybe [ELBInfo])
     (Maybe [ELBInfo])
     (Maybe [ELBInfo])
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 AnIso [ELBInfo] [ELBInfo] [ELBInfo] [ELBInfo]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array that contains information about the target group to use for
-- load balancing in a deployment. In Elastic Load Balancing, target groups
-- are used with Application Load Balancers.
--
-- Adding more than one target group to the array is not supported.
loadBalancerInfo_targetGroupInfoList :: Lens.Lens' LoadBalancerInfo (Prelude.Maybe [TargetGroupInfo])
loadBalancerInfo_targetGroupInfoList :: (Maybe [TargetGroupInfo] -> f (Maybe [TargetGroupInfo]))
-> LoadBalancerInfo -> f LoadBalancerInfo
loadBalancerInfo_targetGroupInfoList = (LoadBalancerInfo -> Maybe [TargetGroupInfo])
-> (LoadBalancerInfo
    -> Maybe [TargetGroupInfo] -> LoadBalancerInfo)
-> Lens
     LoadBalancerInfo
     LoadBalancerInfo
     (Maybe [TargetGroupInfo])
     (Maybe [TargetGroupInfo])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBalancerInfo' {Maybe [TargetGroupInfo]
targetGroupInfoList :: Maybe [TargetGroupInfo]
$sel:targetGroupInfoList:LoadBalancerInfo' :: LoadBalancerInfo -> Maybe [TargetGroupInfo]
targetGroupInfoList} -> Maybe [TargetGroupInfo]
targetGroupInfoList) (\s :: LoadBalancerInfo
s@LoadBalancerInfo' {} Maybe [TargetGroupInfo]
a -> LoadBalancerInfo
s {$sel:targetGroupInfoList:LoadBalancerInfo' :: Maybe [TargetGroupInfo]
targetGroupInfoList = Maybe [TargetGroupInfo]
a} :: LoadBalancerInfo) ((Maybe [TargetGroupInfo] -> f (Maybe [TargetGroupInfo]))
 -> LoadBalancerInfo -> f LoadBalancerInfo)
-> ((Maybe [TargetGroupInfo] -> f (Maybe [TargetGroupInfo]))
    -> Maybe [TargetGroupInfo] -> f (Maybe [TargetGroupInfo]))
-> (Maybe [TargetGroupInfo] -> f (Maybe [TargetGroupInfo]))
-> LoadBalancerInfo
-> f LoadBalancerInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [TargetGroupInfo]
  [TargetGroupInfo]
  [TargetGroupInfo]
  [TargetGroupInfo]
-> Iso
     (Maybe [TargetGroupInfo])
     (Maybe [TargetGroupInfo])
     (Maybe [TargetGroupInfo])
     (Maybe [TargetGroupInfo])
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 AnIso
  [TargetGroupInfo]
  [TargetGroupInfo]
  [TargetGroupInfo]
  [TargetGroupInfo]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The target group pair information. This is an array of
-- @TargeGroupPairInfo@ objects with a maximum size of one.
loadBalancerInfo_targetGroupPairInfoList :: Lens.Lens' LoadBalancerInfo (Prelude.Maybe [TargetGroupPairInfo])
loadBalancerInfo_targetGroupPairInfoList :: (Maybe [TargetGroupPairInfo] -> f (Maybe [TargetGroupPairInfo]))
-> LoadBalancerInfo -> f LoadBalancerInfo
loadBalancerInfo_targetGroupPairInfoList = (LoadBalancerInfo -> Maybe [TargetGroupPairInfo])
-> (LoadBalancerInfo
    -> Maybe [TargetGroupPairInfo] -> LoadBalancerInfo)
-> Lens
     LoadBalancerInfo
     LoadBalancerInfo
     (Maybe [TargetGroupPairInfo])
     (Maybe [TargetGroupPairInfo])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBalancerInfo' {Maybe [TargetGroupPairInfo]
targetGroupPairInfoList :: Maybe [TargetGroupPairInfo]
$sel:targetGroupPairInfoList:LoadBalancerInfo' :: LoadBalancerInfo -> Maybe [TargetGroupPairInfo]
targetGroupPairInfoList} -> Maybe [TargetGroupPairInfo]
targetGroupPairInfoList) (\s :: LoadBalancerInfo
s@LoadBalancerInfo' {} Maybe [TargetGroupPairInfo]
a -> LoadBalancerInfo
s {$sel:targetGroupPairInfoList:LoadBalancerInfo' :: Maybe [TargetGroupPairInfo]
targetGroupPairInfoList = Maybe [TargetGroupPairInfo]
a} :: LoadBalancerInfo) ((Maybe [TargetGroupPairInfo] -> f (Maybe [TargetGroupPairInfo]))
 -> LoadBalancerInfo -> f LoadBalancerInfo)
-> ((Maybe [TargetGroupPairInfo]
     -> f (Maybe [TargetGroupPairInfo]))
    -> Maybe [TargetGroupPairInfo] -> f (Maybe [TargetGroupPairInfo]))
-> (Maybe [TargetGroupPairInfo] -> f (Maybe [TargetGroupPairInfo]))
-> LoadBalancerInfo
-> f LoadBalancerInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [TargetGroupPairInfo]
  [TargetGroupPairInfo]
  [TargetGroupPairInfo]
  [TargetGroupPairInfo]
-> Iso
     (Maybe [TargetGroupPairInfo])
     (Maybe [TargetGroupPairInfo])
     (Maybe [TargetGroupPairInfo])
     (Maybe [TargetGroupPairInfo])
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 AnIso
  [TargetGroupPairInfo]
  [TargetGroupPairInfo]
  [TargetGroupPairInfo]
  [TargetGroupPairInfo]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON LoadBalancerInfo where
  parseJSON :: Value -> Parser LoadBalancerInfo
parseJSON =
    String
-> (Object -> Parser LoadBalancerInfo)
-> Value
-> Parser LoadBalancerInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LoadBalancerInfo"
      ( \Object
x ->
          Maybe [ELBInfo]
-> Maybe [TargetGroupInfo]
-> Maybe [TargetGroupPairInfo]
-> LoadBalancerInfo
LoadBalancerInfo'
            (Maybe [ELBInfo]
 -> Maybe [TargetGroupInfo]
 -> Maybe [TargetGroupPairInfo]
 -> LoadBalancerInfo)
-> Parser (Maybe [ELBInfo])
-> Parser
     (Maybe [TargetGroupInfo]
      -> Maybe [TargetGroupPairInfo] -> LoadBalancerInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [ELBInfo]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"elbInfoList" Parser (Maybe (Maybe [ELBInfo]))
-> Maybe [ELBInfo] -> Parser (Maybe [ELBInfo])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ELBInfo]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [TargetGroupInfo]
   -> Maybe [TargetGroupPairInfo] -> LoadBalancerInfo)
-> Parser (Maybe [TargetGroupInfo])
-> Parser (Maybe [TargetGroupPairInfo] -> LoadBalancerInfo)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [TargetGroupInfo]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"targetGroupInfoList"
                            Parser (Maybe (Maybe [TargetGroupInfo]))
-> Maybe [TargetGroupInfo] -> Parser (Maybe [TargetGroupInfo])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [TargetGroupInfo]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [TargetGroupPairInfo] -> LoadBalancerInfo)
-> Parser (Maybe [TargetGroupPairInfo]) -> Parser LoadBalancerInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [TargetGroupPairInfo]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"targetGroupPairInfoList"
                            Parser (Maybe (Maybe [TargetGroupPairInfo]))
-> Maybe [TargetGroupPairInfo]
-> Parser (Maybe [TargetGroupPairInfo])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [TargetGroupPairInfo]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable LoadBalancerInfo

instance Prelude.NFData LoadBalancerInfo

instance Core.ToJSON LoadBalancerInfo where
  toJSON :: LoadBalancerInfo -> Value
toJSON LoadBalancerInfo' {Maybe [ELBInfo]
Maybe [TargetGroupInfo]
Maybe [TargetGroupPairInfo]
targetGroupPairInfoList :: Maybe [TargetGroupPairInfo]
targetGroupInfoList :: Maybe [TargetGroupInfo]
elbInfoList :: Maybe [ELBInfo]
$sel:targetGroupPairInfoList:LoadBalancerInfo' :: LoadBalancerInfo -> Maybe [TargetGroupPairInfo]
$sel:targetGroupInfoList:LoadBalancerInfo' :: LoadBalancerInfo -> Maybe [TargetGroupInfo]
$sel:elbInfoList:LoadBalancerInfo' :: LoadBalancerInfo -> Maybe [ELBInfo]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"elbInfoList" Text -> [ELBInfo] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([ELBInfo] -> Pair) -> Maybe [ELBInfo] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ELBInfo]
elbInfoList,
            (Text
"targetGroupInfoList" Text -> [TargetGroupInfo] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([TargetGroupInfo] -> Pair)
-> Maybe [TargetGroupInfo] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TargetGroupInfo]
targetGroupInfoList,
            (Text
"targetGroupPairInfoList" Text -> [TargetGroupPairInfo] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([TargetGroupPairInfo] -> Pair)
-> Maybe [TargetGroupPairInfo] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [TargetGroupPairInfo]
targetGroupPairInfoList
          ]
      )