{-# 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.CloudWatch.Types.AlarmHistoryItem
-- 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.CloudWatch.Types.AlarmHistoryItem where

import Amazonka.CloudWatch.Types.AlarmType
import Amazonka.CloudWatch.Types.HistoryItemType
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 the history of a specific alarm.
--
-- /See:/ 'newAlarmHistoryItem' smart constructor.
data AlarmHistoryItem = AlarmHistoryItem'
  { -- | The descriptive name for the alarm.
    AlarmHistoryItem -> Maybe Text
alarmName :: Prelude.Maybe Prelude.Text,
    -- | The type of alarm, either metric alarm or composite alarm.
    AlarmHistoryItem -> Maybe AlarmType
alarmType :: Prelude.Maybe AlarmType,
    -- | Data about the alarm, in JSON format.
    AlarmHistoryItem -> Maybe Text
historyData :: Prelude.Maybe Prelude.Text,
    -- | The type of alarm history item.
    AlarmHistoryItem -> Maybe HistoryItemType
historyItemType :: Prelude.Maybe HistoryItemType,
    -- | A summary of the alarm history, in text format.
    AlarmHistoryItem -> Maybe Text
historySummary :: Prelude.Maybe Prelude.Text,
    -- | The time stamp for the alarm history item.
    AlarmHistoryItem -> Maybe ISO8601
timestamp :: Prelude.Maybe Data.ISO8601
  }
  deriving (AlarmHistoryItem -> AlarmHistoryItem -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlarmHistoryItem -> AlarmHistoryItem -> Bool
$c/= :: AlarmHistoryItem -> AlarmHistoryItem -> Bool
== :: AlarmHistoryItem -> AlarmHistoryItem -> Bool
$c== :: AlarmHistoryItem -> AlarmHistoryItem -> Bool
Prelude.Eq, ReadPrec [AlarmHistoryItem]
ReadPrec AlarmHistoryItem
Int -> ReadS AlarmHistoryItem
ReadS [AlarmHistoryItem]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlarmHistoryItem]
$creadListPrec :: ReadPrec [AlarmHistoryItem]
readPrec :: ReadPrec AlarmHistoryItem
$creadPrec :: ReadPrec AlarmHistoryItem
readList :: ReadS [AlarmHistoryItem]
$creadList :: ReadS [AlarmHistoryItem]
readsPrec :: Int -> ReadS AlarmHistoryItem
$creadsPrec :: Int -> ReadS AlarmHistoryItem
Prelude.Read, Int -> AlarmHistoryItem -> ShowS
[AlarmHistoryItem] -> ShowS
AlarmHistoryItem -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AlarmHistoryItem] -> ShowS
$cshowList :: [AlarmHistoryItem] -> ShowS
show :: AlarmHistoryItem -> String
$cshow :: AlarmHistoryItem -> String
showsPrec :: Int -> AlarmHistoryItem -> ShowS
$cshowsPrec :: Int -> AlarmHistoryItem -> ShowS
Prelude.Show, forall x. Rep AlarmHistoryItem x -> AlarmHistoryItem
forall x. AlarmHistoryItem -> Rep AlarmHistoryItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AlarmHistoryItem x -> AlarmHistoryItem
$cfrom :: forall x. AlarmHistoryItem -> Rep AlarmHistoryItem x
Prelude.Generic)

-- |
-- Create a value of 'AlarmHistoryItem' 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', 'alarmHistoryItem_alarmName' - The descriptive name for the alarm.
--
-- 'alarmType', 'alarmHistoryItem_alarmType' - The type of alarm, either metric alarm or composite alarm.
--
-- 'historyData', 'alarmHistoryItem_historyData' - Data about the alarm, in JSON format.
--
-- 'historyItemType', 'alarmHistoryItem_historyItemType' - The type of alarm history item.
--
-- 'historySummary', 'alarmHistoryItem_historySummary' - A summary of the alarm history, in text format.
--
-- 'timestamp', 'alarmHistoryItem_timestamp' - The time stamp for the alarm history item.
newAlarmHistoryItem ::
  AlarmHistoryItem
