{-# 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.ApplicationAutoScaling.Types.Alarm
-- 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.ApplicationAutoScaling.Types.Alarm 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

-- | Represents a CloudWatch alarm associated with a scaling policy.
--
-- /See:/ 'newAlarm' smart constructor.
data Alarm = Alarm'
  { -- | The name of the alarm.
    Alarm -> Text
alarmName :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the alarm.
    Alarm -> Text
alarmARN :: Prelude.Text
  }
  deriving (Alarm -> Alarm -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Alarm -> Alarm -> Bool
$c/= :: Alarm -> Alarm -> Bool
== :: Alarm -> Alarm -> Bool
$c== :: Alarm -> Alarm -> Bool
Prelude.Eq, ReadPrec [Alarm]
ReadPrec Alarm
Int -> ReadS Alarm
ReadS [Alarm]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Alarm]
$creadListPrec :: ReadPrec [Alarm]
readPrec :: ReadPrec Alarm
$creadPrec :: ReadPrec Alarm
readList :: ReadS [Alarm]
$creadList :: ReadS [Alarm]
readsPrec :: Int -> ReadS Alarm
$creadsPrec :: Int -> ReadS Alarm
Prelude.Read, Int -> Alarm -> ShowS
[Alarm] -> ShowS
Alarm -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Alarm] -> ShowS
$cshowList :: [Alarm] -> ShowS
show :: Alarm -> String
$cshow :: Alarm -> String
showsPrec :: Int -> Alarm -> ShowS
$cshowsPrec :: Int -> Alarm -> ShowS
Prelude.Show, forall x. Rep Alarm x -> Alarm
forall x. Alarm -> Rep Alarm x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Alarm x -> Alarm
$cfrom :: forall x. Alarm -> Rep Alarm x
Prelude.Generic)

-- |
-- Create a value of 'Alarm' 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:
--
-- 'alarmName', 'alarm_alarmName' - The name of the alarm.
--
-- 'alarmARN', 'alarm_alarmARN' - The Amazon Resource Name (ARN) of the alarm.
newAlarm ::
  -- | 'alarmName'
  Prelude.Text ->
  -- | 'alarmARN'
  Prelude.Text ->
  Alarm
newAlarm :: Text -> Text -> Alarm
newAlarm Text
pAlarmName_ Text
pAlarmARN_ =
  Alarm'
    { $sel:alarmName:Alarm' :: Text
alarmName = Text
pAlarmName_,
      $sel:alarmARN:Alarm' :: Text
alarmARN = Text
pAlarmARN_
    }

-- | The name of the alarm.
alarm_alarmName :: Lens.Lens' Alarm Prelude.Text
alarm_alarmName :: Lens' Alarm Text
alarm_alarmName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alarm' {Text
alarmName :: Text
$sel:alarmName:Alarm' :: Alarm -> Text
alarmName} -> Text
alarmName) (\s :: Alarm
s@Alarm' {} Text
a -> Alarm
s {$sel:alarmName:Alarm' :: Text
alarmName = Text
a} :: Alarm)

-- | The Amazon Resource Name (ARN) of the alarm.
alarm_alarmARN :: Lens.Lens' Alarm Prelude.Text
alarm_alarmARN :: Lens' Alarm Text
alarm_alarmARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alarm' {Text
alarmARN :: Text
$sel:alarmARN:Alarm' :: Alarm -> Text
alarmARN} -> Text
alarmARN) (\s :: Alarm
s@Alarm' {} Text
a -> Alarm
s {$sel:alarmARN:Alarm' :: Text
alarmARN = Text
a} :: Alarm)

instance Data.FromJSON Alarm where
  parseJSON :: Value -> Parser Alarm
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Alarm"
      ( \Object
x ->
          Text -> Text -> Alarm
Alarm'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AlarmName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AlarmARN")
      )

instance Prelude.Hashable Alarm where
  hashWithSalt :: Int -> Alarm -> Int
hashWithSalt Int
_salt Alarm' {Text
alarmARN :: Text
alarmName :: Text
$sel:alarmARN:Alarm' :: Alarm -> Text
$sel:alarmName:Alarm' :: Alarm -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
alarmName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
alarmARN

instance Prelude.NFData Alarm where
  rnf :: Alarm -> ()
rnf Alarm' {Text
alarmARN :: Text
alarmName :: Text
$sel:alarmARN:Alarm' :: Alarm -> Text
$sel:alarmName:Alarm' :: Alarm -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
alarmName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
alarmARN