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

import qualified Amazonka.Core as Core
import Amazonka.IoTEventsData.Types.AlarmStateName
import Amazonka.IoTEventsData.Types.CustomerAction
import Amazonka.IoTEventsData.Types.RuleEvaluation
import Amazonka.IoTEventsData.Types.SystemEvent
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the current state of the alarm.
--
-- /See:/ 'newAlarmState' smart constructor.
data AlarmState = AlarmState'
  { -- | Contains information about the action that you can take to respond to
    -- the alarm.
    AlarmState -> Maybe CustomerAction
customerAction :: Prelude.Maybe CustomerAction,
    -- | 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.
    AlarmState -> Maybe AlarmStateName
stateName :: Prelude.Maybe AlarmStateName,
    -- | Information needed to evaluate data.
    AlarmState -> Maybe RuleEvaluation
ruleEvaluation :: Prelude.Maybe RuleEvaluation,
    -- | Contains information about alarm state changes.
    AlarmState -> Maybe SystemEvent
systemEvent :: Prelude.Maybe SystemEvent
  }
  deriving (AlarmState -> AlarmState -> Bool
(AlarmState -> AlarmState -> Bool)
-> (AlarmState -> AlarmState -> Bool) -> Eq AlarmState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlarmState -> AlarmState -> Bool
$c/= :: AlarmState -> AlarmState -> Bool
== :: AlarmState -> AlarmState -> Bool
$c== :: AlarmState -> AlarmState -> Bool
Prelude.Eq, ReadPrec [AlarmState]
ReadPrec AlarmState
Int -> ReadS AlarmState
ReadS [AlarmState]
(Int -> ReadS AlarmState)
-> ReadS [AlarmState]
-> ReadPrec AlarmState
-> ReadPrec [AlarmState]
-> Read AlarmState
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlarmState]
$creadListPrec :: ReadPrec [AlarmState]
readPrec :: ReadPrec AlarmState
$creadPrec :: ReadPrec AlarmState
readList :: ReadS [AlarmState]
$creadList :: ReadS [AlarmState]
readsPrec :: Int -> ReadS AlarmState
$creadsPrec :: Int -> ReadS AlarmState
Prelude.Read, Int -> AlarmState -> ShowS
[AlarmState] -> ShowS
AlarmState -> String
(Int -> AlarmState -> ShowS)
-> (AlarmState -> String)
-> ([AlarmState] -> ShowS)
-> Show AlarmState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AlarmState] -> ShowS
$cshowList :: [AlarmState] -> ShowS
show :: AlarmState -> String
$cshow :: AlarmState -> String
showsPrec :: Int -> AlarmState -> ShowS
$cshowsPrec :: Int -> AlarmState -> ShowS
Prelude.Show, (forall x. AlarmState -> Rep AlarmState x)
-> (forall x. Rep AlarmState x -> AlarmState) -> Generic AlarmState
forall x. Rep AlarmState x -> AlarmState
forall x. AlarmState -> Rep AlarmState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AlarmState x -> AlarmState
$cfrom :: forall x. AlarmState -> Rep AlarmState x
Prelude.Generic)

-- |
-- Create a value of 'AlarmState' 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:
--
-- 'customerAction', 'alarmState_customerAction' - Contains information about the action that you can take to respond to
-- the alarm.
--
-- 'stateName', 'alarmState_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.
--
-- 'ruleEvaluation', 'alarmState_ruleEvaluation' - Information needed to evaluate data.
--
-- 'systemEvent', 'alarmState_systemEvent' - Contains information about alarm state changes.
newAlarmState ::
  AlarmState
newAlarmState :: AlarmState
newAlarmState =
  AlarmState' :: Maybe CustomerAction
-> Maybe AlarmStateName
-> Maybe RuleEvaluation
-> Maybe SystemEvent
-> AlarmState
AlarmState'
    { $sel:customerAction:AlarmState' :: Maybe CustomerAction
customerAction = Maybe CustomerAction
forall a. Maybe a
Prelude.Nothing,
      $sel:stateName:AlarmState' :: Maybe AlarmStateName
stateName = Maybe AlarmStateName
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleEvaluation:AlarmState' :: Maybe RuleEvaluation
ruleEvaluation = Maybe RuleEvaluation
forall a. Maybe a
Prelude.Nothing,
      $sel:systemEvent:AlarmState' :: Maybe SystemEvent
systemEvent = Maybe SystemEvent
forall a. Maybe a
Prelude.Nothing
    }

-- | Contains information about the action that you can take to respond to
-- the alarm.
alarmState_customerAction :: Lens.Lens' AlarmState (Prelude.Maybe CustomerAction)
alarmState_customerAction :: (Maybe CustomerAction -> f (Maybe CustomerAction))
-> AlarmState -> f AlarmState
alarmState_customerAction = (AlarmState -> Maybe CustomerAction)
-> (AlarmState -> Maybe CustomerAction -> AlarmState)
-> Lens
     AlarmState AlarmState (Maybe CustomerAction) (Maybe CustomerAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmState' {Maybe CustomerAction
customerAction :: Maybe CustomerAction
$sel:customerAction:AlarmState' :: AlarmState -> Maybe CustomerAction
customerAction} -> Maybe CustomerAction
customerAction) (\s :: AlarmState
s@AlarmState' {} Maybe CustomerAction
a -> AlarmState
s {$sel:customerAction:AlarmState' :: Maybe CustomerAction
customerAction = Maybe CustomerAction
a} :: AlarmState)

