{-# 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.IoTEvents.Types.Action
-- 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.IoTEvents.Types.Action where

import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.Types.ClearTimerAction
import Amazonka.IoTEvents.Types.DynamoDBAction
import Amazonka.IoTEvents.Types.DynamoDBv2Action
import Amazonka.IoTEvents.Types.FirehoseAction
import Amazonka.IoTEvents.Types.IotEventsAction
import Amazonka.IoTEvents.Types.IotSiteWiseAction
import Amazonka.IoTEvents.Types.IotTopicPublishAction
import Amazonka.IoTEvents.Types.LambdaAction
import Amazonka.IoTEvents.Types.ResetTimerAction
import Amazonka.IoTEvents.Types.SNSTopicPublishAction
import Amazonka.IoTEvents.Types.SetTimerAction
import Amazonka.IoTEvents.Types.SetVariableAction
import Amazonka.IoTEvents.Types.SqsAction
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An action to be performed when the @condition@ is TRUE.
--
-- /See:/ 'newAction' smart constructor.
data Action = Action'
  { -- | Publishes an MQTT message with the given topic to the AWS IoT message
    -- broker.
    Action -> Maybe IotTopicPublishAction
iotTopicPublish :: Prelude.Maybe IotTopicPublishAction,
    -- | Writes to the DynamoDB table that you created. The default action
    -- payload contains all attribute-value pairs that have the information
    -- about the detector model instance and the event that triggered the
    -- action. You can customize the
    -- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html payload>.
    -- A separate column of the DynamoDB table receives one attribute-value
    -- pair in the payload that you specify. For more information, see
    -- <https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html Actions>
    -- in /AWS IoT Events Developer Guide/.
    Action -> Maybe DynamoDBv2Action
dynamoDBv2 :: Prelude.Maybe DynamoDBv2Action,
    -- | Information needed to reset the timer.
    Action -> Maybe ResetTimerAction
resetTimer :: Prelude.Maybe ResetTimerAction,
    -- | Information needed to set the timer.
    Action -> Maybe SetTimerAction
setTimer :: Prelude.Maybe SetTimerAction,
    -- | Sends an Amazon SNS message.
    Action -> Maybe SNSTopicPublishAction
sns :: Prelude.Maybe SNSTopicPublishAction,
    -- | Information needed to clear the timer.
    Action -> Maybe ClearTimerAction
clearTimer :: Prelude.Maybe ClearTimerAction,
    -- | Writes to the DynamoDB table that you created. The default action
    -- payload contains all attribute-value pairs that have the information
    -- about the detector model instance and the event that triggered the
    -- action. You can customize the
    -- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html payload>.
    -- One column of the DynamoDB table receives all attribute-value pairs in
    -- the payload that you specify. For more information, see
    -- <https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html Actions>
    -- in /AWS IoT Events Developer Guide/.
    Action -> Maybe DynamoDBAction
dynamoDB :: Prelude.Maybe DynamoDBAction,
    -- | Sends information about the detector model instance and the event that
    -- triggered the action to an Amazon Kinesis Data Firehose delivery stream.
    Action -> Maybe FirehoseAction
firehose :: Prelude.Maybe FirehoseAction,
    -- | Sends information about the detector model instance and the event that
    -- triggered the action to an asset property in AWS IoT SiteWise .
    Action -> Maybe IotSiteWiseAction
iotSiteWise :: Prelude.Maybe IotSiteWiseAction,
    -- | Sets a variable to a specified value.
    Action -> Maybe SetVariableAction
setVariable :: Prelude.Maybe SetVariableAction,
    -- | Calls a Lambda function, passing in information about the detector model
    -- instance and the event that triggered the action.
    Action -> Maybe LambdaAction
lambda :: Prelude.Maybe LambdaAction,
    -- | Sends AWS IoT Events input, which passes information about the detector
    -- model instance and the event that triggered the action.
    Action -> Maybe IotEventsAction
iotEvents :: Prelude.Maybe IotEventsAction,
    -- | Sends information about the detector model instance and the event that
    -- triggered the action to an Amazon SQS queue.
    Action -> Maybe SqsAction
sqs :: Prelude.Maybe SqsAction
  }
  deriving (Action -> Action -> Bool
(Action -> Action -> Bool)
-> (Action -> Action -> Bool) -> Eq Action
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Action -> Action -> Bool
$c/= :: Action -> Action -> Bool
== :: Action -> Action -> Bool
$c== :: Action -> Action -> Bool
Prelude.Eq, ReadPrec [Action]
ReadPrec Action
Int -> ReadS Action
ReadS [Action]
(Int -> ReadS Action)
-> ReadS [Action]
-> ReadPrec Action
-> ReadPrec [Action]
-> Read Action
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Action]
$creadListPrec :: ReadPrec [Action]
readPrec :: ReadPrec Action
$creadPrec :: ReadPrec Action
readList :: ReadS [Action]
$creadList :: ReadS [Action]
readsPrec :: Int -> ReadS Action
$creadsPrec :: Int -> ReadS Action
Prelude.Read, Int -> Action -> ShowS
[Action] -> ShowS
Action -> String
(Int -> Action -> ShowS)
-> (Action -> String) -> ([Action] -> ShowS) -> Show Action
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Action] -> ShowS
$cshowList :: [Action] -> ShowS
show :: Action -> String
$cshow :: Action -> String
showsPrec :: Int -> Action -> ShowS
$cshowsPrec :: Int -> Action -> ShowS
Prelude.Show, (forall x. Action -> Rep Action x)
-> (forall x. Rep Action x -> Action) -> Generic Action
forall x. Rep Action x -> Action
forall x. Action -> Rep Action x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Action x -> Action
$cfrom :: forall x. Action -> Rep Action x
Prelude.Generic)

