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

import qualified Amazonka.Core as Core
import Amazonka.IoTEventsData.Types.AcknowledgeActionConfiguration
import Amazonka.IoTEventsData.Types.CustomerActionName
import Amazonka.IoTEventsData.Types.DisableActionConfiguration
import Amazonka.IoTEventsData.Types.EnableActionConfiguration
import Amazonka.IoTEventsData.Types.ResetActionConfiguration
import Amazonka.IoTEventsData.Types.SnoozeActionConfiguration
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about the action that you can take to respond to
-- the alarm.
--
-- /See:/ 'newCustomerAction' smart constructor.
data CustomerAction = CustomerAction'
  { -- | Contains the configuration information of a reset action.
    CustomerAction -> Maybe ResetActionConfiguration
resetActionConfiguration :: Prelude.Maybe ResetActionConfiguration,
    -- | The name of the action. The action name can be one of the following
    -- values:
    --
    -- -   @SNOOZE@ - When you snooze the alarm, the alarm state changes to
    --     @SNOOZE_DISABLED@.
    --
    -- -   @ENABLE@ - When you enable the alarm, the alarm state changes to
    --     @NORMAL@.
    --
    -- -   @DISABLE@ - When you disable the alarm, the alarm state changes to
    --     @DISABLED@.
    --
    -- -   @ACKNOWLEDGE@ - When you acknowledge the alarm, the alarm state
    --     changes to @ACKNOWLEDGED@.
    --
    -- -   @RESET@ - When you reset the alarm, the alarm state changes to
    --     @NORMAL@.
    --
    -- For more information, see the
    -- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_AlarmState.html AlarmState>
    -- API.
    CustomerAction -> Maybe CustomerActionName
actionName :: Prelude.Maybe CustomerActionName,
    -- | Contains the configuration information of a snooze action.
    CustomerAction -> Maybe SnoozeActionConfiguration
snoozeActionConfiguration :: Prelude.Maybe SnoozeActionConfiguration,
    -- | Contains the configuration information of an enable action.
    CustomerAction -> Maybe EnableActionConfiguration
enableActionConfiguration :: Prelude.Maybe EnableActionConfiguration,
    -- | Contains the configuration information of a disable action.
    CustomerAction -> Maybe DisableActionConfiguration
disableActionConfiguration :: Prelude.Maybe DisableActionConfiguration,
    -- | Contains the configuration information of an acknowledge action.
    CustomerAction -> Maybe AcknowledgeActionConfiguration
acknowledgeActionConfiguration :: Prelude.Maybe AcknowledgeActionConfiguration
  }
  deriving (CustomerAction -> CustomerAction -> Bool
(CustomerAction -> CustomerAction -> Bool)
-> (CustomerAction -> CustomerAction -> Bool) -> Eq CustomerAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomerAction -> CustomerAction -> Bool
$c/= :: CustomerAction -> CustomerAction -> Bool
== :: CustomerAction -> CustomerAction -> Bool
$c== :: CustomerAction -> CustomerAction -> Bool
Prelude.Eq, ReadPrec [CustomerAction]
ReadPrec CustomerAction
Int -> ReadS CustomerAction
ReadS [CustomerAction]
(Int -> ReadS CustomerAction)
-> ReadS [CustomerAction]
-> ReadPrec CustomerAction
-> ReadPrec [CustomerAction]
-> Read CustomerAction
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomerAction]
$creadListPrec :: ReadPrec [CustomerAction]
readPrec :: ReadPrec CustomerAction
$creadPrec :: ReadPrec CustomerAction
readList :: ReadS [CustomerAction]
$creadList :: ReadS [CustomerAction]
readsPrec :: Int -> ReadS CustomerAction
$creadsPrec :: Int -> ReadS CustomerAction
Prelude.Read, Int -> CustomerAction -> ShowS
[CustomerAction] -> ShowS
CustomerAction -> String
(Int -> CustomerAction -> ShowS)
-> (CustomerAction -> String)
-> ([CustomerAction] -> ShowS)
-> Show CustomerAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomerAction] -> ShowS
$cshowList :: [CustomerAction] -> ShowS
show :: CustomerAction -> String
$cshow :: CustomerAction -> String
showsPrec :: Int -> CustomerAction -> ShowS
$cshowsPrec :: Int -> CustomerAction -> ShowS
Prelude.Show, (forall x. CustomerAction -> Rep CustomerAction x)
-> (forall x. Rep CustomerAction x -> CustomerAction)
-> Generic CustomerAction
forall x. Rep CustomerAction x -> CustomerAction
forall x. CustomerAction -> Rep CustomerAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomerAction x -> CustomerAction
$cfrom :: forall x. CustomerAction -> Rep CustomerAction x
Prelude.Generic)

