{-# 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-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.IoT.Types.StepFunctionsAction where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(StepFunctionsAction -> StepFunctionsAction -> Bool)
-> (StepFunctionsAction -> StepFunctionsAction -> Bool)
-> Eq StepFunctionsAction
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]
(Int -> ReadS StepFunctionsAction)
-> ReadS [StepFunctionsAction]
-> ReadPrec StepFunctionsAction
-> ReadPrec [StepFunctionsAction]
-> Read 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
(Int -> StepFunctionsAction -> ShowS)
-> (StepFunctionsAction -> String)
-> ([StepFunctionsAction] -> ShowS)
-> Show StepFunctionsAction
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. StepFunctionsAction -> Rep StepFunctionsAction x)
-> (forall x. Rep StepFunctionsAction x -> StepFunctionsAction)
-> Generic StepFunctionsAction
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' :: Maybe Text -> Text -> Text -> StepFunctionsAction
StepFunctionsAction'
    { $sel:executionNamePrefix:StepFunctionsAction' :: Maybe Text
executionNamePrefix =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> StepFunctionsAction -> f StepFunctionsAction
stepFunctionsAction_executionNamePrefix = (StepFunctionsAction -> Maybe Text)
-> (StepFunctionsAction -> Maybe Text -> StepFunctionsAction)
-> Lens
     StepFunctionsAction StepFunctionsAction (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> StepFunctionsAction -> f StepFunctionsAction
stepFunctionsAction_stateMachineName = (StepFunctionsAction -> Text)
-> (StepFunctionsAction -> Text -> StepFunctionsAction)
-> Lens StepFunctionsAction StepFunctionsAction Text Text
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 :: (Text -> f Text) -> StepFunctionsAction -> f StepFunctionsAction
stepFunctionsAction_roleArn = (StepFunctionsAction -> Text)
-> (StepFunctionsAction -> Text -> StepFunctionsAction)
-> Lens StepFunctionsAction StepFunctionsAction Text Text
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 Core.FromJSON StepFunctionsAction where
  parseJSON :: Value -> Parser StepFunctionsAction
parseJSON =
    String
-> (Object -> Parser StepFunctionsAction)
-> Value
-> Parser StepFunctionsAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StepFunctionsAction"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> StepFunctionsAction
StepFunctionsAction'
            (Maybe Text -> Text -> Text -> StepFunctionsAction)
-> Parser (Maybe Text)
-> Parser (Text -> Text -> StepFunctionsAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"executionNamePrefix")
            Parser (Text -> Text -> StepFunctionsAction)
-> Parser Text -> Parser (Text -> StepFunctionsAction)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"stateMachineName")
            Parser (Text -> StepFunctionsAction)
-> Parser Text -> Parser StepFunctionsAction
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"roleArn")
      )

instance Prelude.Hashable StepFunctionsAction

instance Prelude.NFData StepFunctionsAction

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"executionNamePrefix" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
executionNamePrefix,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"stateMachineName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
stateMachineName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn)
          ]
      )