{-# 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.ElasticBeanstalk.Types.LoadBalancerDescription
-- 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.ElasticBeanstalk.Types.LoadBalancerDescription where

import qualified Amazonka.Core as Core
import Amazonka.ElasticBeanstalk.Types.Listener
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the details of a LoadBalancer.
--
-- /See:/ 'newLoadBalancerDescription' smart constructor.
data LoadBalancerDescription = LoadBalancerDescription'
  { -- | The name of the LoadBalancer.
    LoadBalancerDescription -> Maybe Text
loadBalancerName :: Prelude.Maybe Prelude.Text,
    -- | The domain name of the LoadBalancer.
    LoadBalancerDescription -> Maybe Text
domain :: Prelude.Maybe Prelude.Text,
    -- | A list of Listeners used by the LoadBalancer.
    LoadBalancerDescription -> Maybe [Listener]
listeners :: Prelude.Maybe [Listener]
  }
  deriving (LoadBalancerDescription -> LoadBalancerDescription -> Bool
(LoadBalancerDescription -> LoadBalancerDescription -> Bool)
-> (LoadBalancerDescription -> LoadBalancerDescription -> Bool)
-> Eq LoadBalancerDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoadBalancerDescription -> LoadBalancerDescription -> Bool
$c/= :: LoadBalancerDescription -> LoadBalancerDescription -> Bool
== :: LoadBalancerDescription -> LoadBalancerDescription -> Bool
$c== :: LoadBalancerDescription -> LoadBalancerDescription -> Bool
Prelude.Eq, ReadPrec [LoadBalancerDescription]
ReadPrec LoadBalancerDescription
Int -> ReadS LoadBalancerDescription
ReadS [LoadBalancerDescription]
(Int -> ReadS LoadBalancerDescription)
-> ReadS [LoadBalancerDescription]
-> ReadPrec LoadBalancerDescription
-> ReadPrec [LoadBalancerDescription]
-> Read LoadBalancerDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoadBalancerDescription]
$creadListPrec :: ReadPrec [LoadBalancerDescription]
readPrec :: ReadPrec LoadBalancerDescription
$creadPrec :: ReadPrec LoadBalancerDescription
readList :: ReadS [LoadBalancerDescription]
$creadList :: ReadS [LoadBalancerDescription]
readsPrec :: Int -> ReadS LoadBalancerDescription
$creadsPrec :: Int -> ReadS LoadBalancerDescription
Prelude.Read, Int -> LoadBalancerDescription -> ShowS
[LoadBalancerDescription] -> ShowS
LoadBalancerDescription -> String
(Int -> LoadBalancerDescription -> ShowS)
-> (LoadBalancerDescription -> String)
-> ([LoadBalancerDescription] -> ShowS)
-> Show LoadBalancerDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoadBalancerDescription] -> ShowS
$cshowList :: [LoadBalancerDescription] -> ShowS
show :: LoadBalancerDescription -> String
$cshow :: LoadBalancerDescription -> String
showsPrec :: Int -> LoadBalancerDescription -> ShowS
$cshowsPrec :: Int -> LoadBalancerDescription -> ShowS
Prelude.Show, (forall x.
 LoadBalancerDescription -> Rep LoadBalancerDescription x)
-> (forall x.
    Rep LoadBalancerDescription x -> LoadBalancerDescription)
-> Generic LoadBalancerDescription
forall x. Rep LoadBalancerDescription x -> LoadBalancerDescription
forall x. LoadBalancerDescription -> Rep LoadBalancerDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoadBalancerDescription x -> LoadBalancerDescription
$cfrom :: forall x. LoadBalancerDescription -> Rep LoadBalancerDescription x
Prelude.Generic)

-- |
-- Create a value of 'LoadBalancerDescription' 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', 'loadBalancerDescription_loadBalancerName' - The name of the LoadBalancer.
--
-- 'domain', 'loadBalancerDescription_domain' - The domain name of the LoadBalancer.
--
-- 'listeners', 'loadBalancerDescription_listeners' - A list of Listeners used by the LoadBalancer.
newLoadBalancerDescription ::
  LoadBalancerDescription
newLoadBalancerDescription :: LoadBalancerDescription
newLoadBalancerDescription =
  LoadBalancerDescription' :: Maybe Text
