{-# 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.HealthCheck
-- 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.HealthCheck 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.CloudWatchAlarmConfiguration
import Amazonka.Route53.Types.HealthCheckConfig
import Amazonka.Route53.Types.LinkedService

-- | A complex type that contains information about one health check that is
-- associated with the current Amazon Web Services account.
--
-- /See:/ 'newHealthCheck' smart constructor.
data HealthCheck = HealthCheck'
  { -- | If the health check was created by another service, the service that
    -- created the health check. When a health check is created by another
    -- service, you can\'t edit or delete it using Amazon Route 53.
    HealthCheck -> Maybe LinkedService
linkedService :: Prelude.Maybe LinkedService,
    -- | A complex type that contains information about the CloudWatch alarm that
    -- Amazon Route 53 is monitoring for this health check.
    HealthCheck -> Maybe CloudWatchAlarmConfiguration
cloudWatchAlarmConfiguration :: Prelude.Maybe CloudWatchAlarmConfiguration,
    -- | The identifier that Amazon Route 53 assigned to the health check when
    -- you created it. When you add or update a resource record set, you use
    -- this value to specify which health check to use. The value can be up to
    -- 64 characters long.
    HealthCheck -> Text
id :: Prelude.Text,
    -- | A unique string that you specified when you created the health check.
    HealthCheck -> Text
callerReference :: Prelude.Text,
    -- | A complex type that contains detailed information about one health
    -- check.
    HealthCheck -> HealthCheckConfig
healthCheckConfig :: HealthCheckConfig,
    -- | The version of the health check. You can optionally pass this value in a
    -- call to @UpdateHealthCheck@ to prevent overwriting another change to the
    -- health check.
    HealthCheck -> Natural
healthCheckVersion :: Prelude.Natural
  }
  deriving (HealthCheck -> HealthCheck -> Bool
(HealthCheck -> HealthCheck -> Bool)
-> (HealthCheck -> HealthCheck -> Bool) -> Eq HealthCheck
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HealthCheck -> HealthCheck -> Bool
$c/= :: HealthCheck -> HealthCheck -> Bool
== :: HealthCheck -> HealthCheck -> Bool
$c== :: HealthCheck -> HealthCheck -> Bool
Prelude.Eq, ReadPrec [HealthCheck]
ReadPrec HealthCheck
Int -> ReadS HealthCheck
ReadS [HealthCheck]
(Int -> ReadS HealthCheck)
-> ReadS [HealthCheck]
-> ReadPrec HealthCheck
-> ReadPrec [HealthCheck]
-> Read HealthCheck
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HealthCheck]
$creadListPrec :: ReadPrec [HealthCheck]
readPrec :: ReadPrec HealthCheck
$creadPrec :: ReadPrec HealthCheck
readList :: ReadS [HealthCheck]
$creadList :: ReadS [HealthCheck]
readsPrec :: Int -> ReadS HealthCheck
$creadsPrec :: Int -> ReadS HealthCheck
Prelude.Read, Int -> HealthCheck -> ShowS
[HealthCheck] -> ShowS
HealthCheck -> String
(Int -> HealthCheck -> ShowS)
-> (HealthCheck -> String)
-> ([HealthCheck] -> ShowS)
-> Show HealthCheck
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HealthCheck] -> ShowS
$cshowList :: [HealthCheck] -> ShowS
show :: HealthCheck -> String
$cshow :: HealthCheck -> String
showsPrec :: Int -> HealthCheck -> ShowS
$cshowsPrec :: Int -> HealthCheck -> ShowS
Prelude.Show, (forall x. HealthCheck -> Rep HealthCheck x)
-> (forall x. Rep HealthCheck x -> HealthCheck)
-> Generic HealthCheck
forall x. Rep HealthCheck x -> HealthCheck
forall x. HealthCheck -> Rep HealthCheck x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HealthCheck x -> HealthCheck
$cfrom :: forall x. HealthCheck -> Rep HealthCheck x
Prelude.Generic)

-- |
-- Create a value of 'HealthCheck' 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:
--
-- 'linkedService', 'healthCheck_linkedService' - If the health check was created by another service, the service that
-- created the health check. When a health check is created by another
-- service, you can\'t edit or delete it using Amazon Route 53.
--
-- 'cloudWatchAlarmConfiguration', 'healthCheck_cloudWatchAlarmConfiguration' - A complex type that contains information about the CloudWatch alarm that
-- Amazon Route 53 is monitoring for this health check.
--
-- 'id', 'healthCheck_id' - The identifier that Amazon Route 53 assigned to the health check when
-- you created it. When you add or update a resource record set, you use
-- this value to specify which health check to use. The value can be up to
-- 64 characters long.
--
-- 'callerReference', 'healthCheck_callerReference' - A unique string that you specified when you created the health check.
--
-- 'healthCheckConfig', 'healthCheck_healthCheckConfig' - A complex type that contains detailed information about one health
-- check.
--
-- 'healthCheckVersion', 'healthCheck_healthCheckVersion' - The version of the health check. You can optionally pass this value in a
-- call to @UpdateHealthCheck@ to prevent overwriting another change to the
-- health check.
newHealthCheck ::
  -- | 'id'
  Prelude.Text ->
  -- | 'callerReference'
  Prelude.Text ->
  -- | 'healthCheckConfig'
  HealthCheckConfig ->
  -- | 'healthCheckVersion'
  Prelude.Natural ->
  HealthCheck
