{-# 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.PartitionError
-- 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.PartitionError 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

-- | Contains information about a partition error.
--
-- /See:/ 'newPartitionError' smart constructor.
data PartitionError = PartitionError'
  { -- | The details about the partition error.
    PartitionError -> Maybe ErrorDetail
errorDetail :: Prelude.Maybe ErrorDetail,
    -- | The values that define the partition.
    PartitionError -> Maybe [Text]
partitionValues :: Prelude.Maybe [Prelude.Text]
  }
  deriving (PartitionError -> PartitionError -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PartitionError -> PartitionError -> Bool
$c/= :: PartitionError -> PartitionError -> Bool
== :: PartitionError -> PartitionError -> Bool
$c== :: PartitionError -> PartitionError -> Bool
Prelude.Eq, ReadPrec [PartitionError]
ReadPrec PartitionError
Int -> ReadS PartitionError
ReadS [PartitionError]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PartitionError]
$creadListPrec :: ReadPrec [PartitionError]
readPrec :: ReadPrec PartitionError
$creadPrec :: ReadPrec PartitionError
readList :: ReadS [PartitionError]
$creadList :: ReadS [PartitionError]
readsPrec :: Int -> ReadS PartitionError
$creadsPrec :: Int -> ReadS PartitionError
Prelude.Read, Int -> PartitionError -> ShowS
[PartitionError] -> ShowS
PartitionError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PartitionError] -> ShowS
$cshowList :: [PartitionError] -> ShowS
show :: PartitionError -> String
$cshow :: PartitionError -> String
showsPrec :: Int -> PartitionError -> ShowS
$cshowsPrec :: Int -> PartitionError -> ShowS
Prelude.Show, forall x. Rep PartitionError x -> PartitionError
forall x. PartitionError -> Rep PartitionError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PartitionError x -> PartitionError
$cfrom :: forall x. PartitionError -> Rep PartitionError x
Prelude.Generic)

-- |
-- Create a value of 'PartitionError' 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', 'partitionError_errorDetail' - The details about the partition error.
--
-- 'partitionValues', 'partitionError_partitionValues' - The values that define the partition.
newPartitionError ::
  PartitionError
newPartitionError :: PartitionError
newPartitionError =
  PartitionError'
    { $sel:errorDetail:PartitionError' :: Maybe ErrorDetail
errorDetail = forall a. Maybe a
Prelude.Nothing,
      $sel:partitionValues:PartitionError' :: Maybe [Text]
partitionValues = forall a. Maybe a
Prelude.Nothing
    }

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

-- | The values that define the partition.
partitionError_partitionValues :: Lens.Lens' PartitionError (Prelude.Maybe [Prelude.Text])
partitionError_partitionValues :: Lens' PartitionError (Maybe [Text])
partitionError_partitionValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartitionError' {Maybe [Text]
partitionValues :: Maybe [Text]
$sel:partitionValues:PartitionError' :: PartitionError -> Maybe [Text]
partitionValues} -> Maybe [Text]
partitionValues) (\s :: PartitionError
s@PartitionError' {} Maybe [Text]
a -> PartitionError
s {$sel:partitionValues:PartitionError' :: Maybe [Text]
partitionValues = Maybe [Text]
a} :: PartitionError) 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 PartitionError where
  parseJSON :: Value -> Parser PartitionError
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PartitionError"
      ( \Object
x ->
          Maybe ErrorDetail -> Maybe [Text] -> PartitionError
PartitionError'
            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
"PartitionValues"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable PartitionError where
  hashWithSalt :: Int -> PartitionError -> Int
hashWithSalt Int
_salt PartitionError' {Maybe [Text]
Maybe ErrorDetail
partitionValues :: Maybe [Text]
errorDetail :: Maybe ErrorDetail
$sel:partitionValues:PartitionError' :: PartitionError -> Maybe [Text]
$sel:errorDetail:PartitionError' :: PartitionError -> 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]
partitionValues

instance Prelude.NFData PartitionError where
  rnf :: PartitionError -> ()
rnf PartitionError' {Maybe [Text]
Maybe ErrorDetail
partitionValues :: Maybe [Text]
errorDetail :: Maybe ErrorDetail
$sel:partitionValues:PartitionError' :: PartitionError -> Maybe [Text]
$sel:errorDetail:PartitionError' :: PartitionError -> 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]
partitionValues