-- | 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.
alarmState_stateName :: Lens.Lens' AlarmState (Prelude.Maybe AlarmStateName)
alarmState_stateName :: (Maybe AlarmStateName -> f (Maybe AlarmStateName))
-> AlarmState -> f AlarmState
alarmState_stateName = (AlarmState -> Maybe AlarmStateName)
-> (AlarmState -> Maybe AlarmStateName -> AlarmState)
-> Lens
     AlarmState AlarmState (Maybe AlarmStateName) (Maybe AlarmStateName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmState' {Maybe AlarmStateName
stateName :: Maybe AlarmStateName
$sel:stateName:AlarmState' :: AlarmState -> Maybe AlarmStateName
stateName} -> Maybe AlarmStateName
stateName) (\s :: AlarmState
s@AlarmState' {} Maybe AlarmStateName
a -> AlarmState
s {$sel:stateName:AlarmState' :: Maybe AlarmStateName
stateName = Maybe AlarmStateName
a} :: AlarmState)

-- | Information needed to evaluate data.
alarmState_ruleEvaluation :: Lens.Lens' AlarmState (Prelude.Maybe RuleEvaluation)
alarmState_ruleEvaluation :: (Maybe RuleEvaluation -> f (Maybe RuleEvaluation))
-> AlarmState -> f AlarmState
alarmState_ruleEvaluation = (AlarmState -> Maybe RuleEvaluation)
-> (AlarmState -> Maybe RuleEvaluation -> AlarmState)
-> Lens
     AlarmState AlarmState (Maybe RuleEvaluation) (Maybe RuleEvaluation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmState' {Maybe RuleEvaluation
ruleEvaluation :: Maybe RuleEvaluation
$sel:ruleEvaluation:AlarmState' :: AlarmState -> Maybe RuleEvaluation
ruleEvaluation} -> Maybe RuleEvaluation
ruleEvaluation) (\s :: AlarmState
s@AlarmState' {} Maybe RuleEvaluation
a -> AlarmState
s {$sel:ruleEvaluation:AlarmState' :: Maybe RuleEvaluation
ruleEvaluation = Maybe RuleEvaluation
a} :: AlarmState)

-- | Contains information about alarm state changes.
alarmState_systemEvent :: Lens.Lens' AlarmState (Prelude.Maybe SystemEvent)
alarmState_systemEvent :: (Maybe SystemEvent -> f (Maybe SystemEvent))
-> AlarmState -> f AlarmState
alarmState_systemEvent = (AlarmState -> Maybe SystemEvent)
-> (AlarmState -> Maybe SystemEvent -> AlarmState)
-> Lens
     AlarmState AlarmState (Maybe SystemEvent) (Maybe SystemEvent)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlarmState' {Maybe SystemEvent
systemEvent :: Maybe SystemEvent
$sel:systemEvent:AlarmState' :: AlarmState -> Maybe SystemEvent
systemEvent} -> Maybe SystemEvent
systemEvent) (\s :: AlarmState
s@AlarmState' {} Maybe SystemEvent
a -> AlarmState
s {$sel:systemEvent:AlarmState' :: Maybe SystemEvent
systemEvent = Maybe SystemEvent
a} :: AlarmState)

instance Core.FromJSON AlarmState where
  parseJSON :: Value -> Parser AlarmState
parseJSON =
    String
-> (Object -> Parser AlarmState) -> Value -> Parser AlarmState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AlarmState"
      ( \Object
x ->
          Maybe CustomerAction
-> Maybe AlarmStateName
-> Maybe RuleEvaluation
-> Maybe SystemEvent
-> AlarmState
AlarmState'
            (Maybe CustomerAction
 -> Maybe AlarmStateName
 -> Maybe RuleEvaluation
 -> Maybe SystemEvent
 -> AlarmState)
-> Parser (Maybe CustomerAction)
-> Parser
     (Maybe AlarmStateName
      -> Maybe RuleEvaluation -> Maybe SystemEvent -> AlarmState)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe CustomerAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"customerAction")
            Parser
  (Maybe AlarmStateName
   -> Maybe RuleEvaluation -> Maybe SystemEvent -> AlarmState)
-> Parser (Maybe AlarmStateName)
-> Parser (Maybe RuleEvaluation -> Maybe SystemEvent -> AlarmState)
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 RuleEvaluation -> Maybe SystemEvent -> AlarmState)
-> Parser (Maybe RuleEvaluation)
-> Parser (Maybe SystemEvent -> AlarmState)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RuleEvaluation)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ruleEvaluation")
            Parser (Maybe SystemEvent -> AlarmState)
-> Parser (Maybe SystemEvent) -> Parser AlarmState
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SystemEvent)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"systemEvent")
      )

instance Prelude.Hashable AlarmState

instance Prelude.NFData AlarmState