-> Maybe Text -> Maybe [Listener] -> LoadBalancerDescription
LoadBalancerDescription'
    { $sel:loadBalancerName:LoadBalancerDescription' :: Maybe Text
loadBalancerName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:domain:LoadBalancerDescription' :: Maybe Text
domain = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:listeners:LoadBalancerDescription' :: Maybe [Listener]
listeners = Maybe [Listener]
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the LoadBalancer.
loadBalancerDescription_loadBalancerName :: Lens.Lens' LoadBalancerDescription (Prelude.Maybe Prelude.Text)
loadBalancerDescription_loadBalancerName :: (Maybe Text -> f (Maybe Text))
-> LoadBalancerDescription -> f LoadBalancerDescription
loadBalancerDescription_loadBalancerName = (LoadBalancerDescription -> Maybe Text)
-> (LoadBalancerDescription
    -> Maybe Text -> LoadBalancerDescription)
-> Lens
     LoadBalancerDescription
     LoadBalancerDescription
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBalancerDescription' {Maybe Text
loadBalancerName :: Maybe Text
$sel:loadBalancerName:LoadBalancerDescription' :: LoadBalancerDescription -> Maybe Text
loadBalancerName} -> Maybe Text
loadBalancerName) (\s :: LoadBalancerDescription
s@LoadBalancerDescription' {} Maybe Text
a -> LoadBalancerDescription
s {$sel:loadBalancerName:LoadBalancerDescription' :: Maybe Text
loadBalancerName = Maybe Text
a} :: LoadBalancerDescription)

-- | The domain name of the LoadBalancer.
loadBalancerDescription_domain :: Lens.Lens' LoadBalancerDescription (Prelude.Maybe Prelude.Text)
loadBalancerDescription_domain :: (Maybe Text -> f (Maybe Text))
-> LoadBalancerDescription -> f LoadBalancerDescription
loadBalancerDescription_domain = (LoadBalancerDescription -> Maybe Text)
-> (LoadBalancerDescription
    -> Maybe Text -> LoadBalancerDescription)
-> Lens
     LoadBalancerDescription
     LoadBalancerDescription
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBalancerDescription' {Maybe Text
domain :: Maybe Text
$sel:domain:LoadBalancerDescription' :: LoadBalancerDescription -> Maybe Text
domain} -> Maybe Text
domain) (\s :: LoadBalancerDescription
s@LoadBalancerDescription' {} Maybe Text
a -> LoadBalancerDescription
s {$sel:domain:LoadBalancerDescription' :: Maybe Text
domain = Maybe Text
a} :: LoadBalancerDescription)

-- | A list of Listeners used by the LoadBalancer.
loadBalancerDescription_listeners :: Lens.Lens' LoadBalancerDescription (Prelude.Maybe [Listener])
loadBalancerDescription_listeners :: (Maybe [Listener] -> f (Maybe [Listener]))
-> LoadBalancerDescription -> f LoadBalancerDescription
loadBalancerDescription_listeners = (LoadBalancerDescription -> Maybe [Listener])
-> (LoadBalancerDescription
    -> Maybe [Listener] -> LoadBalancerDescription)
-> Lens
     LoadBalancerDescription
     LoadBalancerDescription
     (Maybe [Listener])
     (Maybe [Listener])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBalancerDescription' {Maybe [Listener]
listeners :: Maybe [Listener]
$sel:listeners:LoadBalancerDescription' :: LoadBalancerDescription -> Maybe [Listener]
listeners} -> Maybe [Listener]
listeners) (\s :: LoadBalancerDescription
s@LoadBalancerDescription' {} Maybe [Listener]
a -> LoadBalancerDescription
s {$sel:listeners:LoadBalancerDescription' :: Maybe [Listener]
listeners = Maybe [Listener]
a} :: LoadBalancerDescription) ((Maybe [Listener] -> f (Maybe [Listener]))
 -> LoadBalancerDescription -> f LoadBalancerDescription)
-> ((Maybe [Listener] -> f (Maybe [Listener]))
    -> Maybe [Listener] -> f (Maybe [Listener]))
-> (Maybe [Listener] -> f (Maybe [Listener]))
-> LoadBalancerDescription
-> f LoadBalancerDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Listener] [Listener] [Listener] [Listener]
-> Iso
     (Maybe [Listener])
     (Maybe [Listener])
     (Maybe [Listener])
     (Maybe [Listener])
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 [Listener] [Listener] [Listener] [Listener]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML LoadBalancerDescription where
  parseXML :: [Node] -> Either String LoadBalancerDescription
parseXML [Node]
x =
    Maybe Text
-> Maybe Text -> Maybe [Listener] -> LoadBalancerDescription
LoadBalancerDescription'
      (Maybe Text
 -> Maybe Text -> Maybe [Listener] -> LoadBalancerDescription)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe [Listener] -> LoadBalancerDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LoadBalancerName")
      Either
  String (Maybe Text -> Maybe [Listener] -> LoadBalancerDescription)
-> Either String (Maybe Text)
-> Either String (Maybe [Listener] -> LoadBalancerDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Domain")
      Either String (Maybe [Listener] -> LoadBalancerDescription)
-> Either String (Maybe [Listener])
-> Either String LoadBalancerDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Listeners" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Listener]))
-> Either String (Maybe [Listener])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Listener])
-> [Node] -> Either String (Maybe [Listener])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Listener]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )

instance Prelude.Hashable LoadBalancerDescription

instance Prelude.NFData LoadBalancerDescription