{-# 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.AccessAnalyzer.Types.JobError
-- 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.AccessAnalyzer.Types.JobError where

import Amazonka.AccessAnalyzer.Types.JobErrorCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains the details about the policy generation error.
--
-- /See:/ 'newJobError' smart constructor.
data JobError = JobError'
  { -- | The job error code.
    JobError -> JobErrorCode
code :: JobErrorCode,
    -- | Specific information about the error. For example, which service quota
    -- was exceeded or which resource was not found.
    JobError -> Text
message :: Prelude.Text
  }
  deriving (JobError -> JobError -> Bool
(JobError -> JobError -> Bool)
-> (JobError -> JobError -> Bool) -> Eq JobError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobError -> JobError -> Bool
$c/= :: JobError -> JobError -> Bool
== :: JobError -> JobError -> Bool
$c== :: JobError -> JobError -> Bool
Prelude.Eq, ReadPrec [JobError]
ReadPrec JobError
Int -> ReadS JobError
ReadS [JobError]
(Int -> ReadS JobError)
-> ReadS [JobError]
-> ReadPrec JobError
-> ReadPrec [JobError]
-> Read JobError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobError]
$creadListPrec :: ReadPrec [JobError]
readPrec :: ReadPrec JobError
$creadPrec :: ReadPrec JobError
readList :: ReadS [JobError]
$creadList :: ReadS [JobError]
readsPrec :: Int -> ReadS JobError
$creadsPrec :: Int -> ReadS JobError
Prelude.Read, Int -> JobError -> ShowS
[JobError] -> ShowS
JobError -> String
(Int -> JobError -> ShowS)
-> (JobError -> String) -> ([JobError] -> ShowS) -> Show JobError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobError] -> ShowS
$cshowList :: [JobError] -> ShowS
show :: JobError -> String
$cshow :: JobError -> String
showsPrec :: Int -> JobError -> ShowS
$cshowsPrec :: Int -> JobError -> ShowS
Prelude.Show, (forall x. JobError -> Rep JobError x)
-> (forall x. Rep JobError x -> JobError) -> Generic JobError
forall x. Rep JobError x -> JobError
forall x. JobError -> Rep JobError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobError x -> JobError
$cfrom :: forall x. JobError -> Rep JobError x
Prelude.Generic)

-- |
-- Create a value of 'JobError' 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:
--
-- 'code', 'jobError_code' - The job error code.
--
-- 'message', 'jobError_message' - Specific information about the error. For example, which service quota
-- was exceeded or which resource was not found.
newJobError ::
  -- | 'code'
  JobErrorCode ->
  -- | 'message'
  Prelude.Text ->
  JobError
newJobError :: JobErrorCode -> Text -> JobError
newJobError JobErrorCode
pCode_ Text
pMessage_ =
  JobError' :: JobErrorCode -> Text -> JobError
JobError' {$sel:code:JobError' :: JobErrorCode
code = JobErrorCode
pCode_, $sel:message:JobError' :: Text
message = Text
pMessage_}

-- | The job error code.
jobError_code :: Lens.Lens' JobError JobErrorCode
jobError_code :: (JobErrorCode -> f JobErrorCode) -> JobError -> f JobError
jobError_code = (JobError -> JobErrorCode)
-> (JobError -> JobErrorCode -> JobError)
-> Lens JobError JobError JobErrorCode JobErrorCode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobError' {JobErrorCode
code :: JobErrorCode
$sel:code:JobError' :: JobError -> JobErrorCode
code} -> JobErrorCode
code) (\s :: JobError
s@JobError' {} JobErrorCode
a -> JobError
s {$sel:code:JobError' :: JobErrorCode
code = JobErrorCode
a} :: JobError)

-- | Specific information about the error. For example, which service quota
-- was exceeded or which resource was not found.
jobError_message :: Lens.Lens' JobError Prelude.Text
jobError_message :: (Text -> f Text) -> JobError -> f JobError
jobError_message = (JobError -> Text)
-> (JobError -> Text -> JobError)
-> Lens JobError JobError Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobError' {Text
message :: Text
$sel:message:JobError' :: JobError -> Text
message} -> Text
message) (\s :: JobError
s@JobError' {} Text
a -> JobError
s {$sel:message:JobError' :: Text
message = Text
a} :: JobError)

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

instance Prelude.NFData JobError