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

import qualified Amazonka.Core as Core
import Amazonka.DataExchange.Types.Code
import Amazonka.DataExchange.Types.Details
import Amazonka.DataExchange.Types.JobErrorLimitName
import Amazonka.DataExchange.Types.JobErrorResourceTypes
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An error that occurred with the job request.
--
-- /See:/ 'newJobError' smart constructor.
data JobError = JobError'
  { -- | The unique identifier for the resource related to the error.
    JobError -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | The name of the limit that was reached.
    JobError -> Maybe JobErrorLimitName
limitName :: Prelude.Maybe JobErrorLimitName,
    -- | The type of resource related to the error.
    JobError -> Maybe JobErrorResourceTypes
resourceType :: Prelude.Maybe JobErrorResourceTypes,
    -- | The details about the job error.
    JobError -> Maybe Details
details :: Prelude.Maybe Details,
    -- | The value of the exceeded limit.
    JobError -> Maybe Double
limitValue :: Prelude.Maybe Prelude.Double,
    -- | The message related to the job error.
    JobError -> Text
message :: Prelude.Text,
    -- | The code for the job error.
    JobError -> Code
code :: Code
  }
  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:
--
-- 'resourceId', 'jobError_resourceId' - The unique identifier for the resource related to the error.
--
-- 'limitName', 'jobError_limitName' - The name of the limit that was reached.
--
-- 'resourceType', 'jobError_resourceType' - The type of resource related to the error.
--
-- 'details', 'jobError_details' - The details about the job error.
--
-- 'limitValue', 'jobError_limitValue' - The value of the exceeded limit.
--
-- 'message', 'jobError_message' - The message related to the job error.
--
-- 'code', 'jobError_code' - The code for the job error.
newJobError ::
  -- | 'message'
  Prelude.Text ->
  -- | 'code'
  Code ->
  JobError
newJobError :: Text -> Code -> JobError
newJobError Text
pMessage_ Code
pCode_ =
  JobError' :: Maybe Text
-> Maybe JobErrorLimitName
-> Maybe JobErrorResourceTypes
-> Maybe Details
-> Maybe Double
-> Text
-> Code
-> JobError
JobError'
    { $sel:resourceId:JobError' :: Maybe Text
resourceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:limitName:JobError' :: Maybe JobErrorLimitName
limitName = Maybe JobErrorLimitName
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:JobError' :: Maybe JobErrorResourceTypes
resourceType = Maybe JobErrorResourceTypes
forall a. Maybe a
Prelude.Nothing,
      $sel:details:JobError' :: Maybe Details
details = Maybe Details
forall a. Maybe a
Prelude.Nothing,
      $sel:limitValue:JobError' :: Maybe Double
limitValue = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:message:JobError' :: Text
message = Text
pMessage_,
      $sel:code:JobError' :: Code
code = Code
pCode_
    }

-- | The unique identifier for the resource related to the error.
jobError_resourceId :: Lens.Lens' JobError (Prelude.Maybe Prelude.Text)
jobError_resourceId :: (Maybe Text -> f (Maybe Text)) -> JobError -> f JobError
jobError_resourceId = (JobError -> Maybe Text)
-> (JobError -> Maybe Text -> JobError)
-> Lens JobError JobError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobError' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:JobError' :: JobError -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: JobError
s@JobError' {} Maybe Text
a -> JobError
s {$sel:resourceId:JobError' :: Maybe Text
resourceId = Maybe Text
a} :: JobError)

-- | The name of the limit that was reached.
jobError_limitName :: Lens.Lens' JobError (Prelude.Maybe JobErrorLimitName)
jobError_limitName :: (Maybe JobErrorLimitName -> f (Maybe JobErrorLimitName))
-> JobError -> f JobError
jobError_limitName = (JobError -> Maybe JobErrorLimitName)
-> (JobError -> Maybe JobErrorLimitName -> JobError)
-> Lens
     JobError
     JobError
     (Maybe JobErrorLimitName)
     (Maybe JobErrorLimitName)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobError' {Maybe JobErrorLimitName
limitName :: Maybe JobErrorLimitName
$sel:limitName:JobError' :: JobError -> Maybe JobErrorLimitName
limitName} -> Maybe JobErrorLimitName
limitName) (\s :: JobError
s@JobError' {} Maybe JobErrorLimitName
a -> JobError
s {$sel:limitName:JobError' :: Maybe JobErrorLimitName
limitName = Maybe JobErrorLimitName
a} :: JobError)

-- | The type of resource related to the error.
jobError_resourceType :: Lens.Lens' JobError (Prelude.Maybe JobErrorResourceTypes)
jobError_resourceType :: (Maybe JobErrorResourceTypes -> f (Maybe JobErrorResourceTypes))
-> JobError -> f JobError
jobError_resourceType = (JobError -> Maybe JobErrorResourceTypes)
-> (JobError -> Maybe JobErrorResourceTypes -> JobError)
-> Lens
     JobError
     JobError
     (Maybe JobErrorResourceTypes)
     (Maybe JobErrorResourceTypes)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobError' {Maybe JobErrorResourceTypes
