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

import Amazonka.CloudWatch.Types.AlarmType
import Amazonka.CloudWatch.Types.HistoryItemType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 history item.
    AlarmHistoryItem -> Maybe HistoryItemType
historyItemType :: Prelude.Maybe HistoryItemType,
    -- | Data about the alarm, in JSON format.
    AlarmHistoryItem -> Maybe Text
historyData :: Prelude.Maybe Prelude.Text,
    -- | The type of alarm, either metric alarm or composite alarm.
    AlarmHistoryItem -> Maybe AlarmType
alarmType :: Prelude.Maybe AlarmType,
    -- | 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 Core.ISO8601
  }
  deriving (AlarmHistoryItem -> AlarmHistoryItem -> Bool
(AlarmHistoryItem -> AlarmHistoryItem -> Bool)
-> (AlarmHistoryItem -> AlarmHistoryItem -> Bool)
-> Eq AlarmHistoryItem
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]
(Int -> ReadS AlarmHistoryItem)
-> ReadS [AlarmHistoryItem]
-> ReadPrec AlarmHistoryItem
-> ReadPrec [AlarmHistoryItem]
-> Read 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
(Int -> AlarmHistoryItem -> ShowS)
-> (AlarmHistoryItem -> String)
-> ([AlarmHistoryItem] -> ShowS)
-> Show AlarmHistoryItem
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. AlarmHistoryItem -> Rep AlarmHistoryItem x)
-> (forall x. Rep AlarmHistoryItem x -> AlarmHistoryItem)
-> Generic AlarmHistoryItem
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.
--
-- 'historyItemType', 'alarmHistoryItem_historyItemType' - The type of alarm history item.
--
-- 'historyData', 'alarmHistoryItem_historyData' - Data about the alarm, in JSON format.
--
-- 'alarmType', 'alarmHistoryItem_alarmType' - The type of alarm, either metric alarm or composite alarm.
--
-- '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' :: Maybe Text
-> Maybe HistoryItemType
-> Maybe Text
-> Maybe AlarmType
-> Maybe Text
-> Maybe ISO8601
-> AlarmHistoryItem
AlarmHistoryItem'
    { $sel:alarmName:AlarmHistoryItem' :: Maybe Text
alarmName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:historyItemType:AlarmHistoryItem' :: Maybe HistoryItemType
historyItemType = Maybe HistoryItemType
forall a. Maybe a
Prelude.Nothing,
      $sel:historyData:AlarmHistoryItem' :: Maybe Text
historyData = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:alarmType:AlarmHistoryItem' :: Maybe AlarmType
alarmType = Maybe AlarmType
forall a. Maybe a
Prelude.Nothing,
      $sel:historySummary:AlarmHistoryItem' :: Maybe Text
historySummary = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:timestamp:AlarmHistoryItem' :: Maybe ISO8601
timestamp = Maybe ISO8601
forall a. Maybe a
Prelude.Nothing
    }

-- | The descriptive name for the alarm.
alarmHistoryItem_alarmName :: Lens.Lens' AlarmHistoryItem (Prelude.Maybe Prelude.Text)
alarmHistoryItem_alarmName :: (Maybe Text -> f (Maybe Text))
-> AlarmHistoryItem -> f AlarmHistoryItem
alarmHistoryItem_alarmName = (AlarmHistoryItem -> Maybe Text)
-> (AlarmHistoryItem -> Maybe Text -> AlarmHistoryItem)
-> Lens AlarmHistoryItem AlarmHistoryItem (Maybe Text) (Maybe Text)
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 history item.
alarmHistoryItem_historyItemType :: Lens.Lens' AlarmHistoryItem (Prelude.Maybe HistoryItemType)
alarmHistoryItem_historyItemType :: (Maybe HistoryItemType -> f (Maybe HistoryItemType))
-> AlarmHistoryItem -> f AlarmHistoryItem
alarmHistoryItem_historyItemType = (AlarmHistoryItem -> Maybe HistoryItemType)
-> (AlarmHistoryItem -> Maybe HistoryItemType -> AlarmHistoryItem)
-> Lens
     AlarmHistoryItem
     AlarmHistoryItem
     (Maybe HistoryItemType)
     (Maybe 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)

-- | Data about the alarm, in JSON format.
alarmHistoryItem_historyData :: Lens.Lens' AlarmHistoryItem (Prelude.Maybe Prelude.Text)
alarmHistoryItem_historyData :: (Maybe Text -> f (Maybe Text))
-> AlarmHistoryItem -> f AlarmHistoryItem
alarmHistoryItem_historyData = (AlarmHistoryItem -> Maybe Text)
-> (AlarmHistoryItem -> Maybe Text -> AlarmHistoryItem)
-> Lens AlarmHistoryItem AlarmHistoryItem (Maybe Text) (Maybe Text)
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, either metric alarm or composite alarm.
alarmHistoryItem_alarmType :: Lens.Lens' AlarmHistoryItem (Prelude.Maybe AlarmType)
alarmHistoryItem_alarmType :: (Maybe AlarmType -> f (Maybe AlarmType))
-> AlarmHistoryItem -> f AlarmHistoryItem
alarmHistoryItem_alarmType = (AlarmHistoryItem -> Maybe AlarmType)
-> (AlarmHistoryItem -> Maybe AlarmType -> AlarmHistoryItem)
-> Lens
     AlarmHistoryItem
     AlarmHistoryItem
     (Maybe AlarmType)
     (Maybe 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)

-- | A summary of the alarm history, in text format.
alarmHistoryItem_historySummary :: Lens.Lens' AlarmHistoryItem (Prelude.Maybe Prelude.Text)
alarmHistoryItem_historySummary :: (Maybe Text -> f (Maybe Text))
-> AlarmHistoryItem -> f AlarmHistoryItem
alarmHistoryItem_historySummary = (AlarmHistoryItem -> Maybe Text)
-> (AlarmHistoryItem -> Maybe Text -> AlarmHistoryItem)
-> Lens AlarmHistoryItem AlarmHistoryItem (Maybe Text) (Maybe Text)
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 :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AlarmHistoryItem -> f AlarmHistoryItem
alarmHistoryItem_timestamp = (AlarmHistoryItem -> Maybe ISO8601)
-> (AlarmHistoryItem -> Maybe ISO8601 -> AlarmHistoryItem)
-> Lens
     AlarmHistoryItem AlarmHistoryItem (Maybe ISO8601) (Maybe ISO8601)
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) ((Maybe ISO8601 -> f (Maybe ISO8601))
 -> AlarmHistoryItem -> f AlarmHistoryItem)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe ISO8601 -> f (Maybe ISO8601))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AlarmHistoryItem
-> f AlarmHistoryItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso ISO8601 ISO8601 UTCTime UTCTime
-> Iso
     (Maybe ISO8601) (Maybe ISO8601) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso ISO8601 ISO8601 UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

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

instance Prelude.Hashable AlarmHistoryItem

instance Prelude.NFData AlarmHistoryItem