{-# 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.IoTEventsData.Types.AlarmSummary
-- 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.IoTEventsData.Types.AlarmSummary where

import qualified Amazonka.Core as Core
import Amazonka.IoTEventsData.Types.AlarmStateName
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains a summary of an alarm.
--
-- /See:/ 'newAlarmSummary' smart constructor.
data AlarmSummary = AlarmSummary'
  { -- | The value of the key used as a filter to select only the alarms
    -- associated with the
    -- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_CreateAlarmModel.html#iotevents-CreateAlarmModel-request-key key>.
    AlarmSummary -> Maybe Text
keyValue :: Prelude.Maybe Prelude.Text,
    -- | The time the alarm was created, in the Unix epoch format.
    AlarmSummary -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | The name of the alarm model.
    AlarmSummary -> Maybe Text
alarmModelName :: Prelude.Maybe Prelude.Text,
    -- | The name of the alarm state. The state name can be one of the following
    -- values:
    --
    -- -   @DISABLED@ - When the alarm is in the @DISABLED@ state, it isn\'t
    --     ready to evaluate data. To enable the alarm, you must change the
    --     alarm to the @NORMAL@ state.
    --
    -- -   @NORMAL@ - When the alarm is in the @NORMAL@ state, it\'s ready to
    --     evaluate data.
    --
    -- -   @ACTIVE@ - If the alarm is in the @ACTIVE@ state, the alarm is
    --     invoked.
    --
    -- -   @ACKNOWLEDGED@ - When the alarm is in the @ACKNOWLEDGED@ state, the
    --     alarm was invoked and you acknowledged the alarm.
    --
    -- -   @SNOOZE_DISABLED@ - When the alarm is in the @SNOOZE_DISABLED@
    --     state, the alarm is disabled for a specified period of time. After
    --     the snooze time, the alarm automatically changes to the @NORMAL@
    --     state.
    --
    -- -   @LATCHED@ - When the alarm is in the @LATCHED@ state, the alarm was
    --     invoked. However, the data that the alarm is currently evaluating is
    --     within the specified range. To change the alarm to the @NORMAL@
    --     state, you must acknowledge the alarm.
    AlarmSummary -> Maybe AlarmStateName
stateName :: Prelude.Maybe AlarmStateName,
    -- | The time the alarm was last updated, in the Unix epoch format.
    AlarmSummary -> Maybe POSIX
lastUpdateTime :: Prelude.Maybe Core.POSIX,
    -- | The version of the alarm model.
    AlarmSummary -> Maybe Text
alarmModelVersion :: Prelude.Maybe Prelude.Text
  }
  deriving (AlarmSummary -> AlarmSummary -> Bool
(AlarmSummary -> AlarmSummary -> Bool)
-> (AlarmSummary -> AlarmSummary -> Bool) -> Eq AlarmSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlarmSummary -> AlarmSummary -> Bool
$c/= :: AlarmSummary -> AlarmSummary -> Bool
== :: AlarmSummary -> AlarmSummary -> Bool
$c== :: AlarmSummary -> AlarmSummary -> Bool
Prelude.Eq, ReadPrec [AlarmSummary]
ReadPrec AlarmSummary
Int -> ReadS AlarmSummary
ReadS [AlarmSummary]
(Int -> ReadS AlarmSummary)
-> ReadS [AlarmSummary]
-> ReadPrec AlarmSummary
-> ReadPrec [AlarmSummary]
-> Read AlarmSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlarmSummary]
$creadListPrec :: ReadPrec [AlarmSummary]
readPrec :: ReadPrec AlarmSummary
$creadPrec :: ReadPrec AlarmSummary
readList :: ReadS [AlarmSummary]
$creadList :: ReadS [AlarmSummary]
readsPrec :: Int -> ReadS AlarmSummary
$creadsPrec :: Int -> ReadS AlarmSummary
Prelude.Read, Int -> AlarmSummary -> ShowS
[AlarmSummary] -> ShowS
AlarmSummary -> String
(Int -> AlarmSummary -> ShowS)
-> (AlarmSummary -> String)
-> ([AlarmSummary] -> ShowS)
-> Show AlarmSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AlarmSummary] -> ShowS
$cshowList :: [AlarmSummary] -> ShowS
show :: AlarmSummary -> String
$cshow :: AlarmSummary -> String
showsPrec :: Int -> AlarmSummary -> ShowS
$cshowsPrec :: Int -> AlarmSummary -> ShowS
Prelude.Show, (forall x. AlarmSummary -> Rep AlarmSummary x)
-> (forall x. Rep AlarmSummary x -> AlarmSummary)
-> Generic AlarmSummary
forall x. Rep AlarmSummary x -> AlarmSummary
forall x. AlarmSummary -> Rep AlarmSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AlarmSummary x -> AlarmSummary
$cfrom :: forall x. AlarmSummary -> Rep AlarmSummary x
Prelude.Generic)

