{-# 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.HoneyCode.Types.FailedBatchItem
-- 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.HoneyCode.Types.FailedBatchItem where

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

-- | A single item in a batch that failed to perform the intended action
-- because of an error preventing it from succeeding.
--
-- /See:/ 'newFailedBatchItem' smart constructor.
data FailedBatchItem = FailedBatchItem'
  { -- | The id of the batch item that failed. This is the batch item id for the
    -- BatchCreateTableRows and BatchUpsertTableRows operations and the row id
    -- for the BatchUpdateTableRows and BatchDeleteTableRows operations.
    FailedBatchItem -> Text
id :: Prelude.Text,
    -- | The error message that indicates why the batch item failed.
    FailedBatchItem -> Text
errorMessage :: Prelude.Text
  }
  deriving (FailedBatchItem -> FailedBatchItem -> Bool
(FailedBatchItem -> FailedBatchItem -> Bool)
-> (FailedBatchItem -> FailedBatchItem -> Bool)
-> Eq FailedBatchItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FailedBatchItem -> FailedBatchItem -> Bool
$c/= :: FailedBatchItem -> FailedBatchItem -> Bool
== :: FailedBatchItem -> FailedBatchItem -> Bool
$c== :: FailedBatchItem -> FailedBatchItem -> Bool
Prelude.Eq, ReadPrec [FailedBatchItem]
ReadPrec FailedBatchItem
Int -> ReadS FailedBatchItem
ReadS [FailedBatchItem]
(Int -> ReadS FailedBatchItem)
-> ReadS [FailedBatchItem]
-> ReadPrec FailedBatchItem
-> ReadPrec [FailedBatchItem]
-> Read FailedBatchItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FailedBatchItem]
$creadListPrec :: ReadPrec [FailedBatchItem]
readPrec :: ReadPrec FailedBatchItem
$creadPrec :: ReadPrec FailedBatchItem
readList :: ReadS [FailedBatchItem]
$creadList :: ReadS [FailedBatchItem]
readsPrec :: Int -> ReadS FailedBatchItem
$creadsPrec :: Int -> ReadS FailedBatchItem
Prelude.Read, Int -> FailedBatchItem -> ShowS
[FailedBatchItem] -> ShowS
FailedBatchItem -> String
(Int -> FailedBatchItem -> ShowS)
-> (FailedBatchItem -> String)
-> ([FailedBatchItem] -> ShowS)
-> Show FailedBatchItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FailedBatchItem] -> ShowS
$cshowList :: [FailedBatchItem] -> ShowS
show :: FailedBatchItem -> String
$cshow :: FailedBatchItem -> String
showsPrec :: Int -> FailedBatchItem -> ShowS
$cshowsPrec :: Int -> FailedBatchItem -> ShowS
Prelude.Show, (forall x. FailedBatchItem -> Rep FailedBatchItem x)
-> (forall x. Rep FailedBatchItem x -> FailedBatchItem)
-> Generic FailedBatchItem
forall x. Rep FailedBatchItem x -> FailedBatchItem
forall x. FailedBatchItem -> Rep FailedBatchItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FailedBatchItem x -> FailedBatchItem
$cfrom :: forall x. FailedBatchItem -> Rep FailedBatchItem x
Prelude.Generic)

-- |
-- Create a value of 'FailedBatchItem' 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:
--
-- 'id', 'failedBatchItem_id' - The id of the batch item that failed. This is the batch item id for the
-- BatchCreateTableRows and BatchUpsertTableRows operations and the row id
-- for the BatchUpdateTableRows and BatchDeleteTableRows operations.
--
-- 'errorMessage', 'failedBatchItem_errorMessage' - The error message that indicates why the batch item failed.
newFailedBatchItem ::
  -- | 'id'
  Prelude.Text ->
  -- | 'errorMessage'
  Prelude.Text ->
  FailedBatchItem
newFailedBatchItem :: Text -> Text -> FailedBatchItem
newFailedBatchItem Text
pId_ Text
pErrorMessage_ =
  FailedBatchItem' :: Text -> Text -> FailedBatchItem
FailedBatchItem'
    { $sel:id:FailedBatchItem' :: Text
id = Text
pId_,
      $sel:errorMessage:FailedBatchItem' :: Text
errorMessage = Text
pErrorMessage_
    }

-- | The id of the batch item that failed. This is the batch item id for the
-- BatchCreateTableRows and BatchUpsertTableRows operations and the row id
-- for the BatchUpdateTableRows and BatchDeleteTableRows operations.
failedBatchItem_id :: Lens.Lens' FailedBatchItem Prelude.Text
failedBatchItem_id :: (Text -> f Text) -> FailedBatchItem -> f FailedBatchItem
failedBatchItem_id = (FailedBatchItem -> Text)
-> (FailedBatchItem -> Text -> FailedBatchItem)
-> Lens FailedBatchItem FailedBatchItem Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailedBatchItem' {Text
id :: Text
$sel:id:FailedBatchItem' :: FailedBatchItem -> Text
id} -> Text
id) (\s :: FailedBatchItem
s@FailedBatchItem' {} Text
a -> FailedBatchItem
s {$sel:id:FailedBatchItem' :: Text
id = Text
a} :: FailedBatchItem)

-- | The error message that indicates why the batch item failed.
failedBatchItem_errorMessage :: Lens.Lens' FailedBatchItem Prelude.Text
failedBatchItem_errorMessage :: (Text -> f Text) -> FailedBatchItem -> f FailedBatchItem
failedBatchItem_errorMessage = (FailedBatchItem -> Text)
-> (FailedBatchItem -> Text -> FailedBatchItem)
-> Lens FailedBatchItem FailedBatchItem Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FailedBatchItem' {Text
errorMessage :: Text
$sel:errorMessage:FailedBatchItem' :: FailedBatchItem -> Text
errorMessage} -> Text
errorMessage) (\s :: FailedBatchItem
s@FailedBatchItem' {} Text
a -> FailedBatchItem
s {$sel:errorMessage:FailedBatchItem' :: Text
errorMessage = Text
a} :: FailedBatchItem)

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

instance Prelude.Hashable FailedBatchItem

instance Prelude.NFData FailedBatchItem