-- |
-- Create a value of 'CustomerAction' 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:
--
-- 'resetActionConfiguration', 'customerAction_resetActionConfiguration' - Contains the configuration information of a reset action.
--
-- 'actionName', 'customerAction_actionName' - The name of the action. The action name can be one of the following
-- values:
--
-- -   @SNOOZE@ - When you snooze the alarm, the alarm state changes to
--     @SNOOZE_DISABLED@.
--
-- -   @ENABLE@ - When you enable the alarm, the alarm state changes to
--     @NORMAL@.
--
-- -   @DISABLE@ - When you disable the alarm, the alarm state changes to
--     @DISABLED@.
--
-- -   @ACKNOWLEDGE@ - When you acknowledge the alarm, the alarm state
--     changes to @ACKNOWLEDGED@.
--
-- -   @RESET@ - When you reset the alarm, the alarm state changes to
--     @NORMAL@.
--
-- For more information, see the
-- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_AlarmState.html AlarmState>
-- API.
--
-- 'snoozeActionConfiguration', 'customerAction_snoozeActionConfiguration' - Contains the configuration information of a snooze action.
--
-- 'enableActionConfiguration', 'customerAction_enableActionConfiguration' - Contains the configuration information of an enable action.
--
-- 'disableActionConfiguration', 'customerAction_disableActionConfiguration' - Contains the configuration information of a disable action.
--
-- 'acknowledgeActionConfiguration', 'customerAction_acknowledgeActionConfiguration' - Contains the configuration information of an acknowledge action.
newCustomerAction ::
  CustomerAction
newCustomerAction :: CustomerAction
newCustomerAction =
  CustomerAction' :: Maybe ResetActionConfiguration
-> Maybe CustomerActionName
-> Maybe SnoozeActionConfiguration
-> Maybe EnableActionConfiguration
-> Maybe DisableActionConfiguration
-> Maybe AcknowledgeActionConfiguration
-> CustomerAction
CustomerAction'
    { $sel:resetActionConfiguration:CustomerAction' :: Maybe ResetActionConfiguration
resetActionConfiguration =
        Maybe ResetActionConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:actionName:CustomerAction' :: Maybe CustomerActionName
actionName = Maybe CustomerActionName
forall a. Maybe a
Prelude.Nothing,
      $sel:snoozeActionConfiguration:CustomerAction' :: Maybe SnoozeActionConfiguration
snoozeActionConfiguration = Maybe SnoozeActionConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:enableActionConfiguration:CustomerAction' :: Maybe EnableActionConfiguration
enableActionConfiguration = Maybe EnableActionConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:disableActionConfiguration:CustomerAction' :: Maybe DisableActionConfiguration
disableActionConfiguration = Maybe DisableActionConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:acknowledgeActionConfiguration:CustomerAction' :: Maybe AcknowledgeActionConfiguration
acknowledgeActionConfiguration = Maybe AcknowledgeActionConfiguration
forall a. Maybe a
Prelude.Nothing
    }

-- | Contains the configuration information of a reset action.
customerAction_resetActionConfiguration :: Lens.Lens' CustomerAction (Prelude.Maybe ResetActionConfiguration)
customerAction_resetActionConfiguration :: (Maybe ResetActionConfiguration
 -> f (Maybe ResetActionConfiguration))