newHealthCheck :: Text -> Text -> HealthCheckConfig -> Natural -> HealthCheck
newHealthCheck
  Text
pId_
  Text
pCallerReference_
  HealthCheckConfig
pHealthCheckConfig_
  Natural
pHealthCheckVersion_ =
    HealthCheck' :: Maybe LinkedService
-> Maybe CloudWatchAlarmConfiguration
-> Text
-> Text
-> HealthCheckConfig
-> Natural
-> HealthCheck
HealthCheck'
      { $sel:linkedService:HealthCheck' :: Maybe LinkedService
linkedService = Maybe LinkedService
forall a. Maybe a
Prelude.Nothing,
        $sel:cloudWatchAlarmConfiguration:HealthCheck' :: Maybe CloudWatchAlarmConfiguration
cloudWatchAlarmConfiguration = Maybe CloudWatchAlarmConfiguration
forall a. Maybe a
Prelude.Nothing,
        $sel:id:HealthCheck' :: Text
id = Text
pId_,
        $sel:callerReference:HealthCheck' :: Text
callerReference = Text
pCallerReference_,
        $sel:healthCheckConfig:HealthCheck' :: HealthCheckConfig
healthCheckConfig = HealthCheckConfig
pHealthCheckConfig_,
        $sel:healthCheckVersion:HealthCheck' :: Natural
healthCheckVersion = Natural
pHealthCheckVersion_
      }

-- | If the health check was created by another service, the service that
-- created the health check. When a health check is created by another
-- service, you can\'t edit or delete it using Amazon Route 53.
healthCheck_linkedService :: Lens.Lens' HealthCheck (Prelude.Maybe LinkedService)
healthCheck_linkedService :: (Maybe LinkedService -> f (Maybe LinkedService))
-> HealthCheck -> f HealthCheck
healthCheck_linkedService = (HealthCheck -> Maybe LinkedService)
-> (HealthCheck -> Maybe LinkedService -> HealthCheck)
-> Lens
     HealthCheck HealthCheck (Maybe LinkedService) (Maybe LinkedService)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheck' {Maybe LinkedService
linkedService :: Maybe LinkedService
$sel:linkedService:HealthCheck' :: HealthCheck -> Maybe LinkedService
linkedService} -> Maybe LinkedService
linkedService) (\s :: HealthCheck
s@HealthCheck' {} Maybe LinkedService
a -> HealthCheck
s {$sel:linkedService:HealthCheck' :: Maybe LinkedService
linkedService = Maybe LinkedService
a} :: HealthCheck)

-- | A complex type that contains information about the CloudWatch alarm that
-- Amazon Route 53 is monitoring for this health check.
healthCheck_cloudWatchAlarmConfiguration :: Lens.Lens' HealthCheck (Prelude.Maybe CloudWatchAlarmConfiguration)
healthCheck_cloudWatchAlarmConfiguration :: (Maybe CloudWatchAlarmConfiguration
 -> f (Maybe CloudWatchAlarmConfiguration))
-> HealthCheck -> f HealthCheck
healthCheck_cloudWatchAlarmConfiguration = (HealthCheck -> Maybe CloudWatchAlarmConfiguration)
-> (HealthCheck
    -> Maybe CloudWatchAlarmConfiguration -> HealthCheck)
-> Lens
     HealthCheck
     HealthCheck
     (Maybe CloudWatchAlarmConfiguration)
     (Maybe CloudWatchAlarmConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheck' {Maybe CloudWatchAlarmConfiguration
cloudWatchAlarmConfiguration :: Maybe CloudWatchAlarmConfiguration
$sel:cloudWatchAlarmConfiguration:HealthCheck' :: HealthCheck -> Maybe CloudWatchAlarmConfiguration
cloudWatchAlarmConfiguration} -> Maybe CloudWatchAlarmConfiguration
cloudWatchAlarmConfiguration) (\s :: HealthCheck
s@HealthCheck' {} Maybe CloudWatchAlarmConfiguration
a -> HealthCheck
s {$sel:cloudWatchAlarmConfiguration:HealthCheck' :: Maybe CloudWatchAlarmConfiguration
cloudWatchAlarmConfiguration = Maybe CloudWatchAlarmConfiguration
a} :: HealthCheck)

-- | The identifier that Amazon Route 53 assigned to the health check when
-- you created it. When you add or update a resource record set, you use
-- this value to specify which health check to use. The value can be up to
-- 64 characters long.
healthCheck_id :: Lens.Lens' HealthCheck Prelude.Text
healthCheck_id :: (Text -> f Text) -> HealthCheck -> f HealthCheck
healthCheck_id = (HealthCheck -> Text)
-> (HealthCheck -> Text -> HealthCheck)
-> Lens HealthCheck HealthCheck Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheck' {Text
id :: Text
$sel:id:HealthCheck' :: HealthCheck -> Text
id} -> Text
id) (\s :: HealthCheck
s@HealthCheck' {} Text
a -> HealthCheck
s {$sel:id:HealthCheck' :: Text
id = Text
a} :: HealthCheck)

