{-# 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.IoT.Types.StepFunctionsAction
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoT.Types.StepFunctionsAction where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Starts execution of a Step Functions state machine.
--
-- /See:/ 'newStepFunctionsAction' smart constructor.
data StepFunctionsAction = StepFunctionsAction'
  { -- | (Optional) A name will be given to the state machine execution
    -- consisting of this prefix followed by a UUID. Step Functions
    -- automatically creates a unique name for each state machine execution if
    -- one is not provided.
    StepFunctionsAction -> Maybe Text
executionNamePrefix :: Prelude.Maybe Prelude.Text,
    -- | The name of the Step Functions state machine whose execution will be
    -- started.
    StepFunctionsAction -> Text
stateMachineName :: Prelude.Text,
    -- | The ARN of the role that grants IoT permission to start execution of a
    -- state machine (\"Action\":\"states:StartExecution\").
    StepFunctionsAction -> Text
roleArn :: Prelude.Text
  }
  deriving (StepFunctionsAction -> StepFunctionsAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StepFunctionsAction -> StepFunctionsAction -> Bool
$c/= :: StepFunctionsAction -> StepFunctionsAction -> Bool
== :: StepFunctionsAction -> StepFunctionsAction -> Bool
$c== :: StepFunctionsAction -> StepFunctionsAction -> Bool
Prelude.Eq, ReadPrec [StepFunctionsAction]
ReadPrec StepFunctionsAction
Int -> ReadS StepFunctionsAction
ReadS [StepFunctionsAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StepFunctionsAction]
$creadListPrec :: ReadPrec [StepFunctionsAction]
readPrec :: ReadPrec StepFunctionsAction
$creadPrec :: ReadPrec StepFunctionsAction
readList :: ReadS [StepFunctionsAction]
$creadList :: ReadS [StepFunctionsAction]
readsPrec :: Int -> ReadS StepFunctionsAction
$creadsPrec :: Int -> ReadS StepFunctionsAction
Prelude.Read, Int -> StepFunctionsAction -> ShowS
[StepFunctionsAction] -> ShowS
StepFunctionsAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StepFunctionsAction] -> ShowS
$cshowList :: [StepFunctionsAction] -> ShowS
show :: StepFunctionsAction -> String
$cshow :: StepFunctionsAction -> String
showsPrec :: Int -> StepFunctionsAction -> ShowS
$cshowsPrec :: Int -> StepFunctionsAction -> ShowS
Prelude.Show, forall x. Rep StepFunctionsAction x -> StepFunctionsAction
forall x. StepFunctionsAction -> Rep StepFunctionsAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StepFunctionsAction x -> StepFunctionsAction
$cfrom :: forall x. StepFunctionsAction -> Rep StepFunctionsAction x
Prelude.Generic)

-- |
-- Create a value of 'StepFunctionsAction' 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:
--
-- 'executionNamePrefix', 'stepFunctionsAction_executionNamePrefix' - (Optional) A name will be given to the state machine execution
-- consisting of this prefix followed by a UUID. Step Functions
-- automatically creates a unique name for each state machine execution if
-- one is not provided.
--
-- 'stateMachineName', 'stepFunctionsAction_stateMachineName' - The name of the Step Functions state machine whose execution will be
-- started.
--
-- 'roleArn', 'stepFunctionsAction_roleArn' - The ARN of the role that grants IoT permission to start execution of a
-- state machine (\"Action\":\"states:StartExecution\").
newStepFunctionsAction ::
  -- | 'stateMachineName'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  StepFunctionsAction
newStepFunctionsAction :: Text -> Text -> StepFunctionsAction
newStepFunctionsAction Text
pStateMachineName_ Text
pRoleArn_ =
  StepFunctionsAction'
    { $sel:executionNamePrefix:StepFunctionsAction' :: Maybe Text
executionNamePrefix =
        forall a. Maybe a
Prelude.Nothing,
      $sel:stateMachineName:StepFunctionsAction' :: Text
stateMachineName = Text
pStateMachineName_,
      $sel:roleArn:StepFunctionsAction' :: Text
roleArn = Text
pRoleArn_
    }

-- | (Optional) A name will be given to the state machine execution
-- consisting of this prefix followed by a UUID. Step Functions
-- automatically creates a unique name for each state machine execution if
-- one is not provided.
stepFunctionsAction_executionNamePrefix :: Lens.Lens' StepFunctionsAction (Prelude.Maybe Prelude.Text)
stepFunctionsAction_executionNamePrefix :: Lens' StepFunctionsAction (Maybe Text)
stepFunctionsAction_executionNamePrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepFunctionsAction' {Maybe Text
executionNamePrefix :: Maybe Text
$sel:executionNamePrefix:StepFunctionsAction' :: StepFunctionsAction -> Maybe Text
executionNamePrefix} -> Maybe Text
executionNamePrefix) (\s :: StepFunctionsAction
s@StepFunctionsAction' {} Maybe Text
a -> StepFunctionsAction
s {$sel:executionNamePrefix:StepFunctionsAction' :: Maybe Text
executionNamePrefix = Maybe Text
a} :: StepFunctionsAction)

