{-# 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.Transfer.Types.ExecutionStepResult
-- 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.Transfer.Types.ExecutionStepResult 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
import Amazonka.Transfer.Types.ExecutionError
import Amazonka.Transfer.Types.WorkflowStepType

-- | Specifies the following details for the step: error (if any), outputs
-- (if any), and the step type.
--
-- /See:/ 'newExecutionStepResult' smart constructor.
data ExecutionStepResult = ExecutionStepResult'
  { -- | Specifies the details for an error, if it occurred during execution of
    -- the specified workflow step.
    ExecutionStepResult -> Maybe ExecutionError
error :: Prelude.Maybe ExecutionError,
    -- | The values for the key\/value pair applied as a tag to the file. Only
    -- applicable if the step type is @TAG@.
    ExecutionStepResult -> Maybe Text
outputs :: Prelude.Maybe Prelude.Text,
    -- | One of the available step types.
    --
    -- -   /COPY/: Copy the file to another location.
    --
    -- -   /CUSTOM/: Perform a custom step with an Lambda function target.
    --
    -- -   /DELETE/: Delete the file.
    --
    -- -   /TAG/: Add a tag to the file.
    ExecutionStepResult -> Maybe WorkflowStepType
stepType :: Prelude.Maybe WorkflowStepType
  }
  deriving (ExecutionStepResult -> ExecutionStepResult -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecutionStepResult -> ExecutionStepResult -> Bool
$c/= :: ExecutionStepResult -> ExecutionStepResult -> Bool
== :: ExecutionStepResult -> ExecutionStepResult -> Bool
$c== :: ExecutionStepResult -> ExecutionStepResult -> Bool
Prelude.Eq, ReadPrec [ExecutionStepResult]
ReadPrec ExecutionStepResult
Int -> ReadS ExecutionStepResult
ReadS [ExecutionStepResult]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecutionStepResult]
$creadListPrec :: ReadPrec [ExecutionStepResult]
readPrec :: ReadPrec ExecutionStepResult
$creadPrec :: ReadPrec ExecutionStepResult
readList :: ReadS [ExecutionStepResult]
$creadList :: ReadS [ExecutionStepResult]
readsPrec :: Int -> ReadS ExecutionStepResult
$creadsPrec :: Int -> ReadS ExecutionStepResult
Prelude.Read, Int -> ExecutionStepResult -> ShowS
[ExecutionStepResult] -> ShowS
ExecutionStepResult -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecutionStepResult] -> ShowS
$cshowList :: [ExecutionStepResult] -> ShowS
show :: ExecutionStepResult -> String
$cshow :: ExecutionStepResult -> String
showsPrec :: Int -> ExecutionStepResult -> ShowS
$cshowsPrec :: Int -> ExecutionStepResult -> ShowS
Prelude.Show, forall x. Rep ExecutionStepResult x -> ExecutionStepResult
forall x. ExecutionStepResult -> Rep ExecutionStepResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecutionStepResult x -> ExecutionStepResult
$cfrom :: forall x. ExecutionStepResult -> Rep ExecutionStepResult x
Prelude.Generic)

-- |
-- Create a value of 'ExecutionStepResult' 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:
--
-- 'error', 'executionStepResult_error' - Specifies the details for an error, if it occurred during execution of
-- the specified workflow step.
--
-- 'outputs', 'executionStepResult_outputs' - The values for the key\/value pair applied as a tag to the file. Only
-- applicable if the step type is @TAG@.
--
-- 'stepType', 'executionStepResult_stepType' - One of the available step types.
--
-- -   /COPY/: Copy the file to another location.
--
-- -   /CUSTOM/: Perform a custom step with an Lambda function target.
--
-- -   /DELETE/: Delete the file.
--
-- -   /TAG/: Add a tag to the file.
newExecutionStepResult ::
  ExecutionStepResult