-- |
-- Create a value of 'Action' 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:
--
-- 'iotTopicPublish', 'action_iotTopicPublish' - Publishes an MQTT message with the given topic to the AWS IoT message
-- broker.
--
-- 'dynamoDBv2', 'action_dynamoDBv2' - Writes to the DynamoDB table that you created. The default action
-- payload contains all attribute-value pairs that have the information
-- about the detector model instance and the event that triggered the
-- action. You can customize the
-- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html payload>.
-- A separate column of the DynamoDB table receives one attribute-value
-- pair in the payload that you specify. For more information, see
-- <https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html Actions>
-- in /AWS IoT Events Developer Guide/.
--
-- 'resetTimer', 'action_resetTimer' - Information needed to reset the timer.
--
-- 'setTimer', 'action_setTimer' - Information needed to set the timer.
--
-- 'sns', 'action_sns' - Sends an Amazon SNS message.
--
-- 'clearTimer', 'action_clearTimer' - Information needed to clear the timer.
--
-- 'dynamoDB', 'action_dynamoDB' - Writes to the DynamoDB table that you created. The default action
-- payload contains all attribute-value pairs that have the information
-- about the detector model instance and the event that triggered the
-- action. You can customize the
-- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html payload>.
-- One column of the DynamoDB table receives all attribute-value pairs in
-- the payload that you specify. For more information, see
-- <https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html Actions>
-- in /AWS IoT Events Developer Guide/.
--
-- 'firehose', 'action_firehose' - Sends information about the detector model instance and the event that
-- triggered the action to an Amazon Kinesis Data Firehose delivery stream.
--
-- 'iotSiteWise', 'action_iotSiteWise' - Sends information about the detector model instance and the event that
-- triggered the action to an asset property in AWS IoT SiteWise .
--
-- 'setVariable', 'action_setVariable' - Sets a variable to a specified value.
--
-- 'lambda', 'action_lambda' - Calls a Lambda function, passing in information about the detector model
-- instance and the event that triggered the action.
--
-- 'iotEvents', 'action_iotEvents' - Sends AWS IoT Events input, which passes information about the detector
-- model instance and the event that triggered the action.
--
-- 'sqs', 'action_sqs' - Sends information about the detector model instance and the event that
-- triggered the action to an Amazon SQS queue.
newAction ::
  Action
newAction :: Action
newAction =
  Action' :: Maybe IotTopicPublishAction
