{-# 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.TargetHealthDescription
-- 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.TargetHealthDescription where

import qualified Amazonka.Core as Core
import Amazonka.ELBV2.Types.TargetDescription
import Amazonka.ELBV2.Types.TargetHealth
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the health of a target.
--
-- /See:/ 'newTargetHealthDescription' smart constructor.
data TargetHealthDescription = TargetHealthDescription'
  { -- | The health information for the target.
    TargetHealthDescription -> Maybe TargetHealth
targetHealth :: Prelude.Maybe TargetHealth,
    -- | The port to use to connect with the target.
    TargetHealthDescription -> Maybe Text
healthCheckPort :: Prelude.Maybe Prelude.Text,
    -- | The description of the target.
    TargetHealthDescription -> Maybe TargetDescription
target :: Prelude.Maybe TargetDescription
  }
  deriving (TargetHealthDescription -> TargetHealthDescription -> Bool
(TargetHealthDescription -> TargetHealthDescription -> Bool)
-> (TargetHealthDescription -> TargetHealthDescription -> Bool)
-> Eq TargetHealthDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TargetHealthDescription -> TargetHealthDescription -> Bool
$c/= :: TargetHealthDescription -> TargetHealthDescription -> Bool
== :: TargetHealthDescription -> TargetHealthDescription -> Bool
$c== :: TargetHealthDescription -> TargetHealthDescription -> Bool
Prelude.Eq, ReadPrec [TargetHealthDescription]
ReadPrec TargetHealthDescription
Int -> ReadS TargetHealthDescription
ReadS [TargetHealthDescription]
(Int -> ReadS TargetHealthDescription)
-> ReadS [TargetHealthDescription]
-> ReadPrec TargetHealthDescription
-> ReadPrec [TargetHealthDescription]
-> Read TargetHealthDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TargetHealthDescription]
$creadListPrec :: ReadPrec [TargetHealthDescription]
readPrec :: ReadPrec TargetHealthDescription
$creadPrec :: ReadPrec TargetHealthDescription
readList :: ReadS [TargetHealthDescription]
$creadList :: ReadS [TargetHealthDescription]
readsPrec :: Int -> ReadS TargetHealthDescription
$creadsPrec :: Int -> ReadS TargetHealthDescription
Prelude.Read, Int -> TargetHealthDescription -> ShowS
[TargetHealthDescription] -> ShowS
TargetHealthDescription -> String
(Int -> TargetHealthDescription -> ShowS)
-> (TargetHealthDescription -> String)
-> ([TargetHealthDescription] -> ShowS)
-> Show TargetHealthDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TargetHealthDescription] -> ShowS
$cshowList :: [TargetHealthDescription] -> ShowS
show :: TargetHealthDescription -> String
$cshow :: TargetHealthDescription -> String
showsPrec :: Int -> TargetHealthDescription -> ShowS
$cshowsPrec :: Int -> TargetHealthDescription -> ShowS
Prelude.Show, (forall x.
 TargetHealthDescription -> Rep TargetHealthDescription x)
-> (forall x.
    Rep TargetHealthDescription x -> TargetHealthDescription)
-> Generic TargetHealthDescription
forall x. Rep TargetHealthDescription x -> TargetHealthDescription
forall x. TargetHealthDescription -> Rep TargetHealthDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TargetHealthDescription x -> TargetHealthDescription
$cfrom :: forall x. TargetHealthDescription -> Rep TargetHealthDescription x
Prelude.Generic)

-- |
-- Create a value of 'TargetHealthDescription' 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:
--
-- 'targetHealth', 'targetHealthDescription_targetHealth' - The health information for the target.
--
-- 'healthCheckPort', 'targetHealthDescription_healthCheckPort' - The port to use to connect with the target.
--
-- 'target', 'targetHealthDescription_target' - The description of the target.
newTargetHealthDescription ::
  TargetHealthDescription
newTargetHealthDescription :: TargetHealthDescription
newTargetHealthDescription =
  TargetHealthDescription' :: Maybe TargetHealth
