{-# 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.ColumnError
-- 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.ColumnError where

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

-- | Encapsulates a column name that failed and the reason for failure.
--
-- /See:/ 'newColumnError' smart constructor.
data ColumnError = ColumnError'
  { -- | An error message with the reason for the failure of an operation.
    ColumnError -> Maybe ErrorDetail
error :: Prelude.Maybe ErrorDetail,
    -- | The name of the column that failed.
    ColumnError -> Maybe Text
columnName :: Prelude.Maybe Prelude.Text
  }
  deriving (ColumnError -> ColumnError -> Bool
(ColumnError -> ColumnError -> Bool)
-> (ColumnError -> ColumnError -> Bool) -> Eq ColumnError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColumnError -> ColumnError -> Bool
$c/= :: ColumnError -> ColumnError -> Bool
== :: ColumnError -> ColumnError -> Bool
$c== :: ColumnError -> ColumnError -> Bool
Prelude.Eq, ReadPrec [ColumnError]
ReadPrec ColumnError
Int -> ReadS ColumnError
ReadS [ColumnError]
(Int -> ReadS ColumnError)
-> ReadS [ColumnError]
-> ReadPrec ColumnError
-> ReadPrec [ColumnError]
-> Read ColumnError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColumnError]
$creadListPrec :: ReadPrec [ColumnError]
readPrec :: ReadPrec ColumnError
$creadPrec :: ReadPrec ColumnError
readList :: ReadS [ColumnError]
$creadList :: ReadS [ColumnError]
readsPrec :: Int -> ReadS ColumnError
$creadsPrec :: Int -> ReadS ColumnError
Prelude.Read, Int -> ColumnError -> ShowS
[ColumnError] -> ShowS
ColumnError -> String
(Int -> ColumnError -> ShowS)
-> (ColumnError -> String)
-> ([ColumnError] -> ShowS)
-> Show ColumnError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColumnError] -> ShowS
$cshowList :: [ColumnError] -> ShowS
show :: ColumnError -> String
$cshow :: ColumnError -> String
showsPrec :: Int -> ColumnError -> ShowS
$cshowsPrec :: Int -> ColumnError -> ShowS
Prelude.Show, (forall x. ColumnError -> Rep ColumnError x)
-> (forall x. Rep ColumnError x -> ColumnError)
-> Generic ColumnError
forall x. Rep ColumnError x -> ColumnError
forall x. ColumnError -> Rep ColumnError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColumnError x -> ColumnError
$cfrom :: forall x. ColumnError -> Rep ColumnError x
Prelude.Generic)

-- |
-- Create a value of 'ColumnError' 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:
--
-- 'error', 'columnError_error' - An error message with the reason for the failure of an operation.
--
-- 'columnName', 'columnError_columnName' - The name of the column that failed.
newColumnError ::
  ColumnError
newColumnError :: ColumnError
newColumnError =
  ColumnError' :: Maybe ErrorDetail -> Maybe Text -> ColumnError
ColumnError'
    { $sel:error:ColumnError' :: Maybe ErrorDetail
error = Maybe ErrorDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:columnName:ColumnError' :: Maybe Text
columnName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | An error message with the reason for the failure of an operation.
columnError_error :: Lens.Lens' ColumnError (Prelude.Maybe ErrorDetail)
columnError_error :: (Maybe ErrorDetail -> f (Maybe ErrorDetail))
-> ColumnError -> f ColumnError
columnError_error = (ColumnError -> Maybe ErrorDetail)
-> (ColumnError -> Maybe ErrorDetail -> ColumnError)
-> Lens
     ColumnError ColumnError (Maybe ErrorDetail) (Maybe ErrorDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnError' {Maybe ErrorDetail
error :: Maybe ErrorDetail
$sel:error:ColumnError' :: ColumnError -> Maybe ErrorDetail
error} -> Maybe ErrorDetail
error) (\s :: ColumnError
s@ColumnError' {} Maybe ErrorDetail
a -> ColumnError
s {$sel:error:ColumnError' :: Maybe ErrorDetail
error = Maybe ErrorDetail
a} :: ColumnError)

-- | The name of the column that failed.
columnError_columnName :: Lens.Lens' ColumnError (Prelude.Maybe Prelude.Text)
columnError_columnName :: (Maybe Text -> f (Maybe Text)) -> ColumnError -> f ColumnError
columnError_columnName = (ColumnError -> Maybe Text)
-> (ColumnError -> Maybe Text -> ColumnError)
-> Lens ColumnError ColumnError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColumnError' {Maybe Text
columnName :: Maybe Text
$sel:columnName:ColumnError' :: ColumnError -> Maybe Text
columnName} -> Maybe Text
columnName) (\s :: ColumnError
s@ColumnError' {} Maybe Text
a -> ColumnError
s {$sel:columnName:ColumnError' :: Maybe Text
columnName = Maybe Text
a} :: ColumnError)

instance Core.FromJSON ColumnError where
  parseJSON :: Value -> Parser ColumnError
parseJSON =
    String
-> (Object -> Parser ColumnError) -> Value -> Parser ColumnError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ColumnError"
      ( \Object
x ->
          Maybe ErrorDetail -> Maybe Text -> ColumnError
ColumnError'
            (Maybe ErrorDetail -> Maybe Text -> ColumnError)
-> Parser (Maybe ErrorDetail) -> Parser (Maybe Text -> ColumnError)
forall (f :: * -> *) a b. Functor 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
"Error")
            Parser (Maybe Text -> ColumnError)
-> Parser (Maybe Text) -> Parser ColumnError
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
"ColumnName")
      )

instance Prelude.Hashable ColumnError

instance Prelude.NFData ColumnError