{-# 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.RDS.Types.TargetHealth
-- 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.RDS.Types.TargetHealth where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDS.Types.TargetHealthReason
import Amazonka.RDS.Types.TargetState

-- | Information about the connection health of an RDS Proxy target.
--
-- /See:/ 'newTargetHealth' smart constructor.
data TargetHealth = TargetHealth'
  { -- | The current state of the connection health lifecycle for the RDS Proxy
    -- target. The following is a typical lifecycle example for the states of
    -- an RDS Proxy target:
    --
    -- @registering@ > @unavailable@ > @available@ > @unavailable@ >
    -- @available@
    TargetHealth -> Maybe TargetState
state :: Prelude.Maybe TargetState,
    -- | The reason for the current health @State@ of the RDS Proxy target.
    TargetHealth -> Maybe TargetHealthReason
reason :: Prelude.Maybe TargetHealthReason,
    -- | A description of the health of the RDS Proxy target. If the @State@ is
    -- @AVAILABLE@, a description is not included.
    TargetHealth -> Maybe Text
description :: Prelude.Maybe Prelude.Text
  }
  deriving (TargetHealth -> TargetHealth -> Bool
(TargetHealth -> TargetHealth -> Bool)
-> (TargetHealth -> TargetHealth -> Bool) -> Eq TargetHealth
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetHealth -> TargetHealth -> Bool
$c/= :: TargetHealth -> TargetHealth -> Bool
== :: TargetHealth -> TargetHealth -> Bool
$c== :: TargetHealth -> TargetHealth -> Bool
Prelude.Eq, ReadPrec [TargetHealth]
ReadPrec TargetHealth
Int -> ReadS TargetHealth
ReadS [TargetHealth]
(Int -> ReadS TargetHealth)
-> ReadS [TargetHealth]
-> ReadPrec TargetHealth
-> ReadPrec [TargetHealth]
-> Read TargetHealth
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetHealth]
$creadListPrec :: ReadPrec [TargetHealth]
readPrec :: ReadPrec TargetHealth
$creadPrec :: ReadPrec TargetHealth
readList :: ReadS [TargetHealth]
$creadList :: ReadS [TargetHealth]
readsPrec :: Int -> ReadS TargetHealth
$creadsPrec :: Int -> ReadS TargetHealth
Prelude.Read, Int -> TargetHealth -> ShowS
[TargetHealth] -> ShowS
TargetHealth -> String
(Int -> TargetHealth -> ShowS)
-> (TargetHealth -> String)
-> ([TargetHealth] -> ShowS)
-> Show TargetHealth
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetHealth] -> ShowS
$cshowList :: [TargetHealth] -> ShowS
show :: TargetHealth -> String
$cshow :: TargetHealth -> String
showsPrec :: Int -> TargetHealth -> ShowS
$cshowsPrec :: Int -> TargetHealth -> ShowS
Prelude.Show, (forall x. TargetHealth -> Rep TargetHealth x)
-> (forall x. Rep TargetHealth x -> TargetHealth)
-> Generic TargetHealth
forall x. Rep TargetHealth x -> TargetHealth
forall x. TargetHealth -> Rep TargetHealth x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TargetHealth x -> TargetHealth
$cfrom :: forall x. TargetHealth -> Rep TargetHealth x
Prelude.Generic)

-- |
-- Create a value of 'TargetHealth' 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', 'targetHealth_state' - The current state of the connection health lifecycle for the RDS Proxy
-- target. The following is a typical lifecycle example for the states of
-- an RDS Proxy target:
--
-- @registering@ > @unavailable@ > @available@ > @unavailable@ >
-- @available@
--
-- 'reason', 'targetHealth_reason' - The reason for the current health @State@ of the RDS Proxy target.
--
-- 'description', 'targetHealth_description' - A description of the health of the RDS Proxy target. If the @State@ is
-- @AVAILABLE@, a description is not included.
newTargetHealth ::
  TargetHealth
newTargetHealth :: TargetHealth
newTargetHealth =
  TargetHealth' :: Maybe TargetState
-> Maybe TargetHealthReason -> Maybe Text -> TargetHealth
TargetHealth'
    { $sel:state:TargetHealth' :: Maybe TargetState
state = Maybe TargetState
forall a. Maybe a
Prelude.Nothing,
      $sel:reason:TargetHealth' :: Maybe TargetHealthReason
reason = Maybe TargetHealthReason
forall a. Maybe a
Prelude.Nothing,
      $sel:description:TargetHealth' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The current state of the connection health lifecycle for the RDS Proxy
-- target. The following is a typical lifecycle example for the states of
-- an RDS Proxy target:
--
-- @registering@ > @unavailable@ > @available@ > @unavailable@ >
-- @available@
targetHealth_state :: Lens.Lens' TargetHealth (Prelude.Maybe TargetState)
targetHealth_state :: (Maybe TargetState -> f (Maybe TargetState))
-> TargetHealth -> f TargetHealth
targetHealth_state = (TargetHealth -> Maybe TargetState)
-> (TargetHealth -> Maybe TargetState -> TargetHealth)
-> Lens
     TargetHealth TargetHealth (Maybe TargetState) (Maybe TargetState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetHealth' {Maybe TargetState
state :: Maybe TargetState
$sel:state:TargetHealth' :: TargetHealth -> Maybe TargetState
state} -> Maybe TargetState
state) (\s :: TargetHealth
s@TargetHealth' {} Maybe TargetState
a -> TargetHealth
s {$sel:state:TargetHealth' :: Maybe TargetState
state = Maybe TargetState
a} :: TargetHealth)

-- | The reason for the current health @State@ of the RDS Proxy target.
targetHealth_reason :: Lens.Lens' TargetHealth (Prelude.Maybe TargetHealthReason)
targetHealth_reason :: (Maybe TargetHealthReason -> f (Maybe TargetHealthReason))
-> TargetHealth -> f TargetHealth
targetHealth_reason = (TargetHealth -> Maybe TargetHealthReason)
-> (TargetHealth -> Maybe TargetHealthReason -> TargetHealth)
-> Lens
     TargetHealth
     TargetHealth
     (Maybe TargetHealthReason)
     (Maybe TargetHealthReason)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetHealth' {Maybe TargetHealthReason
reason :: Maybe TargetHealthReason
$sel:reason:TargetHealth' :: TargetHealth -> Maybe TargetHealthReason
reason} -> Maybe TargetHealthReason
reason) (\s :: TargetHealth
s@TargetHealth' {} Maybe TargetHealthReason
a -> TargetHealth
s {$sel:reason:TargetHealth' :: Maybe TargetHealthReason
reason = Maybe TargetHealthReason
a} :: TargetHealth)

-- | A description of the health of the RDS Proxy target. If the @State@ is
-- @AVAILABLE@, a description is not included.
targetHealth_description :: Lens.Lens' TargetHealth (Prelude.Maybe Prelude.Text)
targetHealth_description :: (Maybe Text -> f (Maybe Text)) -> TargetHealth -> f TargetHealth
targetHealth_description = (TargetHealth -> Maybe Text)
-> (TargetHealth -> Maybe Text -> TargetHealth)
-> Lens TargetHealth TargetHealth (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetHealth' {Maybe Text
description :: Maybe Text
$sel:description:TargetHealth' :: TargetHealth -> Maybe Text
description} -> Maybe Text
description) (\s :: TargetHealth
s@TargetHealth' {} Maybe Text
a -> TargetHealth
s {$sel:description:TargetHealth' :: Maybe Text
description = Maybe Text
a} :: TargetHealth)

instance Core.FromXML TargetHealth where
  parseXML :: [Node] -> Either String TargetHealth
parseXML [Node]
x =
    Maybe TargetState
-> Maybe TargetHealthReason -> Maybe Text -> TargetHealth
TargetHealth'
      (Maybe TargetState
 -> Maybe TargetHealthReason -> Maybe Text -> TargetHealth)
-> Either String (Maybe TargetState)
-> Either
     String (Maybe TargetHealthReason -> Maybe Text -> TargetHealth)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe TargetState)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"State")
      Either
  String (Maybe TargetHealthReason -> Maybe Text -> TargetHealth)
-> Either String (Maybe TargetHealthReason)
-> Either String (Maybe Text -> TargetHealth)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe TargetHealthReason)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Reason")
      Either String (Maybe Text -> TargetHealth)
-> Either String (Maybe Text) -> Either String TargetHealth
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
"Description")

instance Prelude.Hashable TargetHealth

instance Prelude.NFData TargetHealth