{-# 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.Route53.Types.HealthCheckObservation
-- 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.Route53.Types.HealthCheckObservation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53.Internal
import Amazonka.Route53.Types.HealthCheckRegion
import Amazonka.Route53.Types.StatusReport

-- | A complex type that contains the last failure reason as reported by one
-- Amazon Route 53 health checker.
--
-- /See:/ 'newHealthCheckObservation' smart constructor.
data HealthCheckObservation = HealthCheckObservation'
  { -- | The IP address of the Amazon Route 53 health checker that provided the
    -- failure reason in @StatusReport@.
    HealthCheckObservation -> Maybe Text
iPAddress :: Prelude.Maybe Prelude.Text,
    -- | A complex type that contains the last failure reason as reported by one
    -- Amazon Route 53 health checker and the time of the failed health check.
    HealthCheckObservation -> Maybe StatusReport
statusReport :: Prelude.Maybe StatusReport,
    -- | The region of the Amazon Route 53 health checker that provided the
    -- status in @StatusReport@.
    HealthCheckObservation -> Maybe HealthCheckRegion
region :: Prelude.Maybe HealthCheckRegion
  }
  deriving (HealthCheckObservation -> HealthCheckObservation -> Bool
(HealthCheckObservation -> HealthCheckObservation -> Bool)
-> (HealthCheckObservation -> HealthCheckObservation -> Bool)
-> Eq HealthCheckObservation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HealthCheckObservation -> HealthCheckObservation -> Bool
$c/= :: HealthCheckObservation -> HealthCheckObservation -> Bool
== :: HealthCheckObservation -> HealthCheckObservation -> Bool
$c== :: HealthCheckObservation -> HealthCheckObservation -> Bool
Prelude.Eq, ReadPrec [HealthCheckObservation]
ReadPrec HealthCheckObservation
Int -> ReadS HealthCheckObservation
ReadS [HealthCheckObservation]
(Int -> ReadS HealthCheckObservation)
-> ReadS [HealthCheckObservation]
-> ReadPrec HealthCheckObservation
-> ReadPrec [HealthCheckObservation]
-> Read HealthCheckObservation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HealthCheckObservation]
$creadListPrec :: ReadPrec [HealthCheckObservation]
readPrec :: ReadPrec HealthCheckObservation
$creadPrec :: ReadPrec HealthCheckObservation
readList :: ReadS [HealthCheckObservation]
$creadList :: ReadS [HealthCheckObservation]
readsPrec :: Int -> ReadS HealthCheckObservation
$creadsPrec :: Int -> ReadS HealthCheckObservation
Prelude.Read, Int -> HealthCheckObservation -> ShowS
[HealthCheckObservation] -> ShowS
HealthCheckObservation -> String
(Int -> HealthCheckObservation -> ShowS)
-> (HealthCheckObservation -> String)
-> ([HealthCheckObservation] -> ShowS)
-> Show HealthCheckObservation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HealthCheckObservation] -> ShowS
$cshowList :: [HealthCheckObservation] -> ShowS
show :: HealthCheckObservation -> String
$cshow :: HealthCheckObservation -> String
showsPrec :: Int -> HealthCheckObservation -> ShowS
$cshowsPrec :: Int -> HealthCheckObservation -> ShowS
Prelude.Show, (forall x. HealthCheckObservation -> Rep HealthCheckObservation x)
-> (forall x.
    Rep HealthCheckObservation x -> HealthCheckObservation)
-> Generic HealthCheckObservation
forall x. Rep HealthCheckObservation x -> HealthCheckObservation
forall x. HealthCheckObservation -> Rep HealthCheckObservation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HealthCheckObservation x -> HealthCheckObservation
$cfrom :: forall x. HealthCheckObservation -> Rep HealthCheckObservation x
Prelude.Generic)

-- |
-- Create a value of 'HealthCheckObservation' 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:
--
-- 'iPAddress', 'healthCheckObservation_iPAddress' - The IP address of the Amazon Route 53 health checker that provided the
-- failure reason in @StatusReport@.
--
-- 'statusReport', 'healthCheckObservation_statusReport' - A complex type that contains the last failure reason as reported by one
-- Amazon Route 53 health checker and the time of the failed health check.
--
-- 'region', 'healthCheckObservation_region' - The region of the Amazon Route 53 health checker that provided the
-- status in @StatusReport@.
newHealthCheckObservation ::
  HealthCheckObservation
