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

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

-- | Contains the configuration information of alarm state changes.
--
-- /See:/ 'newStateChangeConfiguration' smart constructor.
data StateChangeConfiguration = StateChangeConfiguration'
  { -- | The trigger type. If the value is @SNOOZE_TIMEOUT@, the snooze duration
    -- ends and the alarm automatically changes to the @NORMAL@ state.
    StateChangeConfiguration -> Maybe TriggerType
triggerType :: Prelude.Maybe TriggerType
  }
  deriving (StateChangeConfiguration -> StateChangeConfiguration -> Bool
(StateChangeConfiguration -> StateChangeConfiguration -> Bool)
-> (StateChangeConfiguration -> StateChangeConfiguration -> Bool)
-> Eq StateChangeConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StateChangeConfiguration -> StateChangeConfiguration -> Bool
$c/= :: StateChangeConfiguration -> StateChangeConfiguration -> Bool
== :: StateChangeConfiguration -> StateChangeConfiguration -> Bool
$c== :: StateChangeConfiguration -> StateChangeConfiguration -> Bool
Prelude.Eq, ReadPrec [StateChangeConfiguration]
ReadPrec StateChangeConfiguration
Int -> ReadS StateChangeConfiguration
ReadS [StateChangeConfiguration]
(Int -> ReadS StateChangeConfiguration)
-> ReadS [StateChangeConfiguration]
-> ReadPrec StateChangeConfiguration
-> ReadPrec [StateChangeConfiguration]
-> Read StateChangeConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StateChangeConfiguration]
$creadListPrec :: ReadPrec [StateChangeConfiguration]
readPrec :: ReadPrec StateChangeConfiguration
$creadPrec :: ReadPrec StateChangeConfiguration
readList :: ReadS [StateChangeConfiguration]
$creadList :: ReadS [StateChangeConfiguration]
readsPrec :: Int -> ReadS StateChangeConfiguration
$creadsPrec :: Int -> ReadS StateChangeConfiguration
Prelude.Read, Int -> StateChangeConfiguration -> ShowS
[StateChangeConfiguration] -> ShowS
StateChangeConfiguration -> String
(Int -> StateChangeConfiguration -> ShowS)
-> (StateChangeConfiguration -> String)
-> ([StateChangeConfiguration] -> ShowS)
-> Show StateChangeConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StateChangeConfiguration] -> ShowS
$cshowList :: [StateChangeConfiguration] -> ShowS
show :: StateChangeConfiguration -> String
$cshow :: StateChangeConfiguration -> String
showsPrec :: Int -> StateChangeConfiguration -> ShowS
$cshowsPrec :: Int -> StateChangeConfiguration -> ShowS
Prelude.Show, (forall x.
 StateChangeConfiguration -> Rep StateChangeConfiguration x)
-> (forall x.
    Rep StateChangeConfiguration x -> StateChangeConfiguration)
-> Generic StateChangeConfiguration
forall x.
Rep StateChangeConfiguration x -> StateChangeConfiguration
forall x.
StateChangeConfiguration -> Rep StateChangeConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StateChangeConfiguration x -> StateChangeConfiguration
$cfrom :: forall x.
StateChangeConfiguration -> Rep StateChangeConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'StateChangeConfiguration' 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:
--
-- 'triggerType', 'stateChangeConfiguration_triggerType' - The trigger type. If the value is @SNOOZE_TIMEOUT@, the snooze duration
-- ends and the alarm automatically changes to the @NORMAL@ state.
newStateChangeConfiguration ::
  StateChangeConfiguration
newStateChangeConfiguration :: StateChangeConfiguration
newStateChangeConfiguration =
  StateChangeConfiguration' :: Maybe TriggerType -> StateChangeConfiguration
StateChangeConfiguration'
    { $sel:triggerType:StateChangeConfiguration' :: Maybe TriggerType
triggerType =
        Maybe TriggerType
forall a. Maybe a
Prelude.Nothing
    }

-- | The trigger type. If the value is @SNOOZE_TIMEOUT@, the snooze duration
-- ends and the alarm automatically changes to the @NORMAL@ state.
stateChangeConfiguration_triggerType :: Lens.Lens' StateChangeConfiguration (Prelude.Maybe TriggerType)
stateChangeConfiguration_triggerType :: (Maybe TriggerType -> f (Maybe TriggerType))
-> StateChangeConfiguration -> f StateChangeConfiguration
stateChangeConfiguration_triggerType = (StateChangeConfiguration -> Maybe TriggerType)
-> (StateChangeConfiguration
    -> Maybe TriggerType -> StateChangeConfiguration)
-> Lens
     StateChangeConfiguration
     StateChangeConfiguration
     (Maybe TriggerType)
     (Maybe TriggerType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StateChangeConfiguration' {Maybe TriggerType
triggerType :: Maybe TriggerType
$sel:triggerType:StateChangeConfiguration' :: StateChangeConfiguration -> Maybe TriggerType
triggerType} -> Maybe TriggerType
triggerType) (\s :: StateChangeConfiguration
s@StateChangeConfiguration' {} Maybe TriggerType
a -> StateChangeConfiguration
s {$sel:triggerType:StateChangeConfiguration' :: Maybe TriggerType
triggerType = Maybe TriggerType
a} :: StateChangeConfiguration)

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

instance Prelude.Hashable StateChangeConfiguration

instance Prelude.NFData StateChangeConfiguration