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

import qualified Amazonka.Core as Core
import Amazonka.IoTEventsData.Types.EventType
import Amazonka.IoTEventsData.Types.StateChangeConfiguration
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about alarm state changes.
--
-- /See:/ 'newSystemEvent' smart constructor.
data SystemEvent = SystemEvent'
  { -- | The event type. If the value is @STATE_CHANGE@, the event contains
    -- information about alarm state changes.
    SystemEvent -> Maybe EventType
eventType :: Prelude.Maybe EventType,
    -- | Contains the configuration information of alarm state changes.
    SystemEvent -> Maybe StateChangeConfiguration
stateChangeConfiguration :: Prelude.Maybe StateChangeConfiguration
  }
  deriving (SystemEvent -> SystemEvent -> Bool
(SystemEvent -> SystemEvent -> Bool)
-> (SystemEvent -> SystemEvent -> Bool) -> Eq SystemEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SystemEvent -> SystemEvent -> Bool
$c/= :: SystemEvent -> SystemEvent -> Bool
== :: SystemEvent -> SystemEvent -> Bool
$c== :: SystemEvent -> SystemEvent -> Bool
Prelude.Eq, ReadPrec [SystemEvent]
ReadPrec SystemEvent
Int -> ReadS SystemEvent
ReadS [SystemEvent]
(Int -> ReadS SystemEvent)
-> ReadS [SystemEvent]
-> ReadPrec SystemEvent
-> ReadPrec [SystemEvent]
-> Read SystemEvent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SystemEvent]
$creadListPrec :: ReadPrec [SystemEvent]
readPrec :: ReadPrec SystemEvent
$creadPrec :: ReadPrec SystemEvent
readList :: ReadS [SystemEvent]
$creadList :: ReadS [SystemEvent]
readsPrec :: Int -> ReadS SystemEvent
$creadsPrec :: Int -> ReadS SystemEvent
Prelude.Read, Int -> SystemEvent -> ShowS
[SystemEvent] -> ShowS
SystemEvent -> String
(Int -> SystemEvent -> ShowS)
-> (SystemEvent -> String)
-> ([SystemEvent] -> ShowS)
-> Show SystemEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SystemEvent] -> ShowS
$cshowList :: [SystemEvent] -> ShowS
show :: SystemEvent -> String
$cshow :: SystemEvent -> String
showsPrec :: Int -> SystemEvent -> ShowS
$cshowsPrec :: Int -> SystemEvent -> ShowS
Prelude.Show, (forall x. SystemEvent -> Rep SystemEvent x)
-> (forall x. Rep SystemEvent x -> SystemEvent)
-> Generic SystemEvent
forall x. Rep SystemEvent x -> SystemEvent
forall x. SystemEvent -> Rep SystemEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SystemEvent x -> SystemEvent
$cfrom :: forall x. SystemEvent -> Rep SystemEvent x
Prelude.Generic)

-- |
-- Create a value of 'SystemEvent' 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:
--
-- 'eventType', 'systemEvent_eventType' - The event type. If the value is @STATE_CHANGE@, the event contains
-- information about alarm state changes.
--
-- 'stateChangeConfiguration', 'systemEvent_stateChangeConfiguration' - Contains the configuration information of alarm state changes.
newSystemEvent ::
  SystemEvent
newSystemEvent :: SystemEvent
newSystemEvent =
  SystemEvent' :: Maybe EventType -> Maybe StateChangeConfiguration -> SystemEvent
SystemEvent'
    { $sel:eventType:SystemEvent' :: Maybe EventType
eventType = Maybe EventType
forall a. Maybe a
Prelude.Nothing,
      $sel:stateChangeConfiguration:SystemEvent' :: Maybe StateChangeConfiguration
stateChangeConfiguration = Maybe StateChangeConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | The event type. If the value is @STATE_CHANGE@, the event contains
-- information about alarm state changes.
systemEvent_eventType :: Lens.Lens' SystemEvent (Prelude.Maybe EventType)
systemEvent_eventType :: (Maybe EventType -> f (Maybe EventType))
-> SystemEvent -> f SystemEvent
systemEvent_eventType = (SystemEvent -> Maybe EventType)
-> (SystemEvent -> Maybe EventType -> SystemEvent)
-> Lens SystemEvent SystemEvent (Maybe EventType) (Maybe EventType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SystemEvent' {Maybe EventType
eventType :: Maybe EventType
$sel:eventType:SystemEvent' :: SystemEvent -> Maybe EventType
eventType} -> Maybe EventType
eventType) (\s :: SystemEvent
s@SystemEvent' {} Maybe EventType
a -> SystemEvent
s {$sel:eventType:SystemEvent' :: Maybe EventType
eventType = Maybe EventType
a} :: SystemEvent)

-- | Contains the configuration information of alarm state changes.
systemEvent_stateChangeConfiguration :: Lens.Lens' SystemEvent (Prelude.Maybe StateChangeConfiguration)
systemEvent_stateChangeConfiguration :: (Maybe StateChangeConfiguration
 -> f (Maybe StateChangeConfiguration))
-> SystemEvent -> f SystemEvent
systemEvent_stateChangeConfiguration = (SystemEvent -> Maybe StateChangeConfiguration)
-> (SystemEvent -> Maybe StateChangeConfiguration -> SystemEvent)
-> Lens
     SystemEvent
     SystemEvent
     (Maybe StateChangeConfiguration)
     (Maybe StateChangeConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SystemEvent' {Maybe StateChangeConfiguration
stateChangeConfiguration :: Maybe StateChangeConfiguration
$sel:stateChangeConfiguration:SystemEvent' :: SystemEvent -> Maybe StateChangeConfiguration
stateChangeConfiguration} -> Maybe StateChangeConfiguration
stateChangeConfiguration) (\s :: SystemEvent
s@SystemEvent' {} Maybe StateChangeConfiguration
a -> SystemEvent
s {$sel:stateChangeConfiguration:SystemEvent' :: Maybe StateChangeConfiguration
stateChangeConfiguration = Maybe StateChangeConfiguration
a} :: SystemEvent)

instance Core.FromJSON SystemEvent where
  parseJSON :: Value -> Parser SystemEvent
parseJSON =
    String
-> (Object -> Parser SystemEvent) -> Value -> Parser SystemEvent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SystemEvent"
      ( \Object
x ->
          Maybe EventType -> Maybe StateChangeConfiguration -> SystemEvent
SystemEvent'
            (Maybe EventType -> Maybe StateChangeConfiguration -> SystemEvent)
-> Parser (Maybe EventType)
-> Parser (Maybe StateChangeConfiguration -> SystemEvent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EventType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"eventType")
            Parser (Maybe StateChangeConfiguration -> SystemEvent)
-> Parser (Maybe StateChangeConfiguration) -> Parser SystemEvent
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe StateChangeConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"stateChangeConfiguration")
      )

instance Prelude.Hashable SystemEvent

instance Prelude.NFData SystemEvent