-> Maybe Text -> Maybe TargetDescription -> TargetHealthDescription
TargetHealthDescription'
    { $sel:targetHealth:TargetHealthDescription' :: Maybe TargetHealth
targetHealth =
        Maybe TargetHealth
forall a. Maybe a
Prelude.Nothing,
      $sel:healthCheckPort:TargetHealthDescription' :: Maybe Text
healthCheckPort = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:target:TargetHealthDescription' :: Maybe TargetDescription
target = Maybe TargetDescription
forall a. Maybe a
Prelude.Nothing
    }

-- | The health information for the target.
targetHealthDescription_targetHealth :: Lens.Lens' TargetHealthDescription (Prelude.Maybe TargetHealth)
targetHealthDescription_targetHealth :: (Maybe TargetHealth -> f (Maybe TargetHealth))
-> TargetHealthDescription -> f TargetHealthDescription
targetHealthDescription_targetHealth = (TargetHealthDescription -> Maybe TargetHealth)
-> (TargetHealthDescription
    -> Maybe TargetHealth -> TargetHealthDescription)
-> Lens
     TargetHealthDescription
     TargetHealthDescription
     (Maybe TargetHealth)
     (Maybe TargetHealth)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetHealthDescription' {Maybe TargetHealth
targetHealth :: Maybe TargetHealth
$sel:targetHealth:TargetHealthDescription' :: TargetHealthDescription -> Maybe TargetHealth
targetHealth} -> Maybe TargetHealth
targetHealth) (\s :: TargetHealthDescription
s@TargetHealthDescription' {} Maybe TargetHealth
a -> TargetHealthDescription
s {$sel:targetHealth:TargetHealthDescription' :: Maybe TargetHealth
targetHealth = Maybe TargetHealth
a} :: TargetHealthDescription)

-- | The port to use to connect with the target.
targetHealthDescription_healthCheckPort :: Lens.Lens' TargetHealthDescription (Prelude.Maybe Prelude.Text)
targetHealthDescription_healthCheckPort :: (Maybe Text -> f (Maybe Text))
-> TargetHealthDescription -> f TargetHealthDescription
targetHealthDescription_healthCheckPort = (TargetHealthDescription -> Maybe Text)
-> (TargetHealthDescription
    -> Maybe Text -> TargetHealthDescription)
-> Lens
     TargetHealthDescription
     TargetHealthDescription
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetHealthDescription' {Maybe Text
healthCheckPort :: Maybe Text
$sel:healthCheckPort:TargetHealthDescription' :: TargetHealthDescription -> Maybe Text
healthCheckPort} -> Maybe Text
healthCheckPort) (\s :: TargetHealthDescription
s@TargetHealthDescription' {} Maybe Text
a -> TargetHealthDescription
s {$sel:healthCheckPort:TargetHealthDescription' :: Maybe Text
healthCheckPort = Maybe Text
a} :: TargetHealthDescription)

-- | The description of the target.
targetHealthDescription_target :: Lens.Lens' TargetHealthDescription (Prelude.Maybe TargetDescription)
targetHealthDescription_target :: (Maybe TargetDescription -> f (Maybe TargetDescription))
-> TargetHealthDescription -> f TargetHealthDescription
targetHealthDescription_target = (TargetHealthDescription -> Maybe TargetDescription)
-> (TargetHealthDescription
    -> Maybe TargetDescription -> TargetHealthDescription)
-> Lens
     TargetHealthDescription
     TargetHealthDescription
     (Maybe TargetDescription)
     (Maybe TargetDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TargetHealthDescription' {Maybe TargetDescription
target :: Maybe TargetDescription
$sel:target:TargetHealthDescription' :: TargetHealthDescription -> Maybe TargetDescription
target} -> Maybe TargetDescription
target) (\s :: TargetHealthDescription
s@TargetHealthDescription' {} Maybe TargetDescription
a -> TargetHealthDescription
s {$sel:target:TargetHealthDescription' :: Maybe TargetDescription
target = Maybe TargetDescription
a} :: TargetHealthDescription)

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

instance Prelude.Hashable TargetHealthDescription

instance Prelude.NFData TargetHealthDescription