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

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

-- | Contains information about a partition error.
--
-- /See:/ 'newPartitionError' smart constructor.
data PartitionError = PartitionError'
  { -- | The values that define the partition.
    PartitionError -> Maybe [Text]
partitionValues :: Prelude.Maybe [Prelude.Text],
    -- | The details about the partition error.
    PartitionError -> Maybe ErrorDetail
errorDetail :: Prelude.Maybe ErrorDetail
  }
  deriving (PartitionError -> PartitionError -> Bool
(PartitionError -> PartitionError -> Bool)
-> (PartitionError -> PartitionError -> Bool) -> Eq PartitionError
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]
(Int -> ReadS PartitionError)
-> ReadS [PartitionError]
-> ReadPrec PartitionError
-> ReadPrec [PartitionError]
-> Read 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
(Int -> PartitionError -> ShowS)
-> (PartitionError -> String)
-> ([PartitionError] -> ShowS)
-> Show PartitionError
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. PartitionError -> Rep PartitionError x)
-> (forall x. Rep PartitionError x -> PartitionError)
-> Generic PartitionError
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:
--
-- 'partitionValues', 'partitionError_partitionValues' - The values that define the partition.
--
-- 'errorDetail', 'partitionError_errorDetail' - The details about the partition error.
newPartitionError ::
  PartitionError
newPartitionError :: PartitionError
newPartitionError =
  PartitionError' :: Maybe [Text] -> Maybe ErrorDetail -> PartitionError
PartitionError'
    { $sel:partitionValues:PartitionError' :: Maybe [Text]
partitionValues = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:errorDetail:PartitionError' :: Maybe ErrorDetail
errorDetail = Maybe ErrorDetail
forall a. Maybe a
Prelude.Nothing
    }

-- | The values that define the partition.
partitionError_partitionValues :: Lens.Lens' PartitionError (Prelude.Maybe [Prelude.Text])
partitionError_partitionValues :: (Maybe [Text] -> f (Maybe [Text]))
-> PartitionError -> f PartitionError
partitionError_partitionValues = (PartitionError -> Maybe [Text])
-> (PartitionError -> Maybe [Text] -> PartitionError)
-> Lens PartitionError PartitionError (Maybe [Text]) (Maybe [Text])
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) ((Maybe [Text] -> f (Maybe [Text]))
 -> PartitionError -> f PartitionError)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> PartitionError
-> f PartitionError
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Core.FromJSON PartitionError where
  parseJSON :: Value -> Parser PartitionError
parseJSON =
    String
-> (Object -> Parser PartitionError)
-> Value
-> Parser PartitionError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PartitionError"
      ( \Object
x ->
          Maybe [Text] -> Maybe ErrorDetail -> PartitionError
PartitionError'
            (Maybe [Text] -> Maybe ErrorDetail -> PartitionError)
-> Parser (Maybe [Text])
-> Parser (Maybe ErrorDetail -> PartitionError)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PartitionValues"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe ErrorDetail -> PartitionError)
-> Parser (Maybe ErrorDetail) -> Parser PartitionError
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 PartitionError

instance Prelude.NFData PartitionError