-> CustomerAction -> f CustomerAction
customerAction_resetActionConfiguration = (CustomerAction -> Maybe ResetActionConfiguration)
-> (CustomerAction
    -> Maybe ResetActionConfiguration -> CustomerAction)
-> Lens
     CustomerAction
     CustomerAction
     (Maybe ResetActionConfiguration)
     (Maybe ResetActionConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerAction' {Maybe ResetActionConfiguration
resetActionConfiguration :: Maybe ResetActionConfiguration
$sel:resetActionConfiguration:CustomerAction' :: CustomerAction -> Maybe ResetActionConfiguration
resetActionConfiguration} -> Maybe ResetActionConfiguration
resetActionConfiguration) (\s :: CustomerAction
s@CustomerAction' {} Maybe ResetActionConfiguration
a -> CustomerAction
s {$sel:resetActionConfiguration:CustomerAction' :: Maybe ResetActionConfiguration
resetActionConfiguration = Maybe ResetActionConfiguration
a} :: CustomerAction)

-- | The name of the action. The action name can be one of the following
-- values:
--
-- -   @SNOOZE@ - When you snooze the alarm, the alarm state changes to
--     @SNOOZE_DISABLED@.
--
-- -   @ENABLE@ - When you enable the alarm, the alarm state changes to
--     @NORMAL@.
--
-- -   @DISABLE@ - When you disable the alarm, the alarm state changes to
--     @DISABLED@.
--
-- -   @ACKNOWLEDGE@ - When you acknowledge the alarm, the alarm state
--     changes to @ACKNOWLEDGED@.
--
-- -   @RESET@ - When you reset the alarm, the alarm state changes to
--     @NORMAL@.
--
-- For more information, see the
-- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_AlarmState.html AlarmState>
-- API.
customerAction_actionName :: Lens.Lens' CustomerAction (Prelude.Maybe CustomerActionName)
customerAction_actionName :: (Maybe CustomerActionName -> f (Maybe CustomerActionName))
-> CustomerAction -> f CustomerAction
customerAction_actionName = (CustomerAction -> Maybe CustomerActionName)
-> (CustomerAction -> Maybe CustomerActionName -> CustomerAction)
-> Lens
     CustomerAction
     CustomerAction
     (Maybe CustomerActionName)
     (Maybe CustomerActionName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerAction' {Maybe CustomerActionName
actionName :: Maybe CustomerActionName
$sel:actionName:CustomerAction' :: CustomerAction -> Maybe CustomerActionName
actionName} -> Maybe CustomerActionName
actionName) (\s :: CustomerAction
s@CustomerAction' {} Maybe CustomerActionName
a -> CustomerAction
s {$sel:actionName:CustomerAction' :: Maybe CustomerActionName
actionName = Maybe CustomerActionName
a} :: CustomerAction)

-- | Contains the configuration information of a snooze action.
customerAction_snoozeActionConfiguration :: Lens.Lens' CustomerAction (Prelude.Maybe SnoozeActionConfiguration)
customerAction_snoozeActionConfiguration :: (Maybe SnoozeActionConfiguration
 -> f (Maybe SnoozeActionConfiguration))
-> CustomerAction -> f CustomerAction
customerAction_snoozeActionConfiguration = (CustomerAction -> Maybe SnoozeActionConfiguration)
-> (CustomerAction
    -> Maybe SnoozeActionConfiguration -> CustomerAction)
-> Lens
     CustomerAction
     CustomerAction
     (Maybe SnoozeActionConfiguration)
     (Maybe SnoozeActionConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerAction' {Maybe SnoozeActionConfiguration
snoozeActionConfiguration :: Maybe SnoozeActionConfiguration
$sel:snoozeActionConfiguration:CustomerAction' :: CustomerAction -> Maybe SnoozeActionConfiguration
snoozeActionConfiguration} -> Maybe SnoozeActionConfiguration
snoozeActionConfiguration) (\s :: CustomerAction
s@CustomerAction' {} Maybe SnoozeActionConfiguration
a -> CustomerAction
s {$sel:snoozeActionConfiguration:CustomerAction' :: Maybe SnoozeActionConfiguration
snoozeActionConfiguration = Maybe SnoozeActionConfiguration
a} :: CustomerAction)