-> Maybe DynamoDBv2Action
-> Maybe ResetTimerAction
-> Maybe SetTimerAction
-> Maybe SNSTopicPublishAction
-> Maybe ClearTimerAction
-> Maybe DynamoDBAction
-> Maybe FirehoseAction
-> Maybe IotSiteWiseAction
-> Maybe SetVariableAction
-> Maybe LambdaAction
-> Maybe IotEventsAction
-> Maybe SqsAction
-> Action
Action'
    { $sel:iotTopicPublish:Action' :: Maybe IotTopicPublishAction
iotTopicPublish = Maybe IotTopicPublishAction
forall a. Maybe a
Prelude.Nothing,
      $sel:dynamoDBv2:Action' :: Maybe DynamoDBv2Action
dynamoDBv2 = Maybe DynamoDBv2Action
forall a. Maybe a
Prelude.Nothing,
      $sel:resetTimer:Action' :: Maybe ResetTimerAction
resetTimer = Maybe ResetTimerAction
forall a. Maybe a
Prelude.Nothing,
      $sel:setTimer:Action' :: Maybe SetTimerAction
setTimer = Maybe SetTimerAction
forall a. Maybe a
Prelude.Nothing,
      $sel:sns:Action' :: Maybe SNSTopicPublishAction
sns = Maybe SNSTopicPublishAction
forall a. Maybe a
Prelude.Nothing,
      $sel:clearTimer:Action' :: Maybe ClearTimerAction
clearTimer = Maybe ClearTimerAction
forall a. Maybe a
Prelude.Nothing,
      $sel:dynamoDB:Action' :: Maybe DynamoDBAction
dynamoDB = Maybe DynamoDBAction
forall a. Maybe a
Prelude.Nothing,
      $sel:firehose:Action' :: Maybe FirehoseAction
firehose = Maybe FirehoseAction
forall a. Maybe a
Prelude.Nothing,
      $sel:iotSiteWise:Action' :: Maybe IotSiteWiseAction
iotSiteWise = Maybe IotSiteWiseAction
forall a. Maybe a
Prelude.Nothing,
      $sel:setVariable:Action' :: Maybe SetVariableAction
setVariable = Maybe SetVariableAction
forall a. Maybe a
Prelude.Nothing,
      $sel:lambda:Action' :: Maybe LambdaAction
lambda = Maybe LambdaAction
forall a. Maybe a
Prelude.Nothing,
      $sel:iotEvents:Action' :: Maybe IotEventsAction
iotEvents = Maybe IotEventsAction
forall a. Maybe a
Prelude.Nothing,
      $sel:sqs:Action' :: Maybe SqsAction
sqs = Maybe SqsAction
forall a. Maybe a
Prelude.Nothing
    }

-- | Publishes an MQTT message with the given topic to the AWS IoT message
-- broker.
action_iotTopicPublish :: Lens.Lens' Action (Prelude.Maybe IotTopicPublishAction)
action_iotTopicPublish :: (Maybe IotTopicPublishAction -> f (Maybe IotTopicPublishAction))
-> Action -> f Action
action_iotTopicPublish = (Action -> Maybe IotTopicPublishAction)
-> (Action -> Maybe IotTopicPublishAction -> Action)
-> Lens
     Action
     Action
     (Maybe IotTopicPublishAction)
     (Maybe IotTopicPublishAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe IotTopicPublishAction
iotTopicPublish :: Maybe IotTopicPublishAction
$sel:iotTopicPublish:Action' :: Action -> Maybe IotTopicPublishAction
iotTopicPublish} -> Maybe IotTopicPublishAction
iotTopicPublish) (\s :: Action
s@Action' {} Maybe IotTopicPublishAction
a -> Action
s {$sel:iotTopicPublish:Action' :: Maybe IotTopicPublishAction
iotTopicPublish = Maybe IotTopicPublishAction
a} :: Action)

-- | Writes to the DynamoDB table that you created. The default action
-- payload contains all attribute-value pairs that have the information
-- about the detector model instance and the event that triggered the
-- action. You can customize the
-- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html payload>.
-- A separate column of the DynamoDB table receives one attribute-value
-- pair in the payload that you specify. For more information, see
-- <https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html Actions>
-- in /AWS IoT Events Developer Guide/.
action_dynamoDBv2 :: Lens.Lens' Action (Prelude.Maybe DynamoDBv2Action)
action_dynamoDBv2 :: (Maybe DynamoDBv2Action -> f (Maybe DynamoDBv2Action))
-> Action -> f Action
action_dynamoDBv2 = (Action -> Maybe DynamoDBv2Action)
-> (Action -> Maybe DynamoDBv2Action -> Action)
-> Lens
     Action Action (Maybe DynamoDBv2Action) (Maybe DynamoDBv2Action)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe DynamoDBv2Action
dynamoDBv2 :: Maybe DynamoDBv2Action
$sel:dynamoDBv2:Action' :: Action -> Maybe DynamoDBv2Action
dynamoDBv2} -> Maybe DynamoDBv2Action
dynamoDBv2) (\s :: Action
s@Action' {} Maybe DynamoDBv2Action
a -> Action
s {$sel:dynamoDBv2:Action' :: Maybe DynamoDBv2Action
dynamoDBv2 = Maybe DynamoDBv2Action
a} :: Action)

-- | Information needed to reset the timer.
action_resetTimer :: Lens.Lens' Action (Prelude.Maybe ResetTimerAction)
action_resetTimer :: (Maybe ResetTimerAction -> f (Maybe ResetTimerAction))
-> Action -> f Action
action_resetTimer = (Action -> Maybe ResetTimerAction)
-> (Action -> Maybe ResetTimerAction -> Action)
-> Lens
     Action Action (Maybe ResetTimerAction) (Maybe ResetTimerAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe ResetTimerAction
resetTimer :: Maybe ResetTimerAction
$sel:resetTimer:Action' :: Action -> Maybe ResetTimerAction
resetTimer} -> Maybe ResetTimerAction
resetTimer) (\s :: Action
s@Action' {} Maybe ResetTimerAction
a -> Action
s {$sel:resetTimer:Action' :: Maybe ResetTimerAction
resetTimer = Maybe ResetTimerAction
a} :: Action)

