{-# 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.AlarmIdentifier
-- 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.AlarmIdentifier 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.CloudWatchRegion

-- | A complex type that identifies the CloudWatch alarm that you want Amazon
-- Route 53 health checkers to use to determine whether the specified
-- health check is healthy.
--
-- /See:/ 'newAlarmIdentifier' smart constructor.
data AlarmIdentifier = AlarmIdentifier'
  { -- | For the CloudWatch alarm that you want Route 53 health checkers to use
    -- to determine whether this health check is healthy, the region that the
    -- alarm was created in.
    --
    -- For the current list of CloudWatch regions, see
    -- <https://docs.aws.amazon.com/general/latest/gr/cw_region.html Amazon CloudWatch endpoints and quotas>
    -- in the /Amazon Web Services General Reference/.
    AlarmIdentifier -> CloudWatchRegion
region :: CloudWatchRegion,
    -- | The name of the CloudWatch alarm that you want Amazon Route 53 health
    -- checkers to use to determine whether this health check is healthy.
    --
    -- Route 53 supports CloudWatch alarms with the following features:
    --
    -- -   Standard-resolution metrics. High-resolution metrics aren\'t
    --     supported. For more information, see
    --     <https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/publishingMetrics.html#high-resolution-metrics High-Resolution Metrics>
    --     in the /Amazon CloudWatch User Guide/.
    --
    -- -   Statistics: Average, Minimum, Maximum, Sum, and SampleCount.
    --     Extended statistics aren\'t supported.
    AlarmIdentifier -> Text
name :: Prelude.Text
  }
  deriving (AlarmIdentifier -> AlarmIdentifier -> Bool
(AlarmIdentifier -> AlarmIdentifier -> Bool)
-> (AlarmIdentifier -> AlarmIdentifier -> Bool)
-> Eq AlarmIdentifier
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlarmIdentifier -> AlarmIdentifier -> Bool
$c/= :: AlarmIdentifier -> AlarmIdentifier -> Bool
== :: AlarmIdentifier -> AlarmIdentifier -> Bool
$c== :: AlarmIdentifier -> AlarmIdentifier -> Bool
Prelude.Eq, ReadPrec [AlarmIdentifier]
ReadPrec AlarmIdentifier
Int -> ReadS AlarmIdentifier
ReadS [AlarmIdentifier]
(Int -> ReadS AlarmIdentifier)
-> ReadS [AlarmIdentifier]
-> ReadPrec AlarmIdentifier
-> ReadPrec [AlarmIdentifier]
-> Read AlarmIdentifier
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlarmIdentifier]
$creadListPrec :: ReadPrec [AlarmIdentifier]
readPrec :: ReadPrec AlarmIdentifier
$creadPrec :: ReadPrec AlarmIdentifier
readList :: ReadS [AlarmIdentifier]
$creadList :: ReadS [AlarmIdentifier]
readsPrec :: Int -> ReadS AlarmIdentifier
$creadsPrec :: Int -> ReadS AlarmIdentifier
Prelude.Read, Int -> AlarmIdentifier -> ShowS
[AlarmIdentifier] -> ShowS
AlarmIdentifier -> String
(Int -> AlarmIdentifier -> ShowS)
-> (AlarmIdentifier -> String)
-> ([AlarmIdentifier] -> ShowS)
-> Show AlarmIdentifier
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AlarmIdentifier] -> ShowS
$cshowList :: [AlarmIdentifier] -> ShowS
show :: AlarmIdentifier -> String
$cshow :: AlarmIdentifier -> String
showsPrec :: Int -> AlarmIdentifier -> ShowS
$cshowsPrec :: Int -> AlarmIdentifier -> ShowS
Prelude.Show, (forall x. AlarmIdentifier -> Rep AlarmIdentifier x)
-> (forall x. Rep AlarmIdentifier x -> AlarmIdentifier)
-> Generic AlarmIdentifier
forall x. Rep AlarmIdentifier x -> AlarmIdentifier
forall x. AlarmIdentifier -> Rep AlarmIdentifier x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AlarmIdentifier x -> AlarmIdentifier
$cfrom :: forall x. AlarmIdentifier -> Rep AlarmIdentifier x
Prelude.Generic)

-- |
-- Create a value of 'AlarmIdentifier' 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:
--
-- 'region', 'alarmIdentifier_region' - For the CloudWatch alarm that you want Route 53 health checkers to use
-- to determine whether this health check is healthy, the region that the
-- alarm was created in.
--
-- For the current list of CloudWatch regions, see
-- <https://docs.aws.amazon.com/general/latest/gr/cw_region.html Amazon CloudWatch endpoints and quotas>
-- in the /Amazon Web Services General Reference/.
--
-- 'name', 'alarmIdentifier_name' - The name of the CloudWatch alarm that you want Amazon Route 53 health
-- checkers to use to determine whether this health check is healthy.
--
-- Route 53 supports CloudWatch alarms with the following features:
--
-- -   Standard-resolution metrics. High-resolution metrics aren\'t
--     supported. For more information, see
--     <https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/publishingMetrics.html#high-resolution-metrics High-Resolution Metrics>
--     in the /Amazon CloudWatch User Guide/.
--
-- -   Statistics: Average, Minimum, Maximum, Sum, and SampleCount.
--     Extended statistics aren\'t supported.
newAlarmIdentifier ::
  -- | 'region'
  CloudWatchRegion ->
  -- | 'name'
  Prelude.Text ->
  AlarmIdentifier