-- |
-- Create a value of 'AlarmSummary' 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:
--
-- 'keyValue', 'alarmSummary_keyValue' - The value of the key used as a filter to select only the alarms
-- associated with the
-- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_CreateAlarmModel.html#iotevents-CreateAlarmModel-request-key key>.
--
-- 'creationTime', 'alarmSummary_creationTime' - The time the alarm was created, in the Unix epoch format.
--
-- 'alarmModelName', 'alarmSummary_alarmModelName' - The name of the alarm model.
--
-- 'stateName', 'alarmSummary_stateName' - The name of the alarm state. The state name can be one of the following
-- values:
--
-- -   @DISABLED@ - When the alarm is in the @DISABLED@ state, it isn\'t
--     ready to evaluate data. To enable the alarm, you must change the
--     alarm to the @NORMAL@ state.
--
-- -   @NORMAL@ - When the alarm is in the @NORMAL@ state, it\'s ready to
--     evaluate data.
--
-- -   @ACTIVE@ - If the alarm is in the @ACTIVE@ state, the alarm is
--     invoked.
--
-- -   @ACKNOWLEDGED@ - When the alarm is in the @ACKNOWLEDGED@ state, the
--     alarm was invoked and you acknowledged the alarm.
--
-- -   @SNOOZE_DISABLED@ - When the alarm is in the @SNOOZE_DISABLED@
--     state, the alarm is disabled for a specified period of time. After
--     the snooze time, the alarm automatically changes to the @NORMAL@
--     state.
--
-- -   @LATCHED@ - When the alarm is in the @LATCHED@ state, the alarm was
--     invoked. However, the data that the alarm is currently evaluating is
--     within the specified range. To change the alarm to the @NORMAL@
--     state, you must acknowledge the alarm.
--
-- 'lastUpdateTime', 'alarmSummary_lastUpdateTime' - The time the alarm was last updated, in the Unix epoch format.
--
-- 'alarmModelVersion', 'alarmSummary_alarmModelVersion' - The version of the alarm model.
newAlarmSummary ::
  AlarmSummary
newAlarmSummary :: AlarmSummary
newAlarmSummary =
  AlarmSummary' :: Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe AlarmStateName
-> Maybe POSIX
-> Maybe Text
-> AlarmSummary
AlarmSummary'
    { $sel:keyValue:AlarmSummary' :: Maybe Text
keyValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:AlarmSummary' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:alarmModelName:AlarmSummary' :: Maybe Text
alarmModelName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stateName:AlarmSummary' :: Maybe AlarmStateName
stateName = Maybe AlarmStateName
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdateTime:AlarmSummary' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:alarmModelVersion:AlarmSummary' :: Maybe Text
alarmModelVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of the key used as a filter to select only the alarms
-- associated with the
-- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_CreateAlarmModel.html#iotevents-CreateAlarmModel-request-key key>.
alarmSummary_keyValue :: Lens.Lens' AlarmSummary (Prelude.Maybe Prelude.Text)
alarmSummary_keyValue :: (Maybe Text -> f (Maybe Text)) -> AlarmSummary -> f AlarmSummary
alarmSummary_keyValue = (AlarmSummary -> Maybe Text)
-> (AlarmSummary -> Maybe Text -> AlarmSummary)
-> Lens AlarmSummary AlarmSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmSummary' {Maybe Text
keyValue :: Maybe Text
$sel:keyValue:AlarmSummary' :: AlarmSummary -> Maybe Text
keyValue} -> Maybe Text
keyValue) (\s :: AlarmSummary
s@AlarmSummary' {} Maybe Text
a -> AlarmSummary
s {$sel:keyValue:AlarmSummary' :: Maybe Text
keyValue = Maybe Text
a} :: AlarmSummary)