resourceType :: Maybe JobErrorResourceTypes
$sel:resourceType:JobError' :: JobError -> Maybe JobErrorResourceTypes
resourceType} -> Maybe JobErrorResourceTypes
resourceType) (\s :: JobError
s@JobError' {} Maybe JobErrorResourceTypes
a -> JobError
s {$sel:resourceType:JobError' :: Maybe JobErrorResourceTypes
resourceType = Maybe JobErrorResourceTypes
a} :: JobError)

-- | The details about the job error.
jobError_details :: Lens.Lens' JobError (Prelude.Maybe Details)
jobError_details :: (Maybe Details -> f (Maybe Details)) -> JobError -> f JobError
jobError_details = (JobError -> Maybe Details)
-> (JobError -> Maybe Details -> JobError)
-> Lens JobError JobError (Maybe Details) (Maybe Details)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobError' {Maybe Details
details :: Maybe Details
$sel:details:JobError' :: JobError -> Maybe Details
details} -> Maybe Details
details) (\s :: JobError
s@JobError' {} Maybe Details
a -> JobError
s {$sel:details:JobError' :: Maybe Details
details = Maybe Details
a} :: JobError)

-- | The value of the exceeded limit.
jobError_limitValue :: Lens.Lens' JobError (Prelude.Maybe Prelude.Double)
jobError_limitValue :: (Maybe Double -> f (Maybe Double)) -> JobError -> f JobError
jobError_limitValue = (JobError -> Maybe Double)
-> (JobError -> Maybe Double -> JobError)
-> Lens JobError JobError (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobError' {Maybe Double
limitValue :: Maybe Double
$sel:limitValue:JobError' :: JobError -> Maybe Double
limitValue} -> Maybe Double
limitValue) (\s :: JobError
s@JobError' {} Maybe Double
a -> JobError
s {$sel:limitValue:JobError' :: Maybe Double
limitValue = Maybe Double
a} :: JobError)

-- | The message related to the job error.
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)

-- | The code for the job error.
jobError_code :: Lens.Lens' JobError Code
jobError_code :: (Code -> f Code) -> JobError -> f JobError
jobError_code = (JobError -> Code)
-> (JobError -> Code -> JobError)
-> Lens JobError JobError Code Code
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobError' {Code
code :: Code
$sel:code:JobError' :: JobError -> Code
code} -> Code
code) (\s :: JobError
s@JobError' {} Code
a -> JobError
s {$sel:code:JobError' :: Code
code = Code
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 ->
          Maybe Text
-> Maybe JobErrorLimitName
-> Maybe JobErrorResourceTypes
-> Maybe Details
-> Maybe Double
-> Text
-> Code
-> JobError
JobError'
            (Maybe Text
 -> Maybe JobErrorLimitName
 -> Maybe JobErrorResourceTypes
 -> Maybe Details
 -> Maybe Double
 -> Text
 -> Code
 -> JobError)
-> Parser (Maybe Text)
-> Parser
     (Maybe JobErrorLimitName
      -> Maybe JobErrorResourceTypes
      -> Maybe Details
      -> Maybe Double
      -> Text
      -> Code
      -> JobError)
forall (f :: * -> *) a b. Functor 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
"ResourceId")
            Parser
  (Maybe JobErrorLimitName
   -> Maybe JobErrorResourceTypes
   -> Maybe Details
   -> Maybe Double
   -> Text
   -> Code
   -> JobError)
-> Parser (Maybe JobErrorLimitName)
-> Parser
     (Maybe JobErrorResourceTypes
      -> Maybe Details -> Maybe Double -> Text -> Code -> JobError)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe JobErrorLimitName)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LimitName")
            Parser
  (Maybe JobErrorResourceTypes
   -> Maybe Details -> Maybe Double -> Text -> Code -> JobError)
-> Parser (Maybe JobErrorResourceTypes)
-> Parser
     (Maybe Details -> Maybe Double -> Text -> Code -> JobError)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe JobErrorResourceTypes)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceType")
            Parser (Maybe Details -> Maybe Double -> Text -> Code -> JobError)
-> Parser (Maybe Details)
-> Parser (Maybe Double -> Text -> Code -> JobError)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Details)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Details")
            Parser (Maybe Double -> Text -> Code -> JobError)
-> Parser (Maybe Double) -> Parser (Text -> Code -> JobError)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LimitValue")
            Parser (Text -> Code -> JobError)
-> Parser Text -> Parser (Code -> 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")
            Parser (Code -> JobError) -> Parser Code -> Parser JobError
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Code
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Code")
      )

instance Prelude.Hashable JobError

instance Prelude.NFData JobError