{-# 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.Comprehend.Types.BatchItemError
-- 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.Comprehend.Types.BatchItemError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes an error that occurred while processing a document in a batch.
-- The operation returns on @BatchItemError@ object for each document that
-- contained an error.
--
-- /See:/ 'newBatchItemError' smart constructor.
data BatchItemError = BatchItemError'
  { -- | The numeric error code of the error.
    BatchItemError -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text,
    -- | A text description of the error.
    BatchItemError -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text,
    -- | The zero-based index of the document in the input list.
    BatchItemError -> Maybe Int
index :: Prelude.Maybe Prelude.Int
  }
  deriving (BatchItemError -> BatchItemError -> Bool
(BatchItemError -> BatchItemError -> Bool)
-> (BatchItemError -> BatchItemError -> Bool) -> Eq BatchItemError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchItemError -> BatchItemError -> Bool
$c/= :: BatchItemError -> BatchItemError -> Bool
== :: BatchItemError -> BatchItemError -> Bool
$c== :: BatchItemError -> BatchItemError -> Bool
Prelude.Eq, ReadPrec [BatchItemError]
ReadPrec BatchItemError
Int -> ReadS BatchItemError
ReadS [BatchItemError]
(Int -> ReadS BatchItemError)
-> ReadS [BatchItemError]
-> ReadPrec BatchItemError
-> ReadPrec [BatchItemError]
-> Read BatchItemError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchItemError]
$creadListPrec :: ReadPrec [BatchItemError]
readPrec :: ReadPrec BatchItemError
$creadPrec :: ReadPrec BatchItemError
readList :: ReadS [BatchItemError]
$creadList :: ReadS [BatchItemError]
readsPrec :: Int -> ReadS BatchItemError
$creadsPrec :: Int -> ReadS BatchItemError
Prelude.Read, Int -> BatchItemError -> ShowS
[BatchItemError] -> ShowS
BatchItemError -> String
(Int -> BatchItemError -> ShowS)
-> (BatchItemError -> String)
-> ([BatchItemError] -> ShowS)
-> Show BatchItemError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchItemError] -> ShowS
$cshowList :: [BatchItemError] -> ShowS
show :: BatchItemError -> String
$cshow :: BatchItemError -> String
showsPrec :: Int -> BatchItemError -> ShowS
$cshowsPrec :: Int -> BatchItemError -> ShowS
Prelude.Show, (forall x. BatchItemError -> Rep BatchItemError x)
-> (forall x. Rep BatchItemError x -> BatchItemError)
-> Generic BatchItemError
forall x. Rep BatchItemError x -> BatchItemError
forall x. BatchItemError -> Rep BatchItemError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchItemError x -> BatchItemError
$cfrom :: forall x. BatchItemError -> Rep BatchItemError x
Prelude.Generic)

-- |
-- Create a value of 'BatchItemError' 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:
--
-- 'errorCode', 'batchItemError_errorCode' - The numeric error code of the error.
--
-- 'errorMessage', 'batchItemError_errorMessage' - A text description of the error.
--
-- 'index', 'batchItemError_index' - The zero-based index of the document in the input list.
newBatchItemError ::
  BatchItemError
newBatchItemError :: BatchItemError
newBatchItemError =
  BatchItemError' :: Maybe Text -> Maybe Text -> Maybe Int -> BatchItemError
BatchItemError'
    { $sel:errorCode:BatchItemError' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:BatchItemError' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:index:BatchItemError' :: Maybe Int
index = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The numeric error code of the error.
batchItemError_errorCode :: Lens.Lens' BatchItemError (Prelude.Maybe Prelude.Text)
batchItemError_errorCode :: (Maybe Text -> f (Maybe Text))
-> BatchItemError -> f BatchItemError
batchItemError_errorCode = (BatchItemError -> Maybe Text)
-> (BatchItemError -> Maybe Text -> BatchItemError)
-> Lens BatchItemError BatchItemError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchItemError' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:BatchItemError' :: BatchItemError -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: BatchItemError
s@BatchItemError' {} Maybe Text
a -> BatchItemError
s {$sel:errorCode:BatchItemError' :: Maybe Text
errorCode = Maybe Text
a} :: BatchItemError)

-- | A text description of the error.
batchItemError_errorMessage :: Lens.Lens' BatchItemError (Prelude.Maybe Prelude.Text)
batchItemError_errorMessage :: (Maybe Text -> f (Maybe Text))
-> BatchItemError -> f BatchItemError
batchItemError_errorMessage = (BatchItemError -> Maybe Text)
-> (BatchItemError -> Maybe Text -> BatchItemError)
-> Lens BatchItemError BatchItemError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchItemError' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:BatchItemError' :: BatchItemError -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: BatchItemError
s@BatchItemError' {} Maybe Text
a -> BatchItemError
s {$sel:errorMessage:BatchItemError' :: Maybe Text
errorMessage = Maybe Text
a} :: BatchItemError)

-- | The zero-based index of the document in the input list.
batchItemError_index :: Lens.Lens' BatchItemError (Prelude.Maybe Prelude.Int)
batchItemError_index :: (Maybe Int -> f (Maybe Int)) -> BatchItemError -> f BatchItemError
batchItemError_index = (BatchItemError -> Maybe Int)
-> (BatchItemError -> Maybe Int -> BatchItemError)
-> Lens BatchItemError BatchItemError (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchItemError' {Maybe Int
index :: Maybe Int
$sel:index:BatchItemError' :: BatchItemError -> Maybe Int
index} -> Maybe Int
index) (\s :: BatchItemError
s@BatchItemError' {} Maybe Int
a -> BatchItemError
s {$sel:index:BatchItemError' :: Maybe Int
index = Maybe Int
a} :: BatchItemError)

instance Core.FromJSON BatchItemError where
  parseJSON :: Value -> Parser BatchItemError
parseJSON =
    String
-> (Object -> Parser BatchItemError)
-> Value
-> Parser BatchItemError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BatchItemError"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Int -> BatchItemError
BatchItemError'
            (Maybe Text -> Maybe Text -> Maybe Int -> BatchItemError)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Int -> BatchItemError)
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
"ErrorCode")
            Parser (Maybe Text -> Maybe Int -> BatchItemError)
-> Parser (Maybe Text) -> Parser (Maybe Int -> BatchItemError)
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
"ErrorMessage")
            Parser (Maybe Int -> BatchItemError)
-> Parser (Maybe Int) -> Parser BatchItemError
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Index")
      )

instance Prelude.Hashable BatchItemError

instance Prelude.NFData BatchItemError