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

import qualified Amazonka.Core as Core
import Amazonka.ELBV2.Types.LoadBalancerStateEnum
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the state of the load balancer.
--
-- /See:/ 'newLoadBalancerState' smart constructor.
data LoadBalancerState = LoadBalancerState'
  { -- | A description of the state.
    LoadBalancerState -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The state code. The initial state of the load balancer is
    -- @provisioning@. After the load balancer is fully set up and ready to
    -- route traffic, its state is @active@. If load balancer is routing
    -- traffic but does not have the resources it needs to scale, its state
    -- is@active_impaired@. If the load balancer could not be set up, its state
    -- is @failed@.
    LoadBalancerState -> Maybe LoadBalancerStateEnum
code :: Prelude.Maybe LoadBalancerStateEnum
  }
  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:
--
-- 'reason', 'loadBalancerState_reason' - A description of the state.
--
-- 'code', 'loadBalancerState_code' - The state code. The initial state of the load balancer is
-- @provisioning@. After the load balancer is fully set up and ready to
-- route traffic, its state is @active@. If load balancer is routing
-- traffic but does not have the resources it needs to scale, its state
-- is@active_impaired@. If the load balancer could not be set up, its state
-- is @failed@.
newLoadBalancerState ::
  LoadBalancerState
newLoadBalancerState :: LoadBalancerState
newLoadBalancerState =
  LoadBalancerState' :: Maybe Text -> Maybe LoadBalancerStateEnum -> LoadBalancerState
LoadBalancerState'
    { $sel:reason:LoadBalancerState' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:code:LoadBalancerState' :: Maybe LoadBalancerStateEnum
code = Maybe LoadBalancerStateEnum
forall a. Maybe a
Prelude.Nothing
    }

-- | A description of the state.
loadBalancerState_reason :: Lens.Lens' LoadBalancerState (Prelude.Maybe Prelude.Text)
loadBalancerState_reason :: (Maybe Text -> f (Maybe Text))
-> LoadBalancerState -> f LoadBalancerState
loadBalancerState_reason = (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
reason :: Maybe Text
$sel:reason:LoadBalancerState' :: LoadBalancerState -> Maybe Text
reason} -> Maybe Text
reason) (\s :: LoadBalancerState
s@LoadBalancerState' {} Maybe Text
a -> LoadBalancerState
s {$sel:reason:LoadBalancerState' :: Maybe Text
reason = Maybe Text
a} :: LoadBalancerState)

-- | The state code. The initial state of the load balancer is
-- @provisioning@. After the load balancer is fully set up and ready to
-- route traffic, its state is @active@. If load balancer is routing
-- traffic but does not have the resources it needs to scale, its state
-- is@active_impaired@. If the load balancer could not be set up, its state
-- is @failed@.
loadBalancerState_code :: Lens.Lens' LoadBalancerState (Prelude.Maybe LoadBalancerStateEnum)
loadBalancerState_code :: (Maybe LoadBalancerStateEnum -> f (Maybe LoadBalancerStateEnum))
-> LoadBalancerState -> f LoadBalancerState
loadBalancerState_code = (LoadBalancerState -> Maybe LoadBalancerStateEnum)
-> (LoadBalancerState
    -> Maybe LoadBalancerStateEnum -> LoadBalancerState)
-> Lens
     LoadBalancerState
     LoadBalancerState
     (Maybe LoadBalancerStateEnum)
     (Maybe LoadBalancerStateEnum)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LoadBalancerState' {Maybe LoadBalancerStateEnum
code :: Maybe LoadBalancerStateEnum
$sel:code:LoadBalancerState' :: LoadBalancerState -> Maybe LoadBalancerStateEnum
code} -> Maybe LoadBalancerStateEnum
code) (\s :: LoadBalancerState
s@LoadBalancerState' {} Maybe LoadBalancerStateEnum
a -> LoadBalancerState
s {$sel:code:LoadBalancerState' :: Maybe LoadBalancerStateEnum
code = Maybe LoadBalancerStateEnum
a} :: LoadBalancerState)

instance Core.FromXML LoadBalancerState where
  parseXML :: [Node] -> Either String LoadBalancerState
parseXML [Node]
x =
    Maybe Text -> Maybe LoadBalancerStateEnum -> LoadBalancerState
LoadBalancerState'
      (Maybe Text -> Maybe LoadBalancerStateEnum -> LoadBalancerState)
-> Either String (Maybe Text)
-> Either String (Maybe LoadBalancerStateEnum -> 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
"Reason") Either String (Maybe LoadBalancerStateEnum -> LoadBalancerState)
-> Either String (Maybe LoadBalancerStateEnum)
-> Either String LoadBalancerState
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe LoadBalancerStateEnum)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Code")

instance Prelude.Hashable LoadBalancerState

instance Prelude.NFData LoadBalancerState