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

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

-- | Contains information about an alarm.
--
-- /See:/ 'newAlarm' smart constructor.
data Alarm = Alarm'
  { -- | 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>.
    Alarm -> Maybe Text
keyValue :: Prelude.Maybe Prelude.Text,
    -- | The time the alarm was created, in the Unix epoch format.
    Alarm -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | Contains information about the current state of the alarm.
    Alarm -> Maybe AlarmState
alarmState :: Prelude.Maybe AlarmState,
    -- | The name of the alarm model.
    Alarm -> Maybe Text
alarmModelName :: Prelude.Maybe Prelude.Text,
    -- | A non-negative integer that reflects the severity level of the alarm.
    Alarm -> Maybe Natural
severity :: Prelude.Maybe Prelude.Natural,
    -- | The time the alarm was last updated, in the Unix epoch format.
    Alarm -> Maybe POSIX
lastUpdateTime :: Prelude.Maybe Core.POSIX,
    -- | The version of the alarm model.
    Alarm -> Maybe Text
alarmModelVersion :: Prelude.Maybe Prelude.Text
  }
  deriving (Alarm -> Alarm -> Bool
(Alarm -> Alarm -> Bool) -> (Alarm -> Alarm -> Bool) -> Eq Alarm
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]
(Int -> ReadS Alarm)
-> ReadS [Alarm]
-> ReadPrec Alarm
-> ReadPrec [Alarm]
-> Read 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
(Int -> Alarm -> ShowS)
-> (Alarm -> String) -> ([Alarm] -> ShowS) -> Show Alarm
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. Alarm -> Rep Alarm x)
-> (forall x. Rep Alarm x -> Alarm) -> Generic Alarm
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:
--
-- 'keyValue', 'alarm_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', 'alarm_creationTime' - The time the alarm was created, in the Unix epoch format.
--
-- 'alarmState', 'alarm_alarmState' - Contains information about the current state of the alarm.
--
-- 'alarmModelName', 'alarm_alarmModelName' - The name of the alarm model.
--
-- 'severity', 'alarm_severity' - A non-negative integer that reflects the severity level of the alarm.
--
-- 'lastUpdateTime', 'alarm_lastUpdateTime' - The time the alarm was last updated, in the Unix epoch format.
--
-- 'alarmModelVersion', 'alarm_alarmModelVersion' - The version of the alarm model.
newAlarm ::
  Alarm
newAlarm :: Alarm
newAlarm =
  Alarm' :: Maybe Text
-> Maybe POSIX
-> Maybe AlarmState
-> Maybe Text
-> Maybe Natural
-> Maybe POSIX
-> Maybe Text
-> Alarm
Alarm'
    { $sel:keyValue:Alarm' :: Maybe Text
keyValue = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:Alarm' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:alarmState:Alarm' :: Maybe AlarmState
alarmState = Maybe AlarmState
forall a. Maybe a
Prelude.Nothing,
      $sel:alarmModelName:Alarm' :: Maybe Text
alarmModelName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:severity:Alarm' :: Maybe Natural
severity = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdateTime:Alarm' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:alarmModelVersion:Alarm' :: 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>.
alarm_keyValue :: Lens.Lens' Alarm (Prelude.Maybe Prelude.Text)
alarm_keyValue :: (Maybe Text -> f (Maybe Text)) -> Alarm -> f Alarm
alarm_keyValue = (Alarm -> Maybe Text)
-> (Alarm -> Maybe Text -> Alarm)
-> Lens Alarm Alarm (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alarm' {Maybe Text
keyValue :: Maybe Text
$sel:keyValue:Alarm' :: Alarm -> Maybe Text
keyValue} -> Maybe Text
keyValue) (\s :: Alarm
s@Alarm' {} Maybe Text
a -> Alarm
s {$sel:keyValue:Alarm' :: Maybe Text
keyValue = Maybe Text
a} :: Alarm)

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

-- | Contains information about the current state of the alarm.
alarm_alarmState :: Lens.Lens' Alarm (Prelude.Maybe AlarmState)
alarm_alarmState :: (Maybe AlarmState -> f (Maybe AlarmState)) -> Alarm -> f Alarm
alarm_alarmState = (Alarm -> Maybe AlarmState)
-> (Alarm -> Maybe AlarmState -> Alarm)
-> Lens Alarm Alarm (Maybe AlarmState) (Maybe AlarmState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alarm' {Maybe AlarmState
alarmState :: Maybe AlarmState
$sel:alarmState:Alarm' :: Alarm -> Maybe AlarmState
alarmState} -> Maybe AlarmState
alarmState) (\s :: Alarm
s@Alarm' {} Maybe AlarmState
a -> Alarm
s {$sel:alarmState:Alarm' :: Maybe AlarmState
alarmState = Maybe AlarmState
a} :: Alarm)

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