-- | Contains the configuration information of an enable action.
customerAction_enableActionConfiguration :: Lens.Lens' CustomerAction (Prelude.Maybe EnableActionConfiguration)
customerAction_enableActionConfiguration :: (Maybe EnableActionConfiguration
 -> f (Maybe EnableActionConfiguration))
-> CustomerAction -> f CustomerAction
customerAction_enableActionConfiguration = (CustomerAction -> Maybe EnableActionConfiguration)
-> (CustomerAction
    -> Maybe EnableActionConfiguration -> CustomerAction)
-> Lens
     CustomerAction
     CustomerAction
     (Maybe EnableActionConfiguration)
     (Maybe EnableActionConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerAction' {Maybe EnableActionConfiguration
enableActionConfiguration :: Maybe EnableActionConfiguration
$sel:enableActionConfiguration:CustomerAction' :: CustomerAction -> Maybe EnableActionConfiguration
enableActionConfiguration} -> Maybe EnableActionConfiguration
enableActionConfiguration) (\s :: CustomerAction
s@CustomerAction' {} Maybe EnableActionConfiguration
a -> CustomerAction
s {$sel:enableActionConfiguration:CustomerAction' :: Maybe EnableActionConfiguration
enableActionConfiguration = Maybe EnableActionConfiguration
a} :: CustomerAction)

-- | Contains the configuration information of a disable action.
customerAction_disableActionConfiguration :: Lens.Lens' CustomerAction (Prelude.Maybe DisableActionConfiguration)
customerAction_disableActionConfiguration :: (Maybe DisableActionConfiguration
 -> f (Maybe DisableActionConfiguration))
-> CustomerAction -> f CustomerAction
customerAction_disableActionConfiguration = (CustomerAction -> Maybe DisableActionConfiguration)
-> (CustomerAction
    -> Maybe DisableActionConfiguration -> CustomerAction)
-> Lens
     CustomerAction
     CustomerAction
     (Maybe DisableActionConfiguration)
     (Maybe DisableActionConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerAction' {Maybe DisableActionConfiguration
disableActionConfiguration :: Maybe DisableActionConfiguration
$sel:disableActionConfiguration:CustomerAction' :: CustomerAction -> Maybe DisableActionConfiguration
disableActionConfiguration} -> Maybe DisableActionConfiguration
disableActionConfiguration) (\s :: CustomerAction
s@CustomerAction' {} Maybe DisableActionConfiguration
a -> CustomerAction
s {$sel:disableActionConfiguration:CustomerAction' :: Maybe DisableActionConfiguration
disableActionConfiguration = Maybe DisableActionConfiguration
a} :: CustomerAction)

-- | Contains the configuration information of an acknowledge action.
customerAction_acknowledgeActionConfiguration :: Lens.Lens' CustomerAction (Prelude.Maybe AcknowledgeActionConfiguration)
customerAction_acknowledgeActionConfiguration :: (Maybe AcknowledgeActionConfiguration
 -> f (Maybe AcknowledgeActionConfiguration))
-> CustomerAction -> f CustomerAction
customerAction_acknowledgeActionConfiguration = (CustomerAction -> Maybe AcknowledgeActionConfiguration)
-> (CustomerAction
    -> Maybe AcknowledgeActionConfiguration -> CustomerAction)