newExecutionStepResult :: ExecutionStepResult
newExecutionStepResult =
  ExecutionStepResult'
    { $sel:error:ExecutionStepResult' :: Maybe ExecutionError
error = forall a. Maybe a
Prelude.Nothing,
      $sel:outputs:ExecutionStepResult' :: Maybe Text
outputs = forall a. Maybe a
Prelude.Nothing,
      $sel:stepType:ExecutionStepResult' :: Maybe WorkflowStepType
stepType = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the details for an error, if it occurred during execution of
-- the specified workflow step.
executionStepResult_error :: Lens.Lens' ExecutionStepResult (Prelude.Maybe ExecutionError)
executionStepResult_error :: Lens' ExecutionStepResult (Maybe ExecutionError)
executionStepResult_error = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionStepResult' {Maybe ExecutionError
error :: Maybe ExecutionError
$sel:error:ExecutionStepResult' :: ExecutionStepResult -> Maybe ExecutionError
error} -> Maybe ExecutionError
error) (\s :: ExecutionStepResult
s@ExecutionStepResult' {} Maybe ExecutionError
a -> ExecutionStepResult
s {$sel:error:ExecutionStepResult' :: Maybe ExecutionError
error = Maybe ExecutionError
a} :: ExecutionStepResult)

-- | The values for the key\/value pair applied as a tag to the file. Only
-- applicable if the step type is @TAG@.
executionStepResult_outputs :: Lens.Lens' ExecutionStepResult (Prelude.Maybe Prelude.Text)
executionStepResult_outputs :: Lens' ExecutionStepResult (Maybe Text)
executionStepResult_outputs = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionStepResult' {Maybe Text
outputs :: Maybe Text
$sel:outputs:ExecutionStepResult' :: ExecutionStepResult -> Maybe Text
outputs} -> Maybe Text
outputs) (\s :: ExecutionStepResult
s@ExecutionStepResult' {} Maybe Text
a -> ExecutionStepResult
s {$sel:outputs:ExecutionStepResult' :: Maybe Text
outputs = Maybe Text
a} :: ExecutionStepResult)

-- | One of the available step types.
--
-- -   /COPY/: Copy the file to another location.
--
-- -   /CUSTOM/: Perform a custom step with an Lambda function target.
--
-- -   /DELETE/: Delete the file.
--
-- -   /TAG/: Add a tag to the file.
executionStepResult_stepType :: Lens.Lens' ExecutionStepResult (Prelude.Maybe WorkflowStepType)
executionStepResult_stepType :: Lens' ExecutionStepResult (Maybe WorkflowStepType)
executionStepResult_stepType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionStepResult' {Maybe WorkflowStepType
stepType :: Maybe WorkflowStepType
$sel:stepType:ExecutionStepResult' :: ExecutionStepResult -> Maybe WorkflowStepType
stepType} -> Maybe WorkflowStepType
stepType) (\s :: ExecutionStepResult
s@ExecutionStepResult' {} Maybe WorkflowStepType
a -> ExecutionStepResult
s {$sel:stepType:ExecutionStepResult' :: Maybe WorkflowStepType
stepType = Maybe WorkflowStepType
a} :: ExecutionStepResult)

instance Data.FromJSON ExecutionStepResult where
  parseJSON :: Value -> Parser ExecutionStepResult
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ExecutionStepResult"
      ( \Object
x ->
          Maybe ExecutionError
-> Maybe Text -> Maybe WorkflowStepType -> ExecutionStepResult
ExecutionStepResult'
            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
"Error")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Outputs")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StepType")
      )

instance Prelude.Hashable ExecutionStepResult where
  hashWithSalt :: Int -> ExecutionStepResult -> Int
hashWithSalt Int
_salt ExecutionStepResult' {Maybe Text
Maybe ExecutionError
Maybe WorkflowStepType
stepType :: Maybe WorkflowStepType
outputs :: Maybe Text
error :: Maybe ExecutionError
$sel:stepType:ExecutionStepResult' :: ExecutionStepResult -> Maybe WorkflowStepType
$sel:outputs:ExecutionStepResult' :: ExecutionStepResult -> Maybe Text
$sel:error:ExecutionStepResult' :: ExecutionStepResult -> Maybe ExecutionError
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ExecutionError
error
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
outputs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe WorkflowStepType
stepType

instance Prelude.NFData ExecutionStepResult where
  rnf :: ExecutionStepResult -> ()
rnf ExecutionStepResult' {Maybe Text
Maybe ExecutionError
Maybe WorkflowStepType
stepType :: Maybe WorkflowStepType
outputs :: Maybe Text
error :: Maybe ExecutionError
$sel:stepType:ExecutionStepResult' :: ExecutionStepResult -> Maybe WorkflowStepType
$sel:outputs:ExecutionStepResult' :: ExecutionStepResult -> Maybe Text
$sel:error:ExecutionStepResult' :: ExecutionStepResult -> Maybe ExecutionError
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ExecutionError
error
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
outputs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe WorkflowStepType
stepType