-- | A non-negative integer that reflects the severity level of the alarm.
alarm_severity :: Lens.Lens' Alarm (Prelude.Maybe Prelude.Natural)
alarm_severity :: (Maybe Natural -> f (Maybe Natural)) -> Alarm -> f Alarm
alarm_severity = (Alarm -> Maybe Natural)
-> (Alarm -> Maybe Natural -> Alarm)
-> Lens Alarm Alarm (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alarm' {Maybe Natural
severity :: Maybe Natural
$sel:severity:Alarm' :: Alarm -> Maybe Natural
severity} -> Maybe Natural
severity) (\s :: Alarm
s@Alarm' {} Maybe Natural
a -> Alarm
s {$sel:severity:Alarm' :: Maybe Natural
severity = Maybe Natural
a} :: Alarm)

-- | The time the alarm was last updated, in the Unix epoch format.
alarm_lastUpdateTime :: Lens.Lens' Alarm (Prelude.Maybe Prelude.UTCTime)
alarm_lastUpdateTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Alarm -> f Alarm
alarm_lastUpdateTime = (Alarm -> Maybe POSIX)
-> (Alarm -> Maybe POSIX -> Alarm)
-> Lens Alarm Alarm (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alarm' {Maybe POSIX
lastUpdateTime :: Maybe POSIX
$sel:lastUpdateTime:Alarm' :: Alarm -> Maybe POSIX
lastUpdateTime} -> Maybe POSIX
lastUpdateTime) (\s :: Alarm
s@Alarm' {} Maybe POSIX
a -> Alarm
s {$sel:lastUpdateTime:Alarm' :: Maybe POSIX
lastUpdateTime = Maybe POSIX
a} :: Alarm) ((Maybe POSIX -> f (Maybe POSIX)) -> Alarm -> f Alarm)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Alarm
-> f Alarm
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.
alarm_alarmModelVersion :: Lens.Lens' Alarm (Prelude.Maybe Prelude.Text)
alarm_alarmModelVersion :: (Maybe Text -> f (Maybe Text)) -> Alarm -> f Alarm
alarm_alarmModelVersion = (Alarm -> Maybe Text)
-> (Alarm -> Maybe Text -> Alarm)
-> Lens Alarm Alarm (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Alarm' {Maybe Text
alarmModelVersion :: Maybe Text
$sel:alarmModelVersion:Alarm' :: Alarm -> Maybe Text
alarmModelVersion} -> Maybe Text
alarmModelVersion) (\s :: Alarm
s@Alarm' {} Maybe Text
a -> Alarm
s {$sel:alarmModelVersion:Alarm' :: Maybe Text
alarmModelVersion = Maybe Text
a} :: Alarm)

instance Core.FromJSON Alarm where
  parseJSON :: Value -> Parser Alarm
parseJSON =
    String -> (Object -> Parser Alarm) -> Value -> Parser Alarm
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Alarm"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe AlarmState
-> Maybe Text
-> Maybe Natural
-> Maybe POSIX
-> Maybe Text
-> Alarm
Alarm'
            (Maybe Text
 -> Maybe POSIX
 -> Maybe AlarmState
 -> Maybe Text
 -> Maybe Natural
 -> Maybe POSIX
 -> Maybe Text
 -> Alarm)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe AlarmState
      -> Maybe Text
      -> Maybe Natural
      -> Maybe POSIX
      -> Maybe Text
      -> Alarm)
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 AlarmState
   -> Maybe Text
   -> Maybe Natural
   -> Maybe POSIX
   -> Maybe Text
   -> Alarm)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe AlarmState
      -> Maybe Text
      -> Maybe Natural
      -> Maybe POSIX
      -> Maybe Text
      -> Alarm)
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 AlarmState
   -> Maybe Text
   -> Maybe Natural
   -> Maybe POSIX
   -> Maybe Text
   -> Alarm)
-> Parser (Maybe AlarmState)
-> Parser
     (Maybe Text -> Maybe Natural -> Maybe POSIX -> Maybe Text -> Alarm)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AlarmState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"alarmState")
            Parser
  (Maybe Text -> Maybe Natural -> Maybe POSIX -> Maybe Text -> Alarm)
-> Parser (Maybe Text)
-> Parser (Maybe Natural -> Maybe POSIX -> Maybe Text -> Alarm)
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 Natural -> Maybe POSIX -> Maybe Text -> Alarm)
-> Parser (Maybe Natural)
-> Parser (Maybe POSIX -> Maybe Text -> Alarm)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"severity")
            Parser (Maybe POSIX -> Maybe Text -> Alarm)
-> Parser (Maybe POSIX) -> Parser (Maybe Text -> Alarm)
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 -> Alarm) -> Parser (Maybe Text) -> Parser Alarm
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 Alarm

instance Prelude.NFData Alarm