-- | The name of the Step Functions state machine whose execution will be
-- started.
stepFunctionsAction_stateMachineName :: Lens.Lens' StepFunctionsAction Prelude.Text
stepFunctionsAction_stateMachineName :: Lens' StepFunctionsAction Text
stepFunctionsAction_stateMachineName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepFunctionsAction' {Text
stateMachineName :: Text
$sel:stateMachineName:StepFunctionsAction' :: StepFunctionsAction -> Text
stateMachineName} -> Text
stateMachineName) (\s :: StepFunctionsAction
s@StepFunctionsAction' {} Text
a -> StepFunctionsAction
s {$sel:stateMachineName:StepFunctionsAction' :: Text
stateMachineName = Text
a} :: StepFunctionsAction)

-- | The ARN of the role that grants IoT permission to start execution of a
-- state machine (\"Action\":\"states:StartExecution\").
stepFunctionsAction_roleArn :: Lens.Lens' StepFunctionsAction Prelude.Text
stepFunctionsAction_roleArn :: Lens' StepFunctionsAction Text
stepFunctionsAction_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepFunctionsAction' {Text
roleArn :: Text
$sel:roleArn:StepFunctionsAction' :: StepFunctionsAction -> Text
roleArn} -> Text
roleArn) (\s :: StepFunctionsAction
s@StepFunctionsAction' {} Text
a -> StepFunctionsAction
s {$sel:roleArn:StepFunctionsAction' :: Text
roleArn = Text
a} :: StepFunctionsAction)

instance Data.FromJSON StepFunctionsAction where
  parseJSON :: Value -> Parser StepFunctionsAction
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StepFunctionsAction"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> StepFunctionsAction
StepFunctionsAction'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"executionNamePrefix")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"stateMachineName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"roleArn")
      )

instance Prelude.Hashable StepFunctionsAction where
  hashWithSalt :: Int -> StepFunctionsAction -> Int
hashWithSalt Int
_salt StepFunctionsAction' {Maybe Text
Text
roleArn :: Text
stateMachineName :: Text
executionNamePrefix :: Maybe Text
$sel:roleArn:StepFunctionsAction' :: StepFunctionsAction -> Text
$sel:stateMachineName:StepFunctionsAction' :: StepFunctionsAction -> Text
$sel:executionNamePrefix:StepFunctionsAction' :: StepFunctionsAction -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
executionNamePrefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
stateMachineName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
roleArn

instance Prelude.NFData StepFunctionsAction where
  rnf :: StepFunctionsAction -> ()
rnf StepFunctionsAction' {Maybe Text
Text
roleArn :: Text
stateMachineName :: Text
executionNamePrefix :: Maybe Text
$sel:roleArn:StepFunctionsAction' :: StepFunctionsAction -> Text
$sel:stateMachineName:StepFunctionsAction' :: StepFunctionsAction -> Text
$sel:executionNamePrefix:StepFunctionsAction' :: StepFunctionsAction -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
executionNamePrefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
stateMachineName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
roleArn

instance Data.ToJSON StepFunctionsAction where
  toJSON :: StepFunctionsAction -> Value
toJSON StepFunctionsAction' {Maybe Text
Text
roleArn :: Text
stateMachineName :: Text
executionNamePrefix :: Maybe Text
$sel:roleArn:StepFunctionsAction' :: StepFunctionsAction -> Text
$sel:stateMachineName:StepFunctionsAction' :: StepFunctionsAction -> Text
$sel:executionNamePrefix:StepFunctionsAction' :: StepFunctionsAction -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"executionNamePrefix" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
executionNamePrefix,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"stateMachineName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
stateMachineName),
            forall a. a -> Maybe a
Prelude.Just (Key
"roleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
roleArn)
          ]
      )