-- | Information needed to set the timer.
action_setTimer :: Lens.Lens' Action (Prelude.Maybe SetTimerAction)
action_setTimer :: (Maybe SetTimerAction -> f (Maybe SetTimerAction))
-> Action -> f Action
action_setTimer = (Action -> Maybe SetTimerAction)
-> (Action -> Maybe SetTimerAction -> Action)
-> Lens Action Action (Maybe SetTimerAction) (Maybe SetTimerAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe SetTimerAction
setTimer :: Maybe SetTimerAction
$sel:setTimer:Action' :: Action -> Maybe SetTimerAction
setTimer} -> Maybe SetTimerAction
setTimer) (\s :: Action
s@Action' {} Maybe SetTimerAction
a -> Action
s {$sel:setTimer:Action' :: Maybe SetTimerAction
setTimer = Maybe SetTimerAction
a} :: Action)

-- | Sends an Amazon SNS message.
action_sns :: Lens.Lens' Action (Prelude.Maybe SNSTopicPublishAction)
action_sns :: (Maybe SNSTopicPublishAction -> f (Maybe SNSTopicPublishAction))
-> Action -> f Action
action_sns = (Action -> Maybe SNSTopicPublishAction)
-> (Action -> Maybe SNSTopicPublishAction -> Action)
-> Lens
     Action
     Action
     (Maybe SNSTopicPublishAction)
     (Maybe SNSTopicPublishAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe SNSTopicPublishAction
sns :: Maybe SNSTopicPublishAction
$sel:sns:Action' :: Action -> Maybe SNSTopicPublishAction
sns} -> Maybe SNSTopicPublishAction
sns) (\s :: Action
s@Action' {} Maybe SNSTopicPublishAction
a -> Action
s {$sel:sns:Action' :: Maybe SNSTopicPublishAction
sns = Maybe SNSTopicPublishAction
a} :: Action)

-- | Information needed to clear the timer.
action_clearTimer :: Lens.Lens' Action (Prelude.Maybe ClearTimerAction)
action_clearTimer :: (Maybe ClearTimerAction -> f (Maybe ClearTimerAction))
-> Action -> f Action
action_clearTimer = (Action -> Maybe ClearTimerAction)
-> (Action -> Maybe ClearTimerAction -> Action)
-> Lens
     Action Action (Maybe ClearTimerAction) (Maybe ClearTimerAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe ClearTimerAction
clearTimer :: Maybe ClearTimerAction
$sel:clearTimer:Action' :: Action -> Maybe ClearTimerAction
clearTimer} -> Maybe ClearTimerAction
clearTimer) (\s :: Action
s@Action' {} Maybe ClearTimerAction
a -> Action
s {$sel:clearTimer:Action' :: Maybe ClearTimerAction
clearTimer = Maybe ClearTimerAction
a} :: Action)

-- | Writes to the DynamoDB table that you created. The default action
-- payload contains all attribute-value pairs that have the information
-- about the detector model instance and the event that triggered the
-- action. You can customize the
-- <https://docs.aws.amazon.com/iotevents/latest/apireference/API_Payload.html payload>.
-- One column of the DynamoDB table receives all attribute-value pairs in
-- the payload that you specify. For more information, see
-- <https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-event-actions.html Actions>
-- in /AWS IoT Events Developer Guide/.
action_dynamoDB :: Lens.Lens' Action (Prelude.Maybe DynamoDBAction)
action_dynamoDB :: (Maybe DynamoDBAction -> f (Maybe DynamoDBAction))
-> Action -> f Action
action_dynamoDB = (Action -> Maybe DynamoDBAction)
-> (Action -> Maybe DynamoDBAction -> Action)
-> Lens Action Action (Maybe DynamoDBAction) (Maybe DynamoDBAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe DynamoDBAction
dynamoDB :: Maybe DynamoDBAction
$sel:dynamoDB:Action' :: Action -> Maybe DynamoDBAction
dynamoDB} -> Maybe DynamoDBAction
dynamoDB) (\s :: Action
s@Action' {} Maybe DynamoDBAction
a -> Action
s {$sel:dynamoDB:Action' :: Maybe DynamoDBAction
dynamoDB = Maybe DynamoDBAction
a} :: Action)