newAlarmIdentifier :: CloudWatchRegion -> Text -> AlarmIdentifier
newAlarmIdentifier CloudWatchRegion
pRegion_ Text
pName_ =
  AlarmIdentifier' :: CloudWatchRegion -> Text -> AlarmIdentifier
AlarmIdentifier' {$sel:region:AlarmIdentifier' :: CloudWatchRegion
region = CloudWatchRegion
pRegion_, $sel:name:AlarmIdentifier' :: Text
name = Text
pName_}

-- | For the CloudWatch alarm that you want Route 53 health checkers to use
-- to determine whether this health check is healthy, the region that the
-- alarm was created in.
--
-- For the current list of CloudWatch regions, see
-- <https://docs.aws.amazon.com/general/latest/gr/cw_region.html Amazon CloudWatch endpoints and quotas>
-- in the /Amazon Web Services General Reference/.
alarmIdentifier_region :: Lens.Lens' AlarmIdentifier CloudWatchRegion
alarmIdentifier_region :: (CloudWatchRegion -> f CloudWatchRegion)
-> AlarmIdentifier -> f AlarmIdentifier
alarmIdentifier_region = (AlarmIdentifier -> CloudWatchRegion)
-> (AlarmIdentifier -> CloudWatchRegion -> AlarmIdentifier)
-> Lens
     AlarmIdentifier AlarmIdentifier CloudWatchRegion CloudWatchRegion
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmIdentifier' {CloudWatchRegion
region :: CloudWatchRegion
$sel:region:AlarmIdentifier' :: AlarmIdentifier -> CloudWatchRegion
region} -> CloudWatchRegion
region) (\s :: AlarmIdentifier
s@AlarmIdentifier' {} CloudWatchRegion
a -> AlarmIdentifier
s {$sel:region:AlarmIdentifier' :: CloudWatchRegion
region = CloudWatchRegion
a} :: AlarmIdentifier)

-- | The name of the CloudWatch alarm that you want Amazon Route 53 health
-- checkers to use to determine whether this health check is healthy.
--
-- Route 53 supports CloudWatch alarms with the following features:
--
-- -   Standard-resolution metrics. High-resolution metrics aren\'t
--     supported. For more information, see
--     <https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/publishingMetrics.html#high-resolution-metrics High-Resolution Metrics>
--     in the /Amazon CloudWatch User Guide/.
--
-- -   Statistics: Average, Minimum, Maximum, Sum, and SampleCount.
--     Extended statistics aren\'t supported.
alarmIdentifier_name :: Lens.Lens' AlarmIdentifier Prelude.Text
alarmIdentifier_name :: (Text -> f Text) -> AlarmIdentifier -> f AlarmIdentifier
alarmIdentifier_name = (AlarmIdentifier -> Text)
-> (AlarmIdentifier -> Text -> AlarmIdentifier)
-> Lens AlarmIdentifier AlarmIdentifier Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmIdentifier' {Text
name :: Text
$sel:name:AlarmIdentifier' :: AlarmIdentifier -> Text
name} -> Text
name) (\s :: AlarmIdentifier
s@AlarmIdentifier' {} Text
a -> AlarmIdentifier
s {$sel:name:AlarmIdentifier' :: Text
name = Text
a} :: AlarmIdentifier)

instance Core.FromXML AlarmIdentifier where
  parseXML :: [Node] -> Either String AlarmIdentifier
parseXML [Node]
x =
    CloudWatchRegion -> Text -> AlarmIdentifier
AlarmIdentifier'
      (CloudWatchRegion -> Text -> AlarmIdentifier)
-> Either String CloudWatchRegion
-> Either String (Text -> AlarmIdentifier)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String CloudWatchRegion
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Region") Either String (Text -> AlarmIdentifier)
-> Either String Text -> Either String AlarmIdentifier
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
"Name")

instance Prelude.Hashable AlarmIdentifier

instance Prelude.NFData AlarmIdentifier

instance Core.ToXML AlarmIdentifier where
  toXML :: AlarmIdentifier -> XML
toXML AlarmIdentifier' {Text
CloudWatchRegion
name :: Text
region :: CloudWatchRegion
$sel:name:AlarmIdentifier' :: AlarmIdentifier -> Text
$sel:region:AlarmIdentifier' :: AlarmIdentifier -> CloudWatchRegion
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [Name
"Region" Name -> CloudWatchRegion -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= CloudWatchRegion
region, Name
"Name" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
name]