-- | The time the alarm was created, in the Unix epoch format.
alarmSummary_creationTime :: Lens.Lens' AlarmSummary (Prelude.Maybe Prelude.UTCTime)
alarmSummary_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AlarmSummary -> f AlarmSummary
alarmSummary_creationTime = (AlarmSummary -> Maybe POSIX)
-> (AlarmSummary -> Maybe POSIX -> AlarmSummary)
-> Lens AlarmSummary AlarmSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmSummary' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:AlarmSummary' :: AlarmSummary -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: AlarmSummary
s@AlarmSummary' {} Maybe POSIX
a -> AlarmSummary
s {$sel:creationTime:AlarmSummary' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: AlarmSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> AlarmSummary -> f AlarmSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AlarmSummary
-> f AlarmSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The name of the alarm model.
alarmSummary_alarmModelName :: Lens.Lens' AlarmSummary (Prelude.Maybe Prelude.Text)
alarmSummary_alarmModelName :: (Maybe Text -> f (Maybe Text)) -> AlarmSummary -> f AlarmSummary
alarmSummary_alarmModelName = (AlarmSummary -> Maybe Text)
-> (AlarmSummary -> Maybe Text -> AlarmSummary)
-> Lens AlarmSummary AlarmSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmSummary' {Maybe Text
alarmModelName :: Maybe Text
$sel:alarmModelName:AlarmSummary' :: AlarmSummary -> Maybe Text
alarmModelName} -> Maybe Text
alarmModelName) (\s :: AlarmSummary
s@AlarmSummary' {} Maybe Text
a -> AlarmSummary
s {$sel:alarmModelName:AlarmSummary' :: Maybe Text
alarmModelName = Maybe Text
a} :: AlarmSummary)

-- | The name of the alarm state. The state name can be one of the following
-- values:
--
-- -   @DISABLED@ - When the alarm is in the @DISABLED@ state, it isn\'t
--     ready to evaluate data. To enable the alarm, you must change the
--     alarm to the @NORMAL@ state.
--
-- -   @NORMAL@ - When the alarm is in the @NORMAL@ state, it\'s ready to
--     evaluate data.
--
-- -   @ACTIVE@ - If the alarm is in the @ACTIVE@ state, the alarm is
--     invoked.
--
-- -   @ACKNOWLEDGED@ - When the alarm is in the @ACKNOWLEDGED@ state, the
--     alarm was invoked and you acknowledged the alarm.
--
-- -   @SNOOZE_DISABLED@ - When the alarm is in the @SNOOZE_DISABLED@
--     state, the alarm is disabled for a specified period of time. After
--     the snooze time, the alarm automatically changes to the @NORMAL@
--     state.
--
-- -   @LATCHED@ - When the alarm is in the @LATCHED@ state, the alarm was
--     invoked. However, the data that the alarm is currently evaluating is
--     within the specified range. To change the alarm to the @NORMAL@
--     state, you must acknowledge the alarm.
alarmSummary_stateName :: Lens.Lens' AlarmSummary (Prelude.Maybe AlarmStateName)
alarmSummary_stateName :: (Maybe AlarmStateName -> f (Maybe AlarmStateName))
-> AlarmSummary -> f AlarmSummary
alarmSummary_stateName = (AlarmSummary -> Maybe AlarmStateName)
-> (AlarmSummary -> Maybe AlarmStateName -> AlarmSummary)
-> Lens
     AlarmSummary
     AlarmSummary
     (Maybe AlarmStateName)
     (Maybe AlarmStateName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmSummary' {Maybe AlarmStateName
stateName :: Maybe AlarmStateName
$sel:stateName:AlarmSummary' :: AlarmSummary -> Maybe AlarmStateName
stateName} -> Maybe AlarmStateName
stateName) (\s :: AlarmSummary
s@AlarmSummary' {} Maybe AlarmStateName
a -> AlarmSummary
s {$sel:stateName:AlarmSummary' :: Maybe AlarmStateName
stateName = Maybe AlarmStateName
a} :: AlarmSummary)

-- | The time the alarm was last updated, in the Unix epoch format.
alarmSummary_lastUpdateTime :: Lens.Lens' AlarmSummary (Prelude.Maybe Prelude.UTCTime)
alarmSummary_lastUpdateTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AlarmSummary -> f AlarmSummary
alarmSummary_lastUpdateTime = (AlarmSummary -> Maybe POSIX)
-> (AlarmSummary -> Maybe POSIX -> AlarmSummary)
-> Lens AlarmSummary AlarmSummary (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmSummary' {Maybe POSIX
lastUpdateTime :: Maybe POSIX
$sel:lastUpdateTime:AlarmSummary' :: AlarmSummary -> Maybe POSIX
lastUpdateTime} -> Maybe POSIX
lastUpdateTime) (\s :: AlarmSummary
s@AlarmSummary' {} Maybe POSIX
a -> AlarmSummary
s {$sel:lastUpdateTime:AlarmSummary' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
a} :: AlarmSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> AlarmSummary -> f AlarmSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AlarmSummary
-> f AlarmSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The version of the alarm model.
alarmSummary_alarmModelVersion :: Lens.Lens' AlarmSummary (Prelude.Maybe Prelude.Text)
alarmSummary_alarmModelVersion :: (Maybe Text -> f (Maybe Text)) -> AlarmSummary -> f AlarmSummary
alarmSummary_alarmModelVersion = (AlarmSummary -> Maybe Text)
-> (AlarmSummary -> Maybe Text -> AlarmSummary)
-> Lens AlarmSummary AlarmSummary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmSummary' {Maybe Text
alarmModelVersion :: Maybe Text
$sel:alarmModelVersion:AlarmSummary' :: AlarmSummary -> Maybe Text
alarmModelVersion} -> Maybe Text
alarmModelVersion) (\s :: AlarmSummary
s@AlarmSummary' {} Maybe Text
a -> AlarmSummary
s {$sel:alarmModelVersion:AlarmSummary' :: Maybe Text
alarmModelVersion = Maybe Text
a} :: AlarmSummary)

instance Core.FromJSON AlarmSummary where
  parseJSON :: Value -> Parser AlarmSummary
parseJSON =
    String
-> (Object -> Parser AlarmSummary) -> Value -> Parser AlarmSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AlarmSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe AlarmStateName
-> Maybe POSIX
-> Maybe Text
-> AlarmSummary
AlarmSummary'
            (Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe AlarmStateName
 -> Maybe POSIX
 -> Maybe Text
 -> AlarmSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe AlarmStateName
      -> Maybe POSIX
      -> Maybe Text
      -> AlarmSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"keyValue")
            Parser
  (Maybe POSIX
   -> Maybe Text
   -> Maybe AlarmStateName
   -> Maybe POSIX
   -> Maybe Text
   -> AlarmSummary)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe AlarmStateName
      -> Maybe POSIX
      -> Maybe Text
      -> AlarmSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"creationTime")
            Parser
  (Maybe Text
   -> Maybe AlarmStateName
   -> Maybe POSIX
   -> Maybe Text
   -> AlarmSummary)
-> Parser (Maybe Text)
-> Parser
     (Maybe AlarmStateName -> Maybe POSIX -> Maybe Text -> AlarmSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"alarmModelName")
            Parser
  (Maybe AlarmStateName -> Maybe POSIX -> Maybe Text -> AlarmSummary)
-> Parser (Maybe AlarmStateName)
-> Parser (Maybe POSIX -> Maybe Text -> AlarmSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AlarmStateName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"stateName")
            Parser (Maybe POSIX -> Maybe Text -> AlarmSummary)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> AlarmSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastUpdateTime")
            Parser (Maybe Text -> AlarmSummary)
-> Parser (Maybe Text) -> Parser AlarmSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"alarmModelVersion")
      )

instance Prelude.Hashable AlarmSummary

instance Prelude.NFData AlarmSummary