-- | Sends information about the detector model instance and the event that
-- triggered the action to an Amazon Kinesis Data Firehose delivery stream.
action_firehose :: Lens.Lens' Action (Prelude.Maybe FirehoseAction)
action_firehose :: (Maybe FirehoseAction -> f (Maybe FirehoseAction))
-> Action -> f Action
action_firehose = (Action -> Maybe FirehoseAction)
-> (Action -> Maybe FirehoseAction -> Action)
-> Lens Action Action (Maybe FirehoseAction) (Maybe FirehoseAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe FirehoseAction
firehose :: Maybe FirehoseAction
$sel:firehose:Action' :: Action -> Maybe FirehoseAction
firehose} -> Maybe FirehoseAction
firehose) (\s :: Action
s@Action' {} Maybe FirehoseAction
a -> Action
s {$sel:firehose:Action' :: Maybe FirehoseAction
firehose = Maybe FirehoseAction
a} :: Action)

-- | Sends information about the detector model instance and the event that
-- triggered the action to an asset property in AWS IoT SiteWise .
action_iotSiteWise :: Lens.Lens' Action (Prelude.Maybe IotSiteWiseAction)
action_iotSiteWise :: (Maybe IotSiteWiseAction -> f (Maybe IotSiteWiseAction))
-> Action -> f Action
action_iotSiteWise = (Action -> Maybe IotSiteWiseAction)
-> (Action -> Maybe IotSiteWiseAction -> Action)
-> Lens
     Action Action (Maybe IotSiteWiseAction) (Maybe IotSiteWiseAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe IotSiteWiseAction
iotSiteWise :: Maybe IotSiteWiseAction
$sel:iotSiteWise:Action' :: Action -> Maybe IotSiteWiseAction
iotSiteWise} -> Maybe IotSiteWiseAction
iotSiteWise) (\s :: Action
s@Action' {} Maybe IotSiteWiseAction
a -> Action
s {$sel:iotSiteWise:Action' :: Maybe IotSiteWiseAction
iotSiteWise = Maybe IotSiteWiseAction
a} :: Action)

-- | Sets a variable to a specified value.
action_setVariable :: Lens.Lens' Action (Prelude.Maybe SetVariableAction)
action_setVariable :: (Maybe SetVariableAction -> f (Maybe SetVariableAction))
-> Action -> f Action
action_setVariable = (Action -> Maybe SetVariableAction)
-> (Action -> Maybe SetVariableAction -> Action)
-> Lens
     Action Action (Maybe SetVariableAction) (Maybe SetVariableAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe SetVariableAction
setVariable :: Maybe SetVariableAction
$sel:setVariable:Action' :: Action -> Maybe SetVariableAction
setVariable} -> Maybe SetVariableAction
setVariable) (\s :: Action
s@Action' {} Maybe SetVariableAction
a -> Action
s {$sel:setVariable:Action' :: Maybe SetVariableAction
setVariable = Maybe SetVariableAction
a} :: Action)

-- | Calls a Lambda function, passing in information about the detector model
-- instance and the event that triggered the action.
action_lambda :: Lens.Lens' Action (Prelude.Maybe LambdaAction)
action_lambda :: (Maybe LambdaAction -> f (Maybe LambdaAction))
-> Action -> f Action
action_lambda = (Action -> Maybe LambdaAction)
-> (Action -> Maybe LambdaAction -> Action)
-> Lens Action Action (Maybe LambdaAction) (Maybe LambdaAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe LambdaAction
lambda :: Maybe LambdaAction
$sel:lambda:Action' :: Action -> Maybe LambdaAction
lambda} -> Maybe LambdaAction
lambda) (\s :: Action
s@Action' {} Maybe LambdaAction
a -> Action
s {$sel:lambda:Action' :: Maybe LambdaAction
lambda = Maybe LambdaAction
a} :: Action)

-- | Sends AWS IoT Events input, which passes information about the detector
-- model instance and the event that triggered the action.
action_iotEvents :: Lens.Lens' Action (Prelude.Maybe IotEventsAction)
action_iotEvents :: (Maybe IotEventsAction -> f (Maybe IotEventsAction))
-> Action -> f Action
action_iotEvents = (Action -> Maybe IotEventsAction)
-> (Action -> Maybe IotEventsAction -> Action)
-> Lens
     Action Action (Maybe IotEventsAction) (Maybe IotEventsAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe IotEventsAction
iotEvents :: Maybe IotEventsAction
$sel:iotEvents:Action' :: Action -> Maybe IotEventsAction
iotEvents} -> Maybe IotEventsAction
iotEvents) (\s :: Action
s@Action' {} Maybe IotEventsAction
a -> Action
s {$sel:iotEvents:Action' :: Maybe IotEventsAction
iotEvents = Maybe IotEventsAction
a} :: Action)