newAlarmHistoryItem :: AlarmHistoryItem
newAlarmHistoryItem =
  AlarmHistoryItem'
    { $sel:alarmName:AlarmHistoryItem' :: Maybe Text
alarmName = forall a. Maybe a
Prelude.Nothing,
      $sel:alarmType:AlarmHistoryItem' :: Maybe AlarmType
alarmType = forall a. Maybe a
Prelude.Nothing,
      $sel:historyData:AlarmHistoryItem' :: Maybe Text
historyData = forall a. Maybe a
Prelude.Nothing,
      $sel:historyItemType:AlarmHistoryItem' :: Maybe HistoryItemType
historyItemType = forall a. Maybe a
Prelude.Nothing,
      $sel:historySummary:AlarmHistoryItem' :: Maybe Text
historySummary = forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:AlarmHistoryItem' :: Maybe ISO8601
timestamp = forall a. Maybe a
Prelude.Nothing
    }

-- | The descriptive name for the alarm.
alarmHistoryItem_alarmName :: Lens.Lens' AlarmHistoryItem (Prelude.Maybe Prelude.Text)
alarmHistoryItem_alarmName :: Lens' AlarmHistoryItem (Maybe Text)
alarmHistoryItem_alarmName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmHistoryItem' {Maybe Text
alarmName :: Maybe Text
$sel:alarmName:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe Text
alarmName} -> Maybe Text
alarmName) (\s :: AlarmHistoryItem
s@AlarmHistoryItem' {} Maybe Text
a -> AlarmHistoryItem
s {$sel:alarmName:AlarmHistoryItem' :: Maybe Text
alarmName = Maybe Text
a} :: AlarmHistoryItem)

-- | The type of alarm, either metric alarm or composite alarm.
alarmHistoryItem_alarmType :: Lens.Lens' AlarmHistoryItem (Prelude.Maybe AlarmType)
alarmHistoryItem_alarmType :: Lens' AlarmHistoryItem (Maybe AlarmType)
alarmHistoryItem_alarmType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmHistoryItem' {Maybe AlarmType
alarmType :: Maybe AlarmType
$sel:alarmType:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe AlarmType
alarmType} -> Maybe AlarmType
alarmType) (\s :: AlarmHistoryItem
s@AlarmHistoryItem' {} Maybe AlarmType
a -> AlarmHistoryItem
s {$sel:alarmType:AlarmHistoryItem' :: Maybe AlarmType
alarmType = Maybe AlarmType
a} :: AlarmHistoryItem)

-- | Data about the alarm, in JSON format.
alarmHistoryItem_historyData :: Lens.Lens' AlarmHistoryItem (Prelude.Maybe Prelude.Text)
alarmHistoryItem_historyData :: Lens' AlarmHistoryItem (Maybe Text)
alarmHistoryItem_historyData = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmHistoryItem' {Maybe Text
historyData :: Maybe Text
$sel:historyData:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe Text
historyData} -> Maybe Text
historyData) (\s :: AlarmHistoryItem
s@AlarmHistoryItem' {} Maybe Text
a -> AlarmHistoryItem
s {$sel:historyData:AlarmHistoryItem' :: Maybe Text
historyData = Maybe Text
a} :: AlarmHistoryItem)

-- | The type of alarm history item.
alarmHistoryItem_historyItemType :: Lens.Lens' AlarmHistoryItem (Prelude.Maybe HistoryItemType)
alarmHistoryItem_historyItemType :: Lens' AlarmHistoryItem (Maybe HistoryItemType)
alarmHistoryItem_historyItemType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmHistoryItem' {Maybe HistoryItemType
historyItemType :: Maybe HistoryItemType
$sel:historyItemType:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe HistoryItemType
historyItemType} -> Maybe HistoryItemType
historyItemType) (\s :: AlarmHistoryItem
s@AlarmHistoryItem' {} Maybe HistoryItemType
a -> AlarmHistoryItem
s {$sel:historyItemType:AlarmHistoryItem' :: Maybe HistoryItemType
historyItemType = Maybe HistoryItemType
a} :: AlarmHistoryItem)