-> Lens
     CustomerAction
     CustomerAction
     (Maybe AcknowledgeActionConfiguration)
     (Maybe AcknowledgeActionConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerAction' {Maybe AcknowledgeActionConfiguration
acknowledgeActionConfiguration :: Maybe AcknowledgeActionConfiguration
$sel:acknowledgeActionConfiguration:CustomerAction' :: CustomerAction -> Maybe AcknowledgeActionConfiguration
acknowledgeActionConfiguration} -> Maybe AcknowledgeActionConfiguration
acknowledgeActionConfiguration) (\s :: CustomerAction
s@CustomerAction' {} Maybe AcknowledgeActionConfiguration
a -> CustomerAction
s {$sel:acknowledgeActionConfiguration:CustomerAction' :: Maybe AcknowledgeActionConfiguration
acknowledgeActionConfiguration = Maybe AcknowledgeActionConfiguration
a} :: CustomerAction)

instance Core.FromJSON CustomerAction where
  parseJSON :: Value -> Parser CustomerAction
parseJSON =
    String
-> (Object -> Parser CustomerAction)
-> Value
-> Parser CustomerAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CustomerAction"
      ( \Object
x ->
          Maybe ResetActionConfiguration
-> Maybe CustomerActionName
-> Maybe SnoozeActionConfiguration
-> Maybe EnableActionConfiguration
-> Maybe DisableActionConfiguration
-> Maybe AcknowledgeActionConfiguration
-> CustomerAction
CustomerAction'
            (Maybe ResetActionConfiguration
 -> Maybe CustomerActionName
 -> Maybe SnoozeActionConfiguration
 -> Maybe EnableActionConfiguration
 -> Maybe DisableActionConfiguration
 -> Maybe AcknowledgeActionConfiguration
 -> CustomerAction)
-> Parser (Maybe ResetActionConfiguration)
-> Parser
     (Maybe CustomerActionName
      -> Maybe SnoozeActionConfiguration
      -> Maybe EnableActionConfiguration
      -> Maybe DisableActionConfiguration
      -> Maybe AcknowledgeActionConfiguration
      -> CustomerAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ResetActionConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resetActionConfiguration")
            Parser
  (Maybe CustomerActionName
   -> Maybe SnoozeActionConfiguration
   -> Maybe EnableActionConfiguration
   -> Maybe DisableActionConfiguration
   -> Maybe AcknowledgeActionConfiguration
   -> CustomerAction)
-> Parser (Maybe CustomerActionName)
-> Parser
     (Maybe SnoozeActionConfiguration
      -> Maybe EnableActionConfiguration
      -> Maybe DisableActionConfiguration
      -> Maybe AcknowledgeActionConfiguration
      -> CustomerAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CustomerActionName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"actionName")
            Parser
  (Maybe SnoozeActionConfiguration
   -> Maybe EnableActionConfiguration
   -> Maybe DisableActionConfiguration
   -> Maybe AcknowledgeActionConfiguration
   -> CustomerAction)
-> Parser (Maybe SnoozeActionConfiguration)
-> Parser
     (Maybe EnableActionConfiguration
      -> Maybe DisableActionConfiguration
      -> Maybe AcknowledgeActionConfiguration
      -> CustomerAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SnoozeActionConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"snoozeActionConfiguration")
            Parser
  (Maybe EnableActionConfiguration
   -> Maybe DisableActionConfiguration
   -> Maybe AcknowledgeActionConfiguration
   -> CustomerAction)
-> Parser (Maybe EnableActionConfiguration)
-> Parser
     (Maybe DisableActionConfiguration
      -> Maybe AcknowledgeActionConfiguration -> CustomerAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EnableActionConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"enableActionConfiguration")
            Parser
  (Maybe DisableActionConfiguration
   -> Maybe AcknowledgeActionConfiguration -> CustomerAction)
-> Parser (Maybe DisableActionConfiguration)
-> Parser (Maybe AcknowledgeActionConfiguration -> CustomerAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DisableActionConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"disableActionConfiguration")
            Parser (Maybe AcknowledgeActionConfiguration -> CustomerAction)
-> Parser (Maybe AcknowledgeActionConfiguration)
-> Parser CustomerAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AcknowledgeActionConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"acknowledgeActionConfiguration")
      )

instance Prelude.Hashable CustomerAction

instance Prelude.NFData CustomerAction