{-# 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.Glue.Types.TableError
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glue.Types.TableError where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.ErrorDetail
import qualified Amazonka.Prelude as Prelude

-- | An error record for table operations.
--
-- /See:/ 'newTableError' smart constructor.
data TableError = TableError'
  { -- | The details about the error.
    TableError -> Maybe ErrorDetail
errorDetail :: Prelude.Maybe ErrorDetail,
    -- | The name of the table. For Hive compatibility, this must be entirely
    -- lowercase.
    TableError -> Maybe Text
tableName :: Prelude.Maybe Prelude.Text
  }
  deriving (TableError -> TableError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TableError -> TableError -> Bool
$c/= :: TableError -> TableError -> Bool
== :: TableError -> TableError -> Bool
$c== :: TableError -> TableError -> Bool
Prelude.Eq, ReadPrec [TableError]
ReadPrec TableError
Int -> ReadS TableError
ReadS [TableError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TableError]
$creadListPrec :: ReadPrec [TableError]
readPrec :: ReadPrec TableError
$creadPrec :: ReadPrec TableError
readList :: ReadS [TableError]
$creadList :: ReadS [TableError]
readsPrec :: Int -> ReadS TableError
$creadsPrec :: Int -> ReadS TableError
Prelude.Read, Int -> TableError -> ShowS
[TableError] -> ShowS
TableError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TableError] -> ShowS
$cshowList :: [TableError] -> ShowS
show :: TableError -> String
$cshow :: TableError -> String
showsPrec :: Int -> TableError -> ShowS
$cshowsPrec :: Int -> TableError -> ShowS
Prelude.Show, forall x. Rep TableError x -> TableError
forall x. TableError -> Rep TableError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TableError x -> TableError
$cfrom :: forall x. TableError -> Rep TableError x
Prelude.Generic)

-- |
-- Create a value of 'TableError' 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:
--
-- 'errorDetail', 'tableError_errorDetail' - The details about the error.
--
-- 'tableName', 'tableError_tableName' - The name of the table. For Hive compatibility, this must be entirely
-- lowercase.
newTableError ::
  TableError
newTableError :: TableError
newTableError =
  TableError'
    { $sel:errorDetail:TableError' :: Maybe ErrorDetail
errorDetail = forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:TableError' :: Maybe Text
tableName = forall a. Maybe a
Prelude.Nothing
    }

-- | The details about the error.
tableError_errorDetail :: Lens.Lens' TableError (Prelude.Maybe ErrorDetail)
tableError_errorDetail :: Lens' TableError (Maybe ErrorDetail)
tableError_errorDetail = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableError' {Maybe ErrorDetail
errorDetail :: Maybe ErrorDetail
$sel:errorDetail:TableError' :: TableError -> Maybe ErrorDetail
errorDetail} -> Maybe ErrorDetail
errorDetail) (\s :: TableError
s@TableError' {} Maybe ErrorDetail
a -> TableError
s {$sel:errorDetail:TableError' :: Maybe ErrorDetail
errorDetail = Maybe ErrorDetail
a} :: TableError)

-- | The name of the table. For Hive compatibility, this must be entirely
-- lowercase.
tableError_tableName :: Lens.Lens' TableError (Prelude.Maybe Prelude.Text)
tableError_tableName :: Lens' TableError (Maybe Text)
tableError_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TableError' {Maybe Text
tableName :: Maybe Text
$sel:tableName:TableError' :: TableError -> Maybe Text
tableName} -> Maybe Text
tableName) (\s :: TableError
s@TableError' {} Maybe Text
a -> TableError
s {$sel:tableName:TableError' :: Maybe Text
tableName = Maybe Text
a} :: TableError)

instance Data.FromJSON TableError where
  parseJSON :: Value -> Parser TableError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TableError"
      ( \Object
x ->
          Maybe ErrorDetail -> Maybe Text -> TableError
TableError'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ErrorDetail")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TableName")
      )

instance Prelude.Hashable TableError where
  hashWithSalt :: Int -> TableError -> Int
hashWithSalt Int
_salt TableError' {Maybe Text
Maybe ErrorDetail
tableName :: Maybe Text
errorDetail :: Maybe ErrorDetail
$sel:tableName:TableError' :: TableError -> Maybe Text
$sel:errorDetail:TableError' :: TableError -> Maybe ErrorDetail
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ErrorDetail
errorDetail
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
tableName

instance Prelude.NFData TableError where
  rnf :: TableError -> ()
rnf TableError' {Maybe Text
Maybe ErrorDetail
tableName :: Maybe Text
errorDetail :: Maybe ErrorDetail
$sel:tableName:TableError' :: TableError -> Maybe Text
$sel:errorDetail:TableError' :: TableError -> Maybe ErrorDetail
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ErrorDetail
errorDetail
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tableName