-- | Sends information about the detector model instance and the event that
-- triggered the action to an Amazon SQS queue.
action_sqs :: Lens.Lens' Action (Prelude.Maybe SqsAction)
action_sqs :: (Maybe SqsAction -> f (Maybe SqsAction)) -> Action -> f Action
action_sqs = (Action -> Maybe SqsAction)
-> (Action -> Maybe SqsAction -> Action)
-> Lens Action Action (Maybe SqsAction) (Maybe SqsAction)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Action' {Maybe SqsAction
sqs :: Maybe SqsAction
$sel:sqs:Action' :: Action -> Maybe SqsAction
sqs} -> Maybe SqsAction
sqs) (\s :: Action
s@Action' {} Maybe SqsAction
a -> Action
s {$sel:sqs:Action' :: Maybe SqsAction
sqs = Maybe SqsAction
a} :: Action)

instance Core.FromJSON Action where
  parseJSON :: Value -> Parser Action
parseJSON =
    String -> (Object -> Parser Action) -> Value -> Parser Action
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Action"
      ( \Object
x ->
          Maybe IotTopicPublishAction
-> Maybe DynamoDBv2Action
-> Maybe ResetTimerAction
-> Maybe SetTimerAction
-> Maybe SNSTopicPublishAction
-> Maybe ClearTimerAction
-> Maybe DynamoDBAction
-> Maybe FirehoseAction
-> Maybe IotSiteWiseAction
-> Maybe SetVariableAction
-> Maybe LambdaAction
-> Maybe IotEventsAction
-> Maybe SqsAction
-> Action
Action'
            (Maybe IotTopicPublishAction
 -> Maybe DynamoDBv2Action
 -> Maybe ResetTimerAction
 -> Maybe SetTimerAction
 -> Maybe SNSTopicPublishAction
 -> Maybe ClearTimerAction
 -> Maybe DynamoDBAction
 -> Maybe FirehoseAction
 -> Maybe IotSiteWiseAction
 -> Maybe SetVariableAction
 -> Maybe LambdaAction
 -> Maybe IotEventsAction
 -> Maybe SqsAction
 -> Action)
-> Parser (Maybe IotTopicPublishAction)
-> Parser
     (Maybe DynamoDBv2Action
      -> Maybe ResetTimerAction
      -> Maybe SetTimerAction
      -> Maybe SNSTopicPublishAction
      -> Maybe ClearTimerAction
      -> Maybe DynamoDBAction
      -> Maybe FirehoseAction
      -> Maybe IotSiteWiseAction
      -> Maybe SetVariableAction
      -> Maybe LambdaAction
      -> Maybe IotEventsAction
      -> Maybe SqsAction
      -> Action)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe IotTopicPublishAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"iotTopicPublish")
            Parser
  (Maybe DynamoDBv2Action
   -> Maybe ResetTimerAction
   -> Maybe SetTimerAction
   -> Maybe SNSTopicPublishAction
   -> Maybe ClearTimerAction
   -> Maybe DynamoDBAction
   -> Maybe FirehoseAction
   -> Maybe IotSiteWiseAction
   -> Maybe SetVariableAction
   -> Maybe LambdaAction
   -> Maybe IotEventsAction
   -> Maybe SqsAction
   -> Action)
-> Parser (Maybe DynamoDBv2Action)
-> Parser
     (Maybe ResetTimerAction
      -> Maybe SetTimerAction
      -> Maybe SNSTopicPublishAction
      -> Maybe ClearTimerAction
      -> Maybe DynamoDBAction
      -> Maybe FirehoseAction
      -> Maybe IotSiteWiseAction
      -> Maybe SetVariableAction
      -> Maybe LambdaAction
      -> Maybe IotEventsAction
      -> Maybe SqsAction
      -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DynamoDBv2Action)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"dynamoDBv2")
            Parser
  (Maybe ResetTimerAction
   -> Maybe SetTimerAction
   -> Maybe SNSTopicPublishAction
   -> Maybe ClearTimerAction
   -> Maybe DynamoDBAction
   -> Maybe FirehoseAction
   -> Maybe IotSiteWiseAction
   -> Maybe SetVariableAction
   -> Maybe LambdaAction
   -> Maybe IotEventsAction
   -> Maybe SqsAction
   -> Action)
