{-# 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.AutoScaling.Types.LoadBalancerState
-- 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.AutoScaling.Types.LoadBalancerState where

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

-- | Describes the state of a Classic Load Balancer.
--
-- /See:/ 'newLoadBalancerState' smart constructor.
data LoadBalancerState = LoadBalancerState'
  { -- | One of the following load balancer states:
    --
    -- -   @Adding@ - The Auto Scaling instances are being registered with the
    --     load balancer.
    --
    -- -   @Added@ - All Auto Scaling instances are registered with the load
    --     balancer.
    --
    -- -   @InService@ - At least one Auto Scaling instance passed an @ELB@
    --     health check.
    --
    -- -   @Removing@ - The Auto Scaling instances are being deregistered from
    --     the load balancer. If connection draining is enabled, Elastic Load
    --     Balancing waits for in-flight requests to complete before
    --     deregistering the instances.
    --
    -- -   @Removed@ - All Auto Scaling instances are deregistered from the
    --     load balancer.
    LoadBalancerState -> Maybe Text
state :: Prelude.Maybe Prelude.Text,
    -- | The name of the load balancer.
    LoadBalancerState -> Maybe Text
loadBalancerName :: Prelude.Maybe Prelude.Text
  }
  deriving (LoadBalancerState -> LoadBalancerState -> Bool
(LoadBalancerState -> LoadBalancerState -> Bool)
-> (LoadBalancerState -> LoadBalancerState -> Bool)
-> Eq LoadBalancerState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LoadBalancerState -> LoadBalancerState -> Bool
$c/= :: LoadBalancerState -> LoadBalancerState -> Bool
== :: LoadBalancerState -> LoadBalancerState -> Bool
$c== :: LoadBalancerState -> LoadBalancerState -> Bool
Prelude.Eq, ReadPrec [LoadBalancerState]
ReadPrec LoadBalancerState
Int -> ReadS LoadBalancerState
ReadS [LoadBalancerState]
(Int -> ReadS LoadBalancerState)
-> ReadS [LoadBalancerState]
-> ReadPrec LoadBalancerState
-> ReadPrec [LoadBalancerState]
-> Read LoadBalancerState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LoadBalancerState]
$creadListPrec :: ReadPrec [LoadBalancerState]
readPrec :: ReadPrec LoadBalancerState
$creadPrec :: ReadPrec LoadBalancerState
readList :: ReadS [LoadBalancerState]
$creadList :: ReadS [LoadBalancerState]
readsPrec :: Int -> ReadS LoadBalancerState
$creadsPrec :: Int -> ReadS LoadBalancerState
Prelude.Read, Int -> LoadBalancerState -> ShowS
[LoadBalancerState] -> ShowS
LoadBalancerState -> String
(Int -> LoadBalancerState -> ShowS)
-> (LoadBalancerState -> String)
-> ([LoadBalancerState] -> ShowS)
-> Show LoadBalancerState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LoadBalancerState] -> ShowS
$cshowList :: [LoadBalancerState] -> ShowS
show :: LoadBalancerState -> String
$cshow :: LoadBalancerState -> String
showsPrec :: Int -> LoadBalancerState -> ShowS
$cshowsPrec :: Int -> LoadBalancerState -> ShowS
Prelude.Show, (forall x. LoadBalancerState -> Rep LoadBalancerState x)
-> (forall x. Rep LoadBalancerState x -> LoadBalancerState)
-> Generic LoadBalancerState
forall x. Rep LoadBalancerState x -> LoadBalancerState
forall x. LoadBalancerState -> Rep LoadBalancerState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LoadBalancerState x -> LoadBalancerState
$cfrom :: forall x. LoadBalancerState -> Rep LoadBalancerState x
Prelude.Generic)

-- |
-- Create a value of 'LoadBalancerState' 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:
--
-- 'state', 'loadBalancerState_state' - One of the following load balancer states:
--
-- -   @Adding@ - The Auto Scaling instances are being registered with the
--     load balancer.
--
-- -   @Added@ - All Auto Scaling instances are registered with the load
--     balancer.
--
-- -   @InService@ - At least one Auto Scaling instance passed an @ELB@
--     health check.
--
-- -   @Removing@ - The Auto Scaling instances are being deregistered from
--     the load balancer. If connection draining is enabled, Elastic Load
--     Balancing waits for in-flight requests to complete before
--     deregistering the instances.
--
-- -   @Removed@ - All Auto Scaling instances are deregistered from the
--     load balancer.
--
-- 'loadBalancerName', 'loadBalancerState_loadBalancerName' - The name of the load balancer.
newLoadBalancerState ::
  LoadBalancerState
newLoadBalancerState :: LoadBalancerState
newLoadBalancerState =
  LoadBalancerState' :: Maybe Text -> Maybe Text -> LoadBalancerState
LoadBalancerState'
    { $sel:state:LoadBalancerState' :: Maybe Text
state = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:loadBalancerName:LoadBalancerState' :: Maybe Text
loadBalancerName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | One of the following load balancer states:
--
-- -   @Adding@ - The Auto Scaling instances are being registered with the
--     load balancer.
--
-- -   @Added@ - All Auto Scaling instances are registered with the load
--     balancer.
--
-- -   @InService@ - At least one Auto Scaling instance passed an @ELB@
--     health check.
--
-- -   @Removing@ - The Auto Scaling instances are being deregistered from
--     the load balancer. If connection draining is enabled, Elastic Load
--     Balancing waits for in-flight requests to complete before
--     deregistering the instances.
--
-- -   @Removed@ - All Auto Scaling instances are deregistered from the
--     load balancer.
loadBalancerState_state :: Lens.Lens' LoadBalancerState (Prelude.Maybe Prelude.Text)
loadBalancerState_state :: (Maybe Text -> f (Maybe Text))
-> LoadBalancerState -> f LoadBalancerState
loadBalancerState_state = (LoadBalancerState -> Maybe Text)
-> (LoadBalancerState -> Maybe Text -> LoadBalancerState)
-> Lens
     LoadBalancerState LoadBalancerState (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBalancerState' {Maybe Text
state :: Maybe Text
$sel:state:LoadBalancerState' :: LoadBalancerState -> Maybe Text
state} -> Maybe Text
state) (\s :: LoadBalancerState
s@LoadBalancerState' {} Maybe Text
a -> LoadBalancerState
s {$sel:state:LoadBalancerState' :: Maybe Text
state = Maybe Text
a} :: LoadBalancerState)

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

instance Core.FromXML LoadBalancerState where
  parseXML :: [Node] -> Either String LoadBalancerState
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> LoadBalancerState
LoadBalancerState'
      (Maybe Text -> Maybe Text -> LoadBalancerState)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> LoadBalancerState)
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
"State")
      Either String (Maybe Text -> LoadBalancerState)
-> Either String (Maybe Text) -> Either String LoadBalancerState
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
"LoadBalancerName")

instance Prelude.Hashable LoadBalancerState

instance Prelude.NFData LoadBalancerState