{-# 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.LakeFormation.Types.PartitionObjects
-- 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.LakeFormation.Types.PartitionObjects where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LakeFormation.Types.TableObject
import qualified Amazonka.Prelude as Prelude

-- | A structure containing a list of partition values and table objects.
--
-- /See:/ 'newPartitionObjects' smart constructor.
data PartitionObjects = PartitionObjects'
  { -- | A list of table objects
    PartitionObjects -> Maybe [TableObject]
objects :: Prelude.Maybe [TableObject],
    -- | A list of partition values.
    PartitionObjects -> Maybe (NonEmpty Text)
partitionValues :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text)
  }
  deriving (PartitionObjects -> PartitionObjects -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PartitionObjects -> PartitionObjects -> Bool
$c/= :: PartitionObjects -> PartitionObjects -> Bool
== :: PartitionObjects -> PartitionObjects -> Bool
$c== :: PartitionObjects -> PartitionObjects -> Bool
Prelude.Eq, ReadPrec [PartitionObjects]
ReadPrec PartitionObjects
Int -> ReadS PartitionObjects
ReadS [PartitionObjects]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PartitionObjects]
$creadListPrec :: ReadPrec [PartitionObjects]
readPrec :: ReadPrec PartitionObjects
$creadPrec :: ReadPrec PartitionObjects
readList :: ReadS [PartitionObjects]
$creadList :: ReadS [PartitionObjects]
readsPrec :: Int -> ReadS PartitionObjects
$creadsPrec :: Int -> ReadS PartitionObjects
Prelude.Read, Int -> PartitionObjects -> ShowS
[PartitionObjects] -> ShowS
PartitionObjects -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PartitionObjects] -> ShowS
$cshowList :: [PartitionObjects] -> ShowS
show :: PartitionObjects -> String
$cshow :: PartitionObjects -> String
showsPrec :: Int -> PartitionObjects -> ShowS
$cshowsPrec :: Int -> PartitionObjects -> ShowS
Prelude.Show, forall x. Rep PartitionObjects x -> PartitionObjects
forall x. PartitionObjects -> Rep PartitionObjects x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PartitionObjects x -> PartitionObjects
$cfrom :: forall x. PartitionObjects -> Rep PartitionObjects x
Prelude.Generic)

-- |
-- Create a value of 'PartitionObjects' 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:
--
-- 'objects', 'partitionObjects_objects' - A list of table objects
--
-- 'partitionValues', 'partitionObjects_partitionValues' - A list of partition values.
newPartitionObjects ::
  PartitionObjects
newPartitionObjects :: PartitionObjects
newPartitionObjects =
  PartitionObjects'
    { $sel:objects:PartitionObjects' :: Maybe [TableObject]
objects = forall a. Maybe a
Prelude.Nothing,
      $sel:partitionValues:PartitionObjects' :: Maybe (NonEmpty Text)
partitionValues = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of table objects
partitionObjects_objects :: Lens.Lens' PartitionObjects (Prelude.Maybe [TableObject])
partitionObjects_objects :: Lens' PartitionObjects (Maybe [TableObject])
partitionObjects_objects = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartitionObjects' {Maybe [TableObject]
objects :: Maybe [TableObject]
$sel:objects:PartitionObjects' :: PartitionObjects -> Maybe [TableObject]
objects} -> Maybe [TableObject]
objects) (\s :: PartitionObjects
s@PartitionObjects' {} Maybe [TableObject]
a -> PartitionObjects
s {$sel:objects:PartitionObjects' :: Maybe [TableObject]
objects = Maybe [TableObject]
a} :: PartitionObjects) 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

-- | A list of partition values.
partitionObjects_partitionValues :: Lens.Lens' PartitionObjects (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
partitionObjects_partitionValues :: Lens' PartitionObjects (Maybe (NonEmpty Text))
partitionObjects_partitionValues = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PartitionObjects' {Maybe (NonEmpty Text)
partitionValues :: Maybe (NonEmpty Text)
$sel:partitionValues:PartitionObjects' :: PartitionObjects -> Maybe (NonEmpty Text)
partitionValues} -> Maybe (NonEmpty Text)
partitionValues) (\s :: PartitionObjects
s@PartitionObjects' {} Maybe (NonEmpty Text)
a -> PartitionObjects
s {$sel:partitionValues:PartitionObjects' :: Maybe (NonEmpty Text)
partitionValues = Maybe (NonEmpty Text)
a} :: PartitionObjects) 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 PartitionObjects where
  parseJSON :: Value -> Parser PartitionObjects
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PartitionObjects"
      ( \Object
x ->
          Maybe [TableObject] -> Maybe (NonEmpty Text) -> PartitionObjects
PartitionObjects'
            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
"Objects" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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")
      )

instance Prelude.Hashable PartitionObjects where
  hashWithSalt :: Int -> PartitionObjects -> Int
hashWithSalt Int
_salt PartitionObjects' {Maybe [TableObject]
Maybe (NonEmpty Text)
partitionValues :: Maybe (NonEmpty Text)
objects :: Maybe [TableObject]
$sel:partitionValues:PartitionObjects' :: PartitionObjects -> Maybe (NonEmpty Text)
$sel:objects:PartitionObjects' :: PartitionObjects -> Maybe [TableObject]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [TableObject]
objects
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
partitionValues

instance Prelude.NFData PartitionObjects where
  rnf :: PartitionObjects -> ()
rnf PartitionObjects' {Maybe [TableObject]
Maybe (NonEmpty Text)
partitionValues :: Maybe (NonEmpty Text)
objects :: Maybe [TableObject]
$sel:partitionValues:PartitionObjects' :: PartitionObjects -> Maybe (NonEmpty Text)
$sel:objects:PartitionObjects' :: PartitionObjects -> Maybe [TableObject]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [TableObject]
objects
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
partitionValues