-> Parser (Maybe ResetTimerAction)
-> Parser
     (Maybe SetTimerAction
      -> Maybe SNSTopicPublishAction
      -> Maybe ClearTimerAction
      -> Maybe DynamoDBAction
      -> Maybe FirehoseAction
      -> Maybe IotSiteWiseAction
      -> Maybe SetVariableAction
      -> Maybe LambdaAction
      -> Maybe IotEventsAction
      -> Maybe SqsAction
      -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ResetTimerAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resetTimer")
            Parser
  (Maybe SetTimerAction
   -> Maybe SNSTopicPublishAction
   -> Maybe ClearTimerAction
   -> Maybe DynamoDBAction
   -> Maybe FirehoseAction
   -> Maybe IotSiteWiseAction
   -> Maybe SetVariableAction
   -> Maybe LambdaAction
   -> Maybe IotEventsAction
   -> Maybe SqsAction
   -> Action)
-> Parser (Maybe SetTimerAction)
-> Parser
     (Maybe SNSTopicPublishAction
      -> Maybe ClearTimerAction
      -> Maybe DynamoDBAction
      -> Maybe FirehoseAction
      -> Maybe IotSiteWiseAction
      -> Maybe SetVariableAction
      -> Maybe LambdaAction
      -> Maybe IotEventsAction
      -> Maybe SqsAction
      -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SetTimerAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"setTimer")
            Parser
  (Maybe SNSTopicPublishAction
   -> Maybe ClearTimerAction
   -> Maybe DynamoDBAction
   -> Maybe FirehoseAction
   -> Maybe IotSiteWiseAction
   -> Maybe SetVariableAction
   -> Maybe LambdaAction
   -> Maybe IotEventsAction
   -> Maybe SqsAction
   -> Action)
-> Parser (Maybe SNSTopicPublishAction)
-> Parser
     (Maybe ClearTimerAction
      -> Maybe DynamoDBAction
      -> Maybe FirehoseAction
      -> Maybe IotSiteWiseAction
      -> Maybe SetVariableAction
      -> Maybe LambdaAction
      -> Maybe IotEventsAction
      -> Maybe SqsAction
      -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SNSTopicPublishAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sns")
            Parser
  (Maybe ClearTimerAction
   -> Maybe DynamoDBAction
   -> Maybe FirehoseAction
   -> Maybe IotSiteWiseAction
   -> Maybe SetVariableAction
   -> Maybe LambdaAction
   -> Maybe IotEventsAction
   -> Maybe SqsAction
   -> Action)
-> Parser (Maybe ClearTimerAction)
-> Parser
     (Maybe DynamoDBAction
      -> Maybe FirehoseAction
      -> Maybe IotSiteWiseAction
      -> Maybe SetVariableAction
      -> Maybe LambdaAction
      -> Maybe IotEventsAction
      -> Maybe SqsAction
      -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ClearTimerAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"clearTimer")
            Parser
  (Maybe DynamoDBAction
   -> Maybe FirehoseAction
   -> Maybe IotSiteWiseAction
   -> Maybe SetVariableAction
   -> Maybe LambdaAction
   -> Maybe IotEventsAction
   -> Maybe SqsAction
   -> Action)
-> Parser (Maybe DynamoDBAction)
-> Parser
     (Maybe FirehoseAction
      -> Maybe IotSiteWiseAction
      -> Maybe SetVariableAction
      -> Maybe LambdaAction
      -> Maybe IotEventsAction
      -> Maybe SqsAction
      -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DynamoDBAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"dynamoDB")
            Parser
  (Maybe FirehoseAction
   -> Maybe IotSiteWiseAction
   -> Maybe SetVariableAction
   -> Maybe LambdaAction
   -> Maybe IotEventsAction
   -> Maybe SqsAction
   -> Action)
-> Parser (Maybe FirehoseAction)
-> Parser
     (Maybe IotSiteWiseAction
      -> Maybe SetVariableAction
      -> Maybe LambdaAction
      -> Maybe IotEventsAction
      -> Maybe SqsAction
      -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FirehoseAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"firehose")
            Parser
  (Maybe IotSiteWiseAction
   -> Maybe SetVariableAction
   -> Maybe LambdaAction
   -> Maybe IotEventsAction
   -> Maybe SqsAction
   -> Action)
-> Parser (Maybe IotSiteWiseAction)
-> Parser
     (Maybe SetVariableAction
      -> Maybe LambdaAction
      -> Maybe IotEventsAction
      -> Maybe SqsAction
      -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe IotSiteWiseAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"iotSiteWise")
            Parser
  (Maybe SetVariableAction
   -> Maybe LambdaAction
   -> Maybe IotEventsAction
   -> Maybe SqsAction
   -> Action)
-> Parser (Maybe SetVariableAction)
-> Parser
     (Maybe LambdaAction
      -> Maybe IotEventsAction -> Maybe SqsAction -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SetVariableAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"setVariable")
            Parser
  (Maybe LambdaAction
   -> Maybe IotEventsAction -> Maybe SqsAction -> Action)
-> Parser (Maybe LambdaAction)
-> Parser (Maybe IotEventsAction -> Maybe SqsAction -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe LambdaAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lambda")
            Parser (Maybe IotEventsAction -> Maybe SqsAction -> Action)
-> Parser (Maybe IotEventsAction)
-> Parser (Maybe SqsAction -> Action)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe IotEventsAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"iotEvents")
            Parser (Maybe SqsAction -> Action)
-> Parser (Maybe SqsAction) -> Parser Action
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SqsAction)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"sqs")
      )

