{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTEventsData.Types.Alarm where

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

-- | Contains information about an alarm.
--
-- /See:/ 'newAlarm' smart constructor.
data Alarm = Alarm'
  { -- | The name of the alarm model.
    Alarm -> Maybe Text
alarmModelName :: Prelude.Maybe Prelude.Text,
    -- | The version of the alarm model.
    Alarm -> Maybe Text
alarmModelVersion :: Prelude.Maybe Prelude.Text,
    -- | Contains information about the current state of the alarm.
    Alarm -> Maybe AlarmState
alarmState :: Prelude.Maybe AlarmState,
    -- | The time the alarm was created, in the Unix epoch format.
    Alarm -> Maybe POSIX
creationTime :: Prelude.Maybe Data.POSIX,
    -- | 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 last updated, in the Unix epoch format.
    Alarm -> Maybe POSIX
lastUpdateTime :: Prelude.Maybe Data.POSIX,
    -- | A non-negative integer that reflects the severity level of the alarm.
    Alarm -> Maybe Natural
severity :: Prelude.Maybe Prelude.Natural
  }
  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:
--
-- 'alarmModelName', 'alarm_alarmModelName' - The name of the alarm model.
--
-- 'alarmModelVersion', 'alarm_alarmModelVersion' - The version of the alarm model.
--
-- 'alarmState', 'alarm_alarmState' - Contains information about the current state of the alarm.
--
-- 'creationTime', 'alarm_creationTime' - The time the alarm was created, in the Unix epoch format.
--
-- '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>.
--
-- 'lastUpdateTime', 'alarm_lastUpdateTime' - The time the alarm was last updated, in the Unix epoch format.
--
-- 'severity', 'alarm_severity' - A non-negative integer that reflects the severity level of the alarm.
newAlarm ::
  Alarm
newAlarm :: Alarm
newAlarm =
  Alarm'
    { $sel:alarmModelName:Alarm' :: Maybe Text
alarmModelName = forall a. Maybe a
Prelude.Nothing,
      $sel:alarmModelVersion:Alarm' :: Maybe Text
alarmModelVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:alarmState:Alarm' :: Maybe AlarmState
alarmState = forall a. Maybe a
Prelude.Nothing,
      $sel:creationTime:Alarm' :: Maybe POSIX
creationTime = forall a. Maybe a
Prelude.Nothing,
      $sel:keyValue:Alarm' :: Maybe Text
keyValue = forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdateTime:Alarm' :: Maybe POSIX
lastUpdateTime = forall a. Maybe a
Prelude.Nothing,
      $sel:severity:Alarm' :: Maybe Natural
severity = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the alarm model.
alarm_alarmModelName :: Lens.Lens' Alarm (Prelude.Maybe Prelude.Text)
alarm_alarmModelName :: Lens' Alarm (Maybe Text)
alarm_alarmModelName = 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)

-- | The version of the alarm model.
alarm_alarmModelVersion :: Lens.Lens' Alarm (Prelude.Maybe Prelude.Text)
alarm_alarmModelVersion :: Lens' Alarm (Maybe Text)
alarm_alarmModelVersion = 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)

-- | Contains information about the current state of the alarm.
alarm_alarmState :: Lens.Lens' Alarm (Prelude.Maybe AlarmState)
alarm_alarmState :: Lens' Alarm (Maybe AlarmState)
alarm_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 time the alarm was created, in the Unix epoch format.
alarm_creationTime :: Lens.Lens' Alarm (Prelude.Maybe Prelude.UTCTime)
alarm_creationTime :: Lens' Alarm (Maybe UTCTime)
alarm_creationTime = 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) 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

-- | 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 :: Lens' Alarm (Maybe Text)
alarm_keyValue = 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 last updated, in the Unix epoch format.
alarm_lastUpdateTime :: Lens.Lens' Alarm (Prelude.Maybe Prelude.UTCTime)
alarm_lastUpdateTime :: Lens' Alarm (Maybe UTCTime)
alarm_lastUpdateTime = 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) 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

-- | A non-negative integer that reflects the severity level of the alarm.
alarm_severity :: Lens.Lens' Alarm (Prelude.Maybe Prelude.Natural)
alarm_severity :: Lens' Alarm (Maybe Natural)
alarm_severity = 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)

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 ->
          Maybe Text
-> Maybe Text
-> Maybe AlarmState
-> Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Natural
-> Alarm
Alarm'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"alarmModelName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"alarmModelVersion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"alarmState")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"creationTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"keyValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"lastUpdateTime")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"severity")
      )

instance Prelude.Hashable Alarm where
  hashWithSalt :: Int -> Alarm -> Int
hashWithSalt Int
_salt Alarm' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe AlarmState
severity :: Maybe Natural
lastUpdateTime :: Maybe POSIX
keyValue :: Maybe Text
creationTime :: Maybe POSIX
alarmState :: Maybe AlarmState
alarmModelVersion :: Maybe Text
alarmModelName :: Maybe Text
$sel:severity:Alarm' :: Alarm -> Maybe Natural
$sel:lastUpdateTime:Alarm' :: Alarm -> Maybe POSIX
$sel:keyValue:Alarm' :: Alarm -> Maybe Text
$sel:creationTime:Alarm' :: Alarm -> Maybe POSIX
$sel:alarmState:Alarm' :: Alarm -> Maybe AlarmState
$sel:alarmModelVersion:Alarm' :: Alarm -> Maybe Text
$sel:alarmModelName:Alarm' :: Alarm -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
alarmModelName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
alarmModelVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AlarmState
alarmState
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
keyValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastUpdateTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
severity

instance Prelude.NFData Alarm where
  rnf :: Alarm -> ()
rnf Alarm' {Maybe Natural
Maybe Text
Maybe POSIX
Maybe AlarmState
severity :: Maybe Natural
lastUpdateTime :: Maybe POSIX
keyValue :: Maybe Text
creationTime :: Maybe POSIX
alarmState :: Maybe AlarmState
alarmModelVersion :: Maybe Text
alarmModelName :: Maybe Text
$sel:severity:Alarm' :: Alarm -> Maybe Natural
$sel:lastUpdateTime:Alarm' :: Alarm -> Maybe POSIX
$sel:keyValue:Alarm' :: Alarm -> Maybe Text
$sel:creationTime:Alarm' :: Alarm -> Maybe POSIX
$sel:alarmState:Alarm' :: Alarm -> Maybe AlarmState
$sel:alarmModelVersion:Alarm' :: Alarm -> Maybe Text
$sel:alarmModelName:Alarm' :: Alarm -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
alarmModelName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
alarmModelVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe AlarmState
alarmState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastUpdateTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
severity