{-# 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.ExecutionResults
-- 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.ExecutionResults 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.ExecutionStepResult

-- | Specifies the steps in the workflow, as well as the steps to execute in
-- case of any errors during workflow execution.
--
-- /See:/ 'newExecutionResults' smart constructor.
data ExecutionResults = ExecutionResults'
  { -- | Specifies the steps (actions) to take if errors are encountered during
    -- execution of the workflow.
    ExecutionResults -> Maybe (NonEmpty ExecutionStepResult)
onExceptionSteps :: Prelude.Maybe (Prelude.NonEmpty ExecutionStepResult),
    -- | Specifies the details for the steps that are in the specified workflow.
    ExecutionResults -> Maybe (NonEmpty ExecutionStepResult)
steps :: Prelude.Maybe (Prelude.NonEmpty ExecutionStepResult)
  }
  deriving (ExecutionResults -> ExecutionResults -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecutionResults -> ExecutionResults -> Bool
$c/= :: ExecutionResults -> ExecutionResults -> Bool
== :: ExecutionResults -> ExecutionResults -> Bool
$c== :: ExecutionResults -> ExecutionResults -> Bool
Prelude.Eq, ReadPrec [ExecutionResults]
ReadPrec ExecutionResults
Int -> ReadS ExecutionResults
ReadS [ExecutionResults]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecutionResults]
$creadListPrec :: ReadPrec [ExecutionResults]
readPrec :: ReadPrec ExecutionResults
$creadPrec :: ReadPrec ExecutionResults
readList :: ReadS [ExecutionResults]
$creadList :: ReadS [ExecutionResults]
readsPrec :: Int -> ReadS ExecutionResults
$creadsPrec :: Int -> ReadS ExecutionResults
Prelude.Read, Int -> ExecutionResults -> ShowS
[ExecutionResults] -> ShowS
ExecutionResults -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecutionResults] -> ShowS
$cshowList :: [ExecutionResults] -> ShowS
show :: ExecutionResults -> String
$cshow :: ExecutionResults -> String
showsPrec :: Int -> ExecutionResults -> ShowS
$cshowsPrec :: Int -> ExecutionResults -> ShowS
Prelude.Show, forall x. Rep ExecutionResults x -> ExecutionResults
forall x. ExecutionResults -> Rep ExecutionResults x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecutionResults x -> ExecutionResults
$cfrom :: forall x. ExecutionResults -> Rep ExecutionResults x
Prelude.Generic)

-- |
-- Create a value of 'ExecutionResults' 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:
--
-- 'onExceptionSteps', 'executionResults_onExceptionSteps' - Specifies the steps (actions) to take if errors are encountered during
-- execution of the workflow.
--
-- 'steps', 'executionResults_steps' - Specifies the details for the steps that are in the specified workflow.
newExecutionResults ::
  ExecutionResults
newExecutionResults :: ExecutionResults
newExecutionResults =
  ExecutionResults'
    { $sel:onExceptionSteps:ExecutionResults' :: Maybe (NonEmpty ExecutionStepResult)
onExceptionSteps =
        forall a. Maybe a
Prelude.Nothing,
      $sel:steps:ExecutionResults' :: Maybe (NonEmpty ExecutionStepResult)
steps = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the steps (actions) to take if errors are encountered during
-- execution of the workflow.
executionResults_onExceptionSteps :: Lens.Lens' ExecutionResults (Prelude.Maybe (Prelude.NonEmpty ExecutionStepResult))
executionResults_onExceptionSteps :: Lens' ExecutionResults (Maybe (NonEmpty ExecutionStepResult))
executionResults_onExceptionSteps = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionResults' {Maybe (NonEmpty ExecutionStepResult)
onExceptionSteps :: Maybe (NonEmpty ExecutionStepResult)
$sel:onExceptionSteps:ExecutionResults' :: ExecutionResults -> Maybe (NonEmpty ExecutionStepResult)
onExceptionSteps} -> Maybe (NonEmpty ExecutionStepResult)
onExceptionSteps) (\s :: ExecutionResults
s@ExecutionResults' {} Maybe (NonEmpty ExecutionStepResult)
a -> ExecutionResults
s {$sel:onExceptionSteps:ExecutionResults' :: Maybe (NonEmpty ExecutionStepResult)
onExceptionSteps = Maybe (NonEmpty ExecutionStepResult)
a} :: ExecutionResults) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies the details for the steps that are in the specified workflow.
executionResults_steps :: Lens.Lens' ExecutionResults (Prelude.Maybe (Prelude.NonEmpty ExecutionStepResult))
executionResults_steps :: Lens' ExecutionResults (Maybe (NonEmpty ExecutionStepResult))
executionResults_steps = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionResults' {Maybe (NonEmpty ExecutionStepResult)
steps :: Maybe (NonEmpty ExecutionStepResult)
$sel:steps:ExecutionResults' :: ExecutionResults -> Maybe (NonEmpty ExecutionStepResult)
steps} -> Maybe (NonEmpty ExecutionStepResult)
steps) (\s :: ExecutionResults
s@ExecutionResults' {} Maybe (NonEmpty ExecutionStepResult)
a -> ExecutionResults
s {$sel:steps:ExecutionResults' :: Maybe (NonEmpty ExecutionStepResult)
steps = Maybe (NonEmpty ExecutionStepResult)
a} :: ExecutionResults) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON ExecutionResults where
  parseJSON :: Value -> Parser ExecutionResults
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ExecutionResults"
      ( \Object
x ->
          Maybe (NonEmpty ExecutionStepResult)
-> Maybe (NonEmpty ExecutionStepResult) -> ExecutionResults
ExecutionResults'
            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
"OnExceptionSteps")
            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
"Steps")
      )

instance Prelude.Hashable ExecutionResults where
  hashWithSalt :: Int -> ExecutionResults -> Int
hashWithSalt Int
_salt ExecutionResults' {Maybe (NonEmpty ExecutionStepResult)
steps :: Maybe (NonEmpty ExecutionStepResult)
onExceptionSteps :: Maybe (NonEmpty ExecutionStepResult)
$sel:steps:ExecutionResults' :: ExecutionResults -> Maybe (NonEmpty ExecutionStepResult)
$sel:onExceptionSteps:ExecutionResults' :: ExecutionResults -> Maybe (NonEmpty ExecutionStepResult)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty ExecutionStepResult)
onExceptionSteps
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty ExecutionStepResult)
steps

instance Prelude.NFData ExecutionResults where
  rnf :: ExecutionResults -> ()
rnf ExecutionResults' {Maybe (NonEmpty ExecutionStepResult)
steps :: Maybe (NonEmpty ExecutionStepResult)
onExceptionSteps :: Maybe (NonEmpty ExecutionStepResult)
$sel:steps:ExecutionResults' :: ExecutionResults -> Maybe (NonEmpty ExecutionStepResult)
$sel:onExceptionSteps:ExecutionResults' :: ExecutionResults -> Maybe (NonEmpty ExecutionStepResult)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty ExecutionStepResult)
onExceptionSteps
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty ExecutionStepResult)
steps