{-# 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.BackfillError
-- 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.BackfillError 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.BackfillErrorCode
import Amazonka.Glue.Types.PartitionValueList
import qualified Amazonka.Prelude as Prelude

-- | A list of errors that can occur when registering partition indexes for
-- an existing table.
--
-- These errors give the details about why an index registration failed and
-- provide a limited number of partitions in the response, so that you can
-- fix the partitions at fault and try registering the index again. The
-- most common set of errors that can occur are categorized as follows:
--
-- -   EncryptedPartitionError: The partitions are encrypted.
--
-- -   InvalidPartitionTypeDataError: The partition value doesn\'t match
--     the data type for that partition column.
--
-- -   MissingPartitionValueError: The partitions are encrypted.
--
-- -   UnsupportedPartitionCharacterError: Characters inside the partition
--     value are not supported. For example: U+0000 , U+0001, U+0002.
--
-- -   InternalError: Any error which does not belong to other error codes.
--
-- /See:/ 'newBackfillError' smart constructor.
data BackfillError = BackfillError'
  { -- | The error code for an error that occurred when registering partition
    -- indexes for an existing table.
    BackfillError -> Maybe BackfillErrorCode
code :: Prelude.Maybe BackfillErrorCode,
    -- | A list of a limited number of partitions in the response.
    BackfillError -> Maybe [PartitionValueList]
partitions :: Prelude.Maybe [PartitionValueList]
  }
  deriving (BackfillError -> BackfillError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BackfillError -> BackfillError -> Bool
$c/= :: BackfillError -> BackfillError -> Bool
== :: BackfillError -> BackfillError -> Bool
$c== :: BackfillError -> BackfillError -> Bool
Prelude.Eq, ReadPrec [BackfillError]
ReadPrec BackfillError
Int -> ReadS BackfillError
ReadS [BackfillError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BackfillError]
$creadListPrec :: ReadPrec [BackfillError]
readPrec :: ReadPrec BackfillError
$creadPrec :: ReadPrec BackfillError
readList :: ReadS [BackfillError]
$creadList :: ReadS [BackfillError]
readsPrec :: Int -> ReadS BackfillError
$creadsPrec :: Int -> ReadS BackfillError
Prelude.Read, Int -> BackfillError -> ShowS
[BackfillError] -> ShowS
BackfillError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BackfillError] -> ShowS
$cshowList :: [BackfillError] -> ShowS
show :: BackfillError -> String
$cshow :: BackfillError -> String
showsPrec :: Int -> BackfillError -> ShowS
$cshowsPrec :: Int -> BackfillError -> ShowS
Prelude.Show, forall x. Rep BackfillError x -> BackfillError
forall x. BackfillError -> Rep BackfillError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BackfillError x -> BackfillError
$cfrom :: forall x. BackfillError -> Rep BackfillError x
Prelude.Generic)

-- |
-- Create a value of 'BackfillError' 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:
--
-- 'code', 'backfillError_code' - The error code for an error that occurred when registering partition
-- indexes for an existing table.
--
-- 'partitions', 'backfillError_partitions' - A list of a limited number of partitions in the response.
newBackfillError ::
  BackfillError
newBackfillError :: BackfillError
newBackfillError =
  BackfillError'
    { $sel:code:BackfillError' :: Maybe BackfillErrorCode
code = forall a. Maybe a
Prelude.Nothing,
      $sel:partitions:BackfillError' :: Maybe [PartitionValueList]
partitions = forall a. Maybe a
Prelude.Nothing
    }

-- | The error code for an error that occurred when registering partition
-- indexes for an existing table.
backfillError_code :: Lens.Lens' BackfillError (Prelude.Maybe BackfillErrorCode)
backfillError_code :: Lens' BackfillError (Maybe BackfillErrorCode)
backfillError_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackfillError' {Maybe BackfillErrorCode
code :: Maybe BackfillErrorCode
$sel:code:BackfillError' :: BackfillError -> Maybe BackfillErrorCode
code} -> Maybe BackfillErrorCode
code) (\s :: BackfillError
s@BackfillError' {} Maybe BackfillErrorCode
a -> BackfillError
s {$sel:code:BackfillError' :: Maybe BackfillErrorCode
code = Maybe BackfillErrorCode
a} :: BackfillError)

-- | A list of a limited number of partitions in the response.
backfillError_partitions :: Lens.Lens' BackfillError (Prelude.Maybe [PartitionValueList])
backfillError_partitions :: Lens' BackfillError (Maybe [PartitionValueList])
backfillError_partitions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BackfillError' {Maybe [PartitionValueList]
partitions :: Maybe [PartitionValueList]
$sel:partitions:BackfillError' :: BackfillError -> Maybe [PartitionValueList]
partitions} -> Maybe [PartitionValueList]
partitions) (\s :: BackfillError
s@BackfillError' {} Maybe [PartitionValueList]
a -> BackfillError
s {$sel:partitions:BackfillError' :: Maybe [PartitionValueList]
partitions = Maybe [PartitionValueList]
a} :: BackfillError) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON BackfillError where
  parseJSON :: Value -> Parser BackfillError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BackfillError"
      ( \Object
x ->
          Maybe BackfillErrorCode
-> Maybe [PartitionValueList] -> BackfillError
BackfillError'
            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
"Code")
            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
"Partitions" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable BackfillError where
  hashWithSalt :: Int -> BackfillError -> Int
hashWithSalt Int
_salt BackfillError' {Maybe [PartitionValueList]
Maybe BackfillErrorCode
partitions :: Maybe [PartitionValueList]
code :: Maybe BackfillErrorCode
$sel:partitions:BackfillError' :: BackfillError -> Maybe [PartitionValueList]
$sel:code:BackfillError' :: BackfillError -> Maybe BackfillErrorCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe BackfillErrorCode
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PartitionValueList]
partitions

instance Prelude.NFData BackfillError where
  rnf :: BackfillError -> ()
rnf BackfillError' {Maybe [PartitionValueList]
Maybe BackfillErrorCode
partitions :: Maybe [PartitionValueList]
code :: Maybe BackfillErrorCode
$sel:partitions:BackfillError' :: BackfillError -> Maybe [PartitionValueList]
$sel:code:BackfillError' :: BackfillError -> Maybe BackfillErrorCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe BackfillErrorCode
code
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [PartitionValueList]
partitions