{-# 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.ExecutionError
-- 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.ExecutionError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Transfer.Types.ExecutionErrorType

-- | Specifies the error message and type, for an error that occurs during
-- the execution of the workflow.
--
-- /See:/ 'newExecutionError' smart constructor.
data ExecutionError = ExecutionError'
  { -- | Specifies the error type: currently, the only valid value is
    -- @PERMISSION_DENIED@, which occurs if your policy does not contain the
    -- correct permissions to complete one or more of the steps in the
    -- workflow.
    ExecutionError -> ExecutionErrorType
type' :: ExecutionErrorType,
    -- | Specifies the descriptive message that corresponds to the @ErrorType@.
    ExecutionError -> Text
message :: Prelude.Text
  }
  deriving (ExecutionError -> ExecutionError -> Bool
(ExecutionError -> ExecutionError -> Bool)
-> (ExecutionError -> ExecutionError -> Bool) -> Eq ExecutionError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecutionError -> ExecutionError -> Bool
$c/= :: ExecutionError -> ExecutionError -> Bool
== :: ExecutionError -> ExecutionError -> Bool
$c== :: ExecutionError -> ExecutionError -> Bool
Prelude.Eq, ReadPrec [ExecutionError]
ReadPrec ExecutionError
Int -> ReadS ExecutionError
ReadS [ExecutionError]
(Int -> ReadS ExecutionError)
-> ReadS [ExecutionError]
-> ReadPrec ExecutionError
-> ReadPrec [ExecutionError]
-> Read ExecutionError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecutionError]
$creadListPrec :: ReadPrec [ExecutionError]
readPrec :: ReadPrec ExecutionError
$creadPrec :: ReadPrec ExecutionError
readList :: ReadS [ExecutionError]
$creadList :: ReadS [ExecutionError]
readsPrec :: Int -> ReadS ExecutionError
$creadsPrec :: Int -> ReadS ExecutionError
Prelude.Read, Int -> ExecutionError -> ShowS
[ExecutionError] -> ShowS
ExecutionError -> String
(Int -> ExecutionError -> ShowS)
-> (ExecutionError -> String)
-> ([ExecutionError] -> ShowS)
-> Show ExecutionError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecutionError] -> ShowS
$cshowList :: [ExecutionError] -> ShowS
show :: ExecutionError -> String
$cshow :: ExecutionError -> String
showsPrec :: Int -> ExecutionError -> ShowS
$cshowsPrec :: Int -> ExecutionError -> ShowS
Prelude.Show, (forall x. ExecutionError -> Rep ExecutionError x)
-> (forall x. Rep ExecutionError x -> ExecutionError)
-> Generic ExecutionError
forall x. Rep ExecutionError x -> ExecutionError
forall x. ExecutionError -> Rep ExecutionError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecutionError x -> ExecutionError
$cfrom :: forall x. ExecutionError -> Rep ExecutionError x
Prelude.Generic)

-- |
-- Create a value of 'ExecutionError' 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:
--
-- 'type'', 'executionError_type' - Specifies the error type: currently, the only valid value is
-- @PERMISSION_DENIED@, which occurs if your policy does not contain the
-- correct permissions to complete one or more of the steps in the
-- workflow.
--
-- 'message', 'executionError_message' - Specifies the descriptive message that corresponds to the @ErrorType@.
newExecutionError ::
  -- | 'type''
  ExecutionErrorType ->
  -- | 'message'
  Prelude.Text ->
  ExecutionError
newExecutionError :: ExecutionErrorType -> Text -> ExecutionError
newExecutionError ExecutionErrorType
pType_ Text
pMessage_ =
  ExecutionError' :: ExecutionErrorType -> Text -> ExecutionError
ExecutionError'
    { $sel:type':ExecutionError' :: ExecutionErrorType
type' = ExecutionErrorType
pType_,
      $sel:message:ExecutionError' :: Text
message = Text
pMessage_
    }

-- | Specifies the error type: currently, the only valid value is
-- @PERMISSION_DENIED@, which occurs if your policy does not contain the
-- correct permissions to complete one or more of the steps in the
-- workflow.
executionError_type :: Lens.Lens' ExecutionError ExecutionErrorType
executionError_type :: (ExecutionErrorType -> f ExecutionErrorType)
-> ExecutionError -> f ExecutionError
executionError_type = (ExecutionError -> ExecutionErrorType)
-> (ExecutionError -> ExecutionErrorType -> ExecutionError)
-> Lens
     ExecutionError ExecutionError ExecutionErrorType ExecutionErrorType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionError' {ExecutionErrorType
type' :: ExecutionErrorType
$sel:type':ExecutionError' :: ExecutionError -> ExecutionErrorType
type'} -> ExecutionErrorType
type') (\s :: ExecutionError
s@ExecutionError' {} ExecutionErrorType
a -> ExecutionError
s {$sel:type':ExecutionError' :: ExecutionErrorType
type' = ExecutionErrorType
a} :: ExecutionError)

-- | Specifies the descriptive message that corresponds to the @ErrorType@.
executionError_message :: Lens.Lens' ExecutionError Prelude.Text
executionError_message :: (Text -> f Text) -> ExecutionError -> f ExecutionError
executionError_message = (ExecutionError -> Text)
-> (ExecutionError -> Text -> ExecutionError)
-> Lens ExecutionError ExecutionError Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExecutionError' {Text
message :: Text
$sel:message:ExecutionError' :: ExecutionError -> Text
message} -> Text
message) (\s :: ExecutionError
s@ExecutionError' {} Text
a -> ExecutionError
s {$sel:message:ExecutionError' :: Text
message = Text
a} :: ExecutionError)

instance Core.FromJSON ExecutionError where
  parseJSON :: Value -> Parser ExecutionError
parseJSON =
    String
-> (Object -> Parser ExecutionError)
-> Value
-> Parser ExecutionError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExecutionError"
      ( \Object
x ->
          ExecutionErrorType -> Text -> ExecutionError
ExecutionError'
            (ExecutionErrorType -> Text -> ExecutionError)
-> Parser ExecutionErrorType -> Parser (Text -> ExecutionError)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser ExecutionErrorType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type") Parser (Text -> ExecutionError)
-> Parser Text -> Parser ExecutionError
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
"Message")
      )

instance Prelude.Hashable ExecutionError

instance Prelude.NFData ExecutionError