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

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.BackfillErrorCode
import Amazonka.Glue.Types.PartitionValueList
import qualified Amazonka.Lens as Lens
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'
  { -- | A list of a limited number of partitions in the response.
    BackfillError -> Maybe [PartitionValueList]
partitions :: Prelude.Maybe [PartitionValueList],
    -- | The error code for an error that occurred when registering partition
    -- indexes for an existing table.
    BackfillError -> Maybe BackfillErrorCode
code :: Prelude.Maybe BackfillErrorCode
  }
  deriving (BackfillError -> BackfillError -> Bool
(BackfillError -> BackfillError -> Bool)
-> (BackfillError -> BackfillError -> Bool) -> Eq BackfillError
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]
(Int -> ReadS BackfillError)
-> ReadS [BackfillError]
-> ReadPrec BackfillError
-> ReadPrec [BackfillError]
-> Read 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
(Int -> BackfillError -> ShowS)
-> (BackfillError -> String)
-> ([BackfillError] -> ShowS)
-> Show BackfillError
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. BackfillError -> Rep BackfillError x)
-> (forall x. Rep BackfillError x -> BackfillError)
-> Generic BackfillError
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:
--
-- 'partitions', 'backfillError_partitions' - A list of a limited number of partitions in the response.
--
-- 'code', 'backfillError_code' - The error code for an error that occurred when registering partition
-- indexes for an existing table.
newBackfillError ::
  BackfillError
newBackfillError :: BackfillError
newBackfillError =
  BackfillError' :: Maybe [PartitionValueList]
-> Maybe BackfillErrorCode -> BackfillError
BackfillError'
    { $sel:partitions:BackfillError' :: Maybe [PartitionValueList]
partitions = Maybe [PartitionValueList]
forall a. Maybe a
Prelude.Nothing,
      $sel:code:BackfillError' :: Maybe BackfillErrorCode
code = Maybe BackfillErrorCode
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of a limited number of partitions in the response.
backfillError_partitions :: Lens.Lens' BackfillError (Prelude.Maybe [PartitionValueList])
backfillError_partitions :: (Maybe [PartitionValueList] -> f (Maybe [PartitionValueList]))
-> BackfillError -> f BackfillError
backfillError_partitions = (BackfillError -> Maybe [PartitionValueList])
-> (BackfillError -> Maybe [PartitionValueList] -> BackfillError)
-> Lens
     BackfillError
     BackfillError
     (Maybe [PartitionValueList])
     (Maybe [PartitionValueList])
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) ((Maybe [PartitionValueList] -> f (Maybe [PartitionValueList]))
 -> BackfillError -> f BackfillError)
-> ((Maybe [PartitionValueList] -> f (Maybe [PartitionValueList]))
    -> Maybe [PartitionValueList] -> f (Maybe [PartitionValueList]))
-> (Maybe [PartitionValueList] -> f (Maybe [PartitionValueList]))
-> BackfillError
-> f BackfillError
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PartitionValueList]
  [PartitionValueList]
  [PartitionValueList]
  [PartitionValueList]
-> Iso
     (Maybe [PartitionValueList])
     (Maybe [PartitionValueList])
     (Maybe [PartitionValueList])
     (Maybe [PartitionValueList])
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 AnIso
  [PartitionValueList]
  [PartitionValueList]
  [PartitionValueList]
  [PartitionValueList]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: (Maybe BackfillErrorCode -> f (Maybe BackfillErrorCode))
-> BackfillError -> f BackfillError
backfillError_code = (BackfillError -> Maybe BackfillErrorCode)
-> (BackfillError -> Maybe BackfillErrorCode -> BackfillError)
-> Lens
     BackfillError
     BackfillError
     (Maybe BackfillErrorCode)
     (Maybe BackfillErrorCode)
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)

instance Core.FromJSON BackfillError where
  parseJSON :: Value -> Parser BackfillError
parseJSON =
    String
-> (Object -> Parser BackfillError)
-> Value
-> Parser BackfillError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BackfillError"
      ( \Object
x ->
          Maybe [PartitionValueList]
-> Maybe BackfillErrorCode -> BackfillError
BackfillError'
            (Maybe [PartitionValueList]
 -> Maybe BackfillErrorCode -> BackfillError)
-> Parser (Maybe [PartitionValueList])
-> Parser (Maybe BackfillErrorCode -> BackfillError)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [PartitionValueList]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Partitions" Parser (Maybe (Maybe [PartitionValueList]))
-> Maybe [PartitionValueList]
-> Parser (Maybe [PartitionValueList])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [PartitionValueList]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe BackfillErrorCode -> BackfillError)
-> Parser (Maybe BackfillErrorCode) -> Parser BackfillError
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe BackfillErrorCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Code")
      )

instance Prelude.Hashable BackfillError

instance Prelude.NFData BackfillError