instance Prelude.Hashable Action

instance Prelude.NFData Action

instance Core.ToJSON Action where
  toJSON :: Action -> Value
toJSON Action' {Maybe ClearTimerAction
Maybe IotSiteWiseAction
Maybe LambdaAction
Maybe IotTopicPublishAction
Maybe IotEventsAction
Maybe FirehoseAction
Maybe DynamoDBv2Action
Maybe DynamoDBAction
Maybe ResetTimerAction
Maybe SNSTopicPublishAction
Maybe SetTimerAction
Maybe SetVariableAction
Maybe SqsAction
sqs :: Maybe SqsAction
iotEvents :: Maybe IotEventsAction
lambda :: Maybe LambdaAction
setVariable :: Maybe SetVariableAction
iotSiteWise :: Maybe IotSiteWiseAction
firehose :: Maybe FirehoseAction
dynamoDB :: Maybe DynamoDBAction
clearTimer :: Maybe ClearTimerAction
sns :: Maybe SNSTopicPublishAction
setTimer :: Maybe SetTimerAction
resetTimer :: Maybe ResetTimerAction
dynamoDBv2 :: Maybe DynamoDBv2Action
iotTopicPublish :: Maybe IotTopicPublishAction
$sel:sqs:Action' :: Action -> Maybe SqsAction
$sel:iotEvents:Action' :: Action -> Maybe IotEventsAction
$sel:lambda:Action' :: Action -> Maybe LambdaAction
$sel:setVariable:Action' :: Action -> Maybe SetVariableAction
$sel:iotSiteWise:Action' :: Action -> Maybe IotSiteWiseAction
$sel:firehose:Action' :: Action -> Maybe FirehoseAction
$sel:dynamoDB:Action' :: Action -> Maybe DynamoDBAction
$sel:clearTimer:Action' :: Action -> Maybe ClearTimerAction
$sel:sns:Action' :: Action -> Maybe SNSTopicPublishAction
$sel:setTimer:Action' :: Action -> Maybe SetTimerAction
$sel:resetTimer:Action' :: Action -> Maybe ResetTimerAction
$sel:dynamoDBv2:Action' :: Action -> Maybe DynamoDBv2Action
$sel:iotTopicPublish:Action' :: Action -> Maybe IotTopicPublishAction
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"iotTopicPublish" Text -> IotTopicPublishAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (IotTopicPublishAction -> Pair)
-> Maybe IotTopicPublishAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IotTopicPublishAction
iotTopicPublish,
            (Text
"dynamoDBv2" Text -> DynamoDBv2Action -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DynamoDBv2Action -> Pair) -> Maybe DynamoDBv2Action -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DynamoDBv2Action
dynamoDBv2,
            (Text
"resetTimer" Text -> ResetTimerAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ResetTimerAction -> Pair) -> Maybe ResetTimerAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResetTimerAction
resetTimer,
            (Text
"setTimer" Text -> SetTimerAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SetTimerAction -> Pair) -> Maybe SetTimerAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SetTimerAction
setTimer,
            (Text
"sns" Text -> SNSTopicPublishAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SNSTopicPublishAction -> Pair)
-> Maybe SNSTopicPublishAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SNSTopicPublishAction
sns,
            (Text
"clearTimer" Text -> ClearTimerAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ClearTimerAction -> Pair) -> Maybe ClearTimerAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ClearTimerAction
clearTimer,
            (Text
"dynamoDB" Text -> DynamoDBAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DynamoDBAction -> Pair) -> Maybe DynamoDBAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DynamoDBAction
dynamoDB,
            (Text
"firehose" Text -> FirehoseAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (FirehoseAction -> Pair) -> Maybe FirehoseAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FirehoseAction
firehose,
            (Text
"iotSiteWise" Text -> IotSiteWiseAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (IotSiteWiseAction -> Pair)
-> Maybe IotSiteWiseAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IotSiteWiseAction
iotSiteWise,
            (Text
"setVariable" Text -> SetVariableAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SetVariableAction -> Pair)
-> Maybe SetVariableAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SetVariableAction
setVariable,
            (Text
"lambda" Text -> LambdaAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LambdaAction -> Pair) -> Maybe LambdaAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LambdaAction
lambda,
            (Text
"iotEvents" Text -> IotEventsAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (IotEventsAction -> Pair) -> Maybe IotEventsAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe IotEventsAction
iotEvents,
            (Text
"sqs" Text -> SqsAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SqsAction -> Pair) -> Maybe SqsAction -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SqsAction
sqs
          ]
      )