newHealthCheckObservation :: HealthCheckObservation
newHealthCheckObservation =
  HealthCheckObservation' :: Maybe Text
-> Maybe StatusReport
-> Maybe HealthCheckRegion
-> HealthCheckObservation
HealthCheckObservation'
    { $sel:iPAddress:HealthCheckObservation' :: Maybe Text
iPAddress =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:statusReport:HealthCheckObservation' :: Maybe StatusReport
statusReport = Maybe StatusReport
forall a. Maybe a
Prelude.Nothing,
      $sel:region:HealthCheckObservation' :: Maybe HealthCheckRegion
region = Maybe HealthCheckRegion
forall a. Maybe a
Prelude.Nothing
    }

-- | The IP address of the Amazon Route 53 health checker that provided the
-- failure reason in @StatusReport@.
healthCheckObservation_iPAddress :: Lens.Lens' HealthCheckObservation (Prelude.Maybe Prelude.Text)
healthCheckObservation_iPAddress :: (Maybe Text -> f (Maybe Text))
-> HealthCheckObservation -> f HealthCheckObservation
healthCheckObservation_iPAddress = (HealthCheckObservation -> Maybe Text)
-> (HealthCheckObservation -> Maybe Text -> HealthCheckObservation)
-> Lens
     HealthCheckObservation
     HealthCheckObservation
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheckObservation' {Maybe Text
iPAddress :: Maybe Text
$sel:iPAddress:HealthCheckObservation' :: HealthCheckObservation -> Maybe Text
iPAddress} -> Maybe Text
iPAddress) (\s :: HealthCheckObservation
s@HealthCheckObservation' {} Maybe Text
a -> HealthCheckObservation
s {$sel:iPAddress:HealthCheckObservation' :: Maybe Text
iPAddress = Maybe Text
a} :: HealthCheckObservation)

-- | A complex type that contains the last failure reason as reported by one
-- Amazon Route 53 health checker and the time of the failed health check.
healthCheckObservation_statusReport :: Lens.Lens' HealthCheckObservation (Prelude.Maybe StatusReport)
healthCheckObservation_statusReport :: (Maybe StatusReport -> f (Maybe StatusReport))
-> HealthCheckObservation -> f HealthCheckObservation
healthCheckObservation_statusReport = (HealthCheckObservation -> Maybe StatusReport)
-> (HealthCheckObservation
    -> Maybe StatusReport -> HealthCheckObservation)
-> Lens
     HealthCheckObservation
     HealthCheckObservation
     (Maybe StatusReport)
     (Maybe StatusReport)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheckObservation' {Maybe StatusReport
statusReport :: Maybe StatusReport
$sel:statusReport:HealthCheckObservation' :: HealthCheckObservation -> Maybe StatusReport
statusReport} -> Maybe StatusReport
statusReport) (\s :: HealthCheckObservation
s@HealthCheckObservation' {} Maybe StatusReport
a -> HealthCheckObservation
s {$sel:statusReport:HealthCheckObservation' :: Maybe StatusReport
statusReport = Maybe StatusReport
a} :: HealthCheckObservation)

-- | The region of the Amazon Route 53 health checker that provided the
-- status in @StatusReport@.
healthCheckObservation_region :: Lens.Lens' HealthCheckObservation (Prelude.Maybe HealthCheckRegion)
healthCheckObservation_region :: (Maybe HealthCheckRegion -> f (Maybe HealthCheckRegion))
-> HealthCheckObservation -> f HealthCheckObservation
healthCheckObservation_region = (HealthCheckObservation -> Maybe HealthCheckRegion)
-> (HealthCheckObservation
    -> Maybe HealthCheckRegion -> HealthCheckObservation)
-> Lens
     HealthCheckObservation
     HealthCheckObservation
     (Maybe HealthCheckRegion)
     (Maybe HealthCheckRegion)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheckObservation' {Maybe HealthCheckRegion
region :: Maybe HealthCheckRegion
$sel:region:HealthCheckObservation' :: HealthCheckObservation -> Maybe HealthCheckRegion
region} -> Maybe HealthCheckRegion
region) (\s :: HealthCheckObservation
s@HealthCheckObservation' {} Maybe HealthCheckRegion
a -> HealthCheckObservation
s {$sel:region:HealthCheckObservation' :: Maybe HealthCheckRegion
region = Maybe HealthCheckRegion
a} :: HealthCheckObservation)

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

instance Prelude.Hashable HealthCheckObservation

instance Prelude.NFData HealthCheckObservation