-- | A summary of the alarm history, in text format.
alarmHistoryItem_historySummary :: Lens.Lens' AlarmHistoryItem (Prelude.Maybe Prelude.Text)
alarmHistoryItem_historySummary :: Lens' AlarmHistoryItem (Maybe Text)
alarmHistoryItem_historySummary = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmHistoryItem' {Maybe Text
historySummary :: Maybe Text
$sel:historySummary:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe Text
historySummary} -> Maybe Text
historySummary) (\s :: AlarmHistoryItem
s@AlarmHistoryItem' {} Maybe Text
a -> AlarmHistoryItem
s {$sel:historySummary:AlarmHistoryItem' :: Maybe Text
historySummary = Maybe Text
a} :: AlarmHistoryItem)

-- | The time stamp for the alarm history item.
alarmHistoryItem_timestamp :: Lens.Lens' AlarmHistoryItem (Prelude.Maybe Prelude.UTCTime)
alarmHistoryItem_timestamp :: Lens' AlarmHistoryItem (Maybe UTCTime)
alarmHistoryItem_timestamp = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmHistoryItem' {Maybe ISO8601
timestamp :: Maybe ISO8601
$sel:timestamp:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe ISO8601
timestamp} -> Maybe ISO8601
timestamp) (\s :: AlarmHistoryItem
s@AlarmHistoryItem' {} Maybe ISO8601
a -> AlarmHistoryItem
s {$sel:timestamp:AlarmHistoryItem' :: Maybe ISO8601
timestamp = Maybe ISO8601
a} :: AlarmHistoryItem) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

instance Data.FromXML AlarmHistoryItem where
  parseXML :: [Node] -> Either String AlarmHistoryItem
parseXML [Node]
x =
    Maybe Text
-> Maybe AlarmType
-> Maybe Text
-> Maybe HistoryItemType
-> Maybe Text
-> Maybe ISO8601
-> AlarmHistoryItem
AlarmHistoryItem'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"AlarmName")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"AlarmType")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"HistoryData")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"HistoryItemType")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"HistorySummary")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Timestamp")

instance Prelude.Hashable AlarmHistoryItem where
  hashWithSalt :: Int -> AlarmHistoryItem -> Int
hashWithSalt Int
_salt AlarmHistoryItem' {Maybe Text
Maybe ISO8601
Maybe AlarmType
Maybe HistoryItemType
timestamp :: Maybe ISO8601
historySummary :: Maybe Text
historyItemType :: Maybe HistoryItemType
historyData :: Maybe Text
alarmType :: Maybe AlarmType
alarmName :: Maybe Text
$sel:timestamp:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe ISO8601
$sel:historySummary:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe Text
$sel:historyItemType:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe HistoryItemType
$sel:historyData:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe Text
$sel:alarmType:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe AlarmType
$sel:alarmName:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
alarmName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AlarmType
alarmType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
historyData
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe HistoryItemType
historyItemType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
historySummary
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
timestamp

instance Prelude.NFData AlarmHistoryItem where
  rnf :: AlarmHistoryItem -> ()
rnf AlarmHistoryItem' {Maybe Text
Maybe ISO8601
Maybe AlarmType
Maybe HistoryItemType
timestamp :: Maybe ISO8601
historySummary :: Maybe Text
historyItemType :: Maybe HistoryItemType
historyData :: Maybe Text
alarmType :: Maybe AlarmType
alarmName :: Maybe Text
$sel:timestamp:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe ISO8601
$sel:historySummary:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe Text
$sel:historyItemType:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe HistoryItemType
$sel:historyData:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe Text
$sel:alarmType:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe AlarmType
$sel:alarmName:AlarmHistoryItem' :: AlarmHistoryItem -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
alarmName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AlarmType
alarmType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
historyData
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe HistoryItemType
historyItemType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
historySummary
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
timestamp