{-# 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-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.Transfer.Types.ExecutionStepResult where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | One of the available step types.
    --
    -- -   /Copy/: copy the file to another location
    --
    -- -   /Custom/: custom step with a lambda target
    --
    -- -   /Delete/: delete the file
    --
    -- -   /Tag/: add a tag to the file
    ExecutionStepResult -> Maybe WorkflowStepType
stepType :: Prelude.Maybe WorkflowStepType,
    -- | Specifies the details for an error, if it occurred during execution of
    -- the specified workfow 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
  }
  deriving (ExecutionStepResult -> ExecutionStepResult -> Bool
(ExecutionStepResult -> ExecutionStepResult -> Bool)
-> (ExecutionStepResult -> ExecutionStepResult -> Bool)
-> Eq ExecutionStepResult
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]
(Int -> ReadS ExecutionStepResult)
-> ReadS [ExecutionStepResult]
-> ReadPrec ExecutionStepResult
-> ReadPrec [ExecutionStepResult]
-> Read 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
(Int -> ExecutionStepResult -> ShowS)
-> (ExecutionStepResult -> String)
-> ([ExecutionStepResult] -> ShowS)
-> Show ExecutionStepResult
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. ExecutionStepResult -> Rep ExecutionStepResult x)
-> (forall x. Rep ExecutionStepResult x -> ExecutionStepResult)
-> Generic ExecutionStepResult
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:
--
-- 'stepType', 'executionStepResult_stepType' - One of the available step types.
--
-- -   /Copy/: copy the file to another location
--
-- -   /Custom/: custom step with a lambda target
--
-- -   /Delete/: delete the file
--
-- -   /Tag/: add a tag to the file
--
-- 'error', 'executionStepResult_error' - Specifies the details for an error, if it occurred during execution of
-- the specified workfow 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@.
newExecutionStepResult ::
  ExecutionStepResult
newExecutionStepResult :: ExecutionStepResult
newExecutionStepResult =
  ExecutionStepResult' :: Maybe WorkflowStepType
-> Maybe ExecutionError -> Maybe Text -> ExecutionStepResult
ExecutionStepResult'
    { $sel:stepType:ExecutionStepResult' :: Maybe WorkflowStepType
stepType = Maybe WorkflowStepType
forall a. Maybe a
Prelude.Nothing,
      $sel:error:ExecutionStepResult' :: Maybe ExecutionError
error = Maybe ExecutionError
forall a. Maybe a
Prelude.Nothing,
      $sel:outputs:ExecutionStepResult' :: Maybe Text
outputs = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | One of the available step types.
--
-- -   /Copy/: copy the file to another location
--
-- -   /Custom/: custom step with a lambda target
--
-- -   /Delete/: delete the file
--
-- -   /Tag/: add a tag to the file
executionStepResult_stepType :: Lens.Lens' ExecutionStepResult (Prelude.Maybe WorkflowStepType)
executionStepResult_stepType :: (Maybe WorkflowStepType -> f (Maybe WorkflowStepType))
-> ExecutionStepResult -> f ExecutionStepResult
executionStepResult_stepType = (ExecutionStepResult -> Maybe WorkflowStepType)
-> (ExecutionStepResult
    -> Maybe WorkflowStepType -> ExecutionStepResult)
-> Lens
     ExecutionStepResult
     ExecutionStepResult
     (Maybe WorkflowStepType)
     (Maybe WorkflowStepType)
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)

-- | Specifies the details for an error, if it occurred during execution of
-- the specified workfow step.
executionStepResult_error :: Lens.Lens' ExecutionStepResult (Prelude.Maybe ExecutionError)
executionStepResult_error :: (Maybe ExecutionError -> f (Maybe ExecutionError))
-> ExecutionStepResult -> f ExecutionStepResult
executionStepResult_error = (ExecutionStepResult -> Maybe ExecutionError)
-> (ExecutionStepResult
    -> Maybe ExecutionError -> ExecutionStepResult)
-> Lens
     ExecutionStepResult
     ExecutionStepResult
     (Maybe ExecutionError)
     (Maybe ExecutionError)
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 :: (Maybe Text -> f (Maybe Text))
-> ExecutionStepResult -> f ExecutionStepResult
executionStepResult_outputs = (ExecutionStepResult -> Maybe Text)
-> (ExecutionStepResult -> Maybe Text -> ExecutionStepResult)
-> Lens
     ExecutionStepResult ExecutionStepResult (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable ExecutionStepResult

instance Prelude.NFData ExecutionStepResult