-- | A unique string that you specified when you created the health check.
healthCheck_callerReference :: Lens.Lens' HealthCheck Prelude.Text
healthCheck_callerReference :: (Text -> f Text) -> HealthCheck -> f HealthCheck
healthCheck_callerReference = (HealthCheck -> Text)
-> (HealthCheck -> Text -> HealthCheck)
-> Lens HealthCheck HealthCheck Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheck' {Text
callerReference :: Text
$sel:callerReference:HealthCheck' :: HealthCheck -> Text
callerReference} -> Text
callerReference) (\s :: HealthCheck
s@HealthCheck' {} Text
a -> HealthCheck
s {$sel:callerReference:HealthCheck' :: Text
callerReference = Text
a} :: HealthCheck)

-- | A complex type that contains detailed information about one health
-- check.
healthCheck_healthCheckConfig :: Lens.Lens' HealthCheck HealthCheckConfig
healthCheck_healthCheckConfig :: (HealthCheckConfig -> f HealthCheckConfig)
-> HealthCheck -> f HealthCheck
healthCheck_healthCheckConfig = (HealthCheck -> HealthCheckConfig)
-> (HealthCheck -> HealthCheckConfig -> HealthCheck)
-> Lens HealthCheck HealthCheck HealthCheckConfig HealthCheckConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheck' {HealthCheckConfig
healthCheckConfig :: HealthCheckConfig
$sel:healthCheckConfig:HealthCheck' :: HealthCheck -> HealthCheckConfig
healthCheckConfig} -> HealthCheckConfig
healthCheckConfig) (\s :: HealthCheck
s@HealthCheck' {} HealthCheckConfig
a -> HealthCheck
s {$sel:healthCheckConfig:HealthCheck' :: HealthCheckConfig
healthCheckConfig = HealthCheckConfig
a} :: HealthCheck)

-- | The version of the health check. You can optionally pass this value in a
-- call to @UpdateHealthCheck@ to prevent overwriting another change to the
-- health check.
healthCheck_healthCheckVersion :: Lens.Lens' HealthCheck Prelude.Natural
healthCheck_healthCheckVersion :: (Natural -> f Natural) -> HealthCheck -> f HealthCheck
healthCheck_healthCheckVersion = (HealthCheck -> Natural)
-> (HealthCheck -> Natural -> HealthCheck)
-> Lens HealthCheck HealthCheck Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HealthCheck' {Natural
healthCheckVersion :: Natural
$sel:healthCheckVersion:HealthCheck' :: HealthCheck -> Natural
healthCheckVersion} -> Natural
healthCheckVersion) (\s :: HealthCheck
s@HealthCheck' {} Natural
a -> HealthCheck
s {$sel:healthCheckVersion:HealthCheck' :: Natural
healthCheckVersion = Natural
a} :: HealthCheck)

instance Core.FromXML HealthCheck where
  parseXML :: [Node] -> Either String HealthCheck
parseXML [Node]
x =
    Maybe LinkedService
-> Maybe CloudWatchAlarmConfiguration
-> Text
-> Text
-> HealthCheckConfig
-> Natural
-> HealthCheck
HealthCheck'
      (Maybe LinkedService
 -> Maybe CloudWatchAlarmConfiguration
 -> Text
 -> Text
 -> HealthCheckConfig
 -> Natural
 -> HealthCheck)
-> Either String (Maybe LinkedService)
-> Either
     String
     (Maybe CloudWatchAlarmConfiguration
      -> Text -> Text -> HealthCheckConfig -> Natural -> HealthCheck)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe LinkedService)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LinkedService")
      Either
  String
  (Maybe CloudWatchAlarmConfiguration
   -> Text -> Text -> HealthCheckConfig -> Natural -> HealthCheck)
-> Either String (Maybe CloudWatchAlarmConfiguration)
-> Either
     String
     (Text -> Text -> HealthCheckConfig -> Natural -> HealthCheck)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node]
-> Text -> Either String (Maybe CloudWatchAlarmConfiguration)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CloudWatchAlarmConfiguration")
      Either
  String
  (Text -> Text -> HealthCheckConfig -> Natural -> HealthCheck)
-> Either String Text
-> Either
     String (Text -> HealthCheckConfig -> Natural -> HealthCheck)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Id")
      Either String (Text -> HealthCheckConfig -> Natural -> HealthCheck)
-> Either String Text
-> Either String (HealthCheckConfig -> Natural -> HealthCheck)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"CallerReference")
      Either String (HealthCheckConfig -> Natural -> HealthCheck)
-> Either String HealthCheckConfig
-> Either String (Natural -> HealthCheck)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String HealthCheckConfig
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"HealthCheckConfig")
      Either String (Natural -> HealthCheck)
-> Either String Natural -> Either String HealthCheck
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Natural
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"HealthCheckVersion")

instance Prelude.Hashable HealthCheck

instance Prelude.NFData HealthCheck