{-# 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-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.Glue.Types.TableError where

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

-- | An error record for table operations.
--
-- /See:/ 'newTableError' smart constructor.
data TableError = TableError'
  { -- | The name of the table. For Hive compatibility, this must be entirely
    -- lowercase.
    TableError -> Maybe Text
tableName :: Prelude.Maybe Prelude.Text,
    -- | The details about the error.
    TableError -> Maybe ErrorDetail
errorDetail :: Prelude.Maybe ErrorDetail
  }
  deriving (TableError -> TableError -> Bool
(TableError -> TableError -> Bool)
-> (TableError -> TableError -> Bool) -> Eq TableError
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]
(Int -> ReadS TableError)
-> ReadS [TableError]
-> ReadPrec TableError
-> ReadPrec [TableError]
-> Read 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
(Int -> TableError -> ShowS)
-> (TableError -> String)
-> ([TableError] -> ShowS)
-> Show TableError
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. TableError -> Rep TableError x)
-> (forall x. Rep TableError x -> TableError) -> Generic TableError
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:
--
-- 'tableName', 'tableError_tableName' - The name of the table. For Hive compatibility, this must be entirely
-- lowercase.
--
-- 'errorDetail', 'tableError_errorDetail' - The details about the error.
newTableError ::
  TableError
newTableError :: TableError
newTableError =
  TableError' :: Maybe Text -> Maybe ErrorDetail -> TableError
TableError'
    { $sel:tableName:TableError' :: Maybe Text
tableName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:errorDetail:TableError' :: Maybe ErrorDetail
errorDetail = Maybe ErrorDetail
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the table. For Hive compatibility, this must be entirely
-- lowercase.
tableError_tableName :: Lens.Lens' TableError (Prelude.Maybe Prelude.Text)
tableError_tableName :: (Maybe Text -> f (Maybe Text)) -> TableError -> f TableError
tableError_tableName = (TableError -> Maybe Text)
-> (TableError -> Maybe Text -> TableError)
-> Lens TableError TableError (Maybe Text) (Maybe Text)
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)

-- | The details about the error.
tableError_errorDetail :: Lens.Lens' TableError (Prelude.Maybe ErrorDetail)
tableError_errorDetail :: (Maybe ErrorDetail -> f (Maybe ErrorDetail))
-> TableError -> f TableError
tableError_errorDetail = (TableError -> Maybe ErrorDetail)
-> (TableError -> Maybe ErrorDetail -> TableError)
-> Lens
     TableError TableError (Maybe ErrorDetail) (Maybe 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)

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

instance Prelude.Hashable TableError

instance Prelude.NFData TableError