{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.RDS.Types.TargetHealth where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | 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,
    -- | The reason for the current health @State@ of the RDS Proxy target.
    TargetHealth -> Maybe TargetHealthReason
reason :: Prelude.Maybe TargetHealthReason,
    -- | 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
  }
  deriving (TargetHealth -> TargetHealth -> Bool
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]
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
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. 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:
--
-- 'description', 'targetHealth_description' - A description of the health of the RDS Proxy target. If the @State@ is
-- @AVAILABLE@, a description is not included.
--
-- 'reason', 'targetHealth_reason' - The reason for the current health @State@ of the RDS Proxy target.
--
-- '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@
newTargetHealth ::
  TargetHealth
newTargetHealth :: TargetHealth
newTargetHealth =
  TargetHealth'
    { $sel:description:TargetHealth' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:reason:TargetHealth' :: Maybe TargetHealthReason
reason = forall a. Maybe a
Prelude.Nothing,
      $sel:state:TargetHealth' :: Maybe TargetState
state = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' TargetHealth (Maybe Text)
targetHealth_description = 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)

-- | The reason for the current health @State@ of the RDS Proxy target.
targetHealth_reason :: Lens.Lens' TargetHealth (Prelude.Maybe TargetHealthReason)
targetHealth_reason :: Lens' TargetHealth (Maybe TargetHealthReason)
targetHealth_reason = 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)

-- | 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 :: Lens' TargetHealth (Maybe TargetState)
targetHealth_state = 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)

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

instance Prelude.Hashable TargetHealth where
  hashWithSalt :: Int -> TargetHealth -> Int
hashWithSalt Int
_salt TargetHealth' {Maybe Text
Maybe TargetHealthReason
Maybe TargetState
state :: Maybe TargetState
reason :: Maybe TargetHealthReason
description :: Maybe Text
$sel:state:TargetHealth' :: TargetHealth -> Maybe TargetState
$sel:reason:TargetHealth' :: TargetHealth -> Maybe TargetHealthReason
$sel:description:TargetHealth' :: TargetHealth -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TargetHealthReason
reason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe TargetState
state

instance Prelude.NFData TargetHealth where
  rnf :: TargetHealth -> ()
rnf TargetHealth' {Maybe Text
Maybe TargetHealthReason
Maybe TargetState
state :: Maybe TargetState
reason :: Maybe TargetHealthReason
description :: Maybe Text
$sel:state:TargetHealth' :: TargetHealth -> Maybe TargetState
$sel:reason:TargetHealth' :: TargetHealth -> Maybe TargetHealthReason
$sel:description:TargetHealth' :: TargetHealth -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TargetHealthReason
reason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe TargetState
state