{-# 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.S3CatalogSource
-- 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.S3CatalogSource 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.S3SourceAdditionalOptions
import qualified Amazonka.Prelude as Prelude

-- | Specifies an Amazon S3 data store in the Glue Data Catalog.
--
-- /See:/ 'newS3CatalogSource' smart constructor.
data S3CatalogSource = S3CatalogSource'
  { -- | Specifies additional connection options.
    S3CatalogSource -> Maybe S3SourceAdditionalOptions
additionalOptions :: Prelude.Maybe S3SourceAdditionalOptions,
    -- | Partitions satisfying this predicate are deleted. Files within the
    -- retention period in these partitions are not deleted. Set to @\"\"@ –
    -- empty by default.
    S3CatalogSource -> Maybe Text
partitionPredicate :: Prelude.Maybe Prelude.Text,
    -- | The name of the data store.
    S3CatalogSource -> Text
name :: Prelude.Text,
    -- | The database to read from.
    S3CatalogSource -> Text
database :: Prelude.Text,
    -- | The database table to read from.
    S3CatalogSource -> Text
table :: Prelude.Text
  }
  deriving (S3CatalogSource -> S3CatalogSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3CatalogSource -> S3CatalogSource -> Bool
$c/= :: S3CatalogSource -> S3CatalogSource -> Bool
== :: S3CatalogSource -> S3CatalogSource -> Bool
$c== :: S3CatalogSource -> S3CatalogSource -> Bool
Prelude.Eq, ReadPrec [S3CatalogSource]
ReadPrec S3CatalogSource
Int -> ReadS S3CatalogSource
ReadS [S3CatalogSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3CatalogSource]
$creadListPrec :: ReadPrec [S3CatalogSource]
readPrec :: ReadPrec S3CatalogSource
$creadPrec :: ReadPrec S3CatalogSource
readList :: ReadS [S3CatalogSource]
$creadList :: ReadS [S3CatalogSource]
readsPrec :: Int -> ReadS S3CatalogSource
$creadsPrec :: Int -> ReadS S3CatalogSource
Prelude.Read, Int -> S3CatalogSource -> ShowS
[S3CatalogSource] -> ShowS
S3CatalogSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3CatalogSource] -> ShowS
$cshowList :: [S3CatalogSource] -> ShowS
show :: S3CatalogSource -> String
$cshow :: S3CatalogSource -> String
showsPrec :: Int -> S3CatalogSource -> ShowS
$cshowsPrec :: Int -> S3CatalogSource -> ShowS
Prelude.Show, forall x. Rep S3CatalogSource x -> S3CatalogSource
forall x. S3CatalogSource -> Rep S3CatalogSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3CatalogSource x -> S3CatalogSource
$cfrom :: forall x. S3CatalogSource -> Rep S3CatalogSource x
Prelude.Generic)

-- |
-- Create a value of 'S3CatalogSource' 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:
--
-- 'additionalOptions', 's3CatalogSource_additionalOptions' - Specifies additional connection options.
--
-- 'partitionPredicate', 's3CatalogSource_partitionPredicate' - Partitions satisfying this predicate are deleted. Files within the
-- retention period in these partitions are not deleted. Set to @\"\"@ –
-- empty by default.
--
-- 'name', 's3CatalogSource_name' - The name of the data store.
--
-- 'database', 's3CatalogSource_database' - The database to read from.
--
-- 'table', 's3CatalogSource_table' - The database table to read from.
newS3CatalogSource ::
  -- | 'name'
  Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  -- | 'table'
  Prelude.Text ->
  S3CatalogSource
newS3CatalogSource :: Text -> Text -> Text -> S3CatalogSource
newS3CatalogSource Text
pName_ Text
pDatabase_ Text
pTable_ =
  S3CatalogSource'
    { $sel:additionalOptions:S3CatalogSource' :: Maybe S3SourceAdditionalOptions
additionalOptions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:partitionPredicate:S3CatalogSource' :: Maybe Text
partitionPredicate = forall a. Maybe a
Prelude.Nothing,
      $sel:name:S3CatalogSource' :: Text
name = Text
pName_,
      $sel:database:S3CatalogSource' :: Text
database = Text
pDatabase_,
      $sel:table:S3CatalogSource' :: Text
table = Text
pTable_
    }

-- | Specifies additional connection options.
s3CatalogSource_additionalOptions :: Lens.Lens' S3CatalogSource (Prelude.Maybe S3SourceAdditionalOptions)
s3CatalogSource_additionalOptions :: Lens' S3CatalogSource (Maybe S3SourceAdditionalOptions)
s3CatalogSource_additionalOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3CatalogSource' {Maybe S3SourceAdditionalOptions
additionalOptions :: Maybe S3SourceAdditionalOptions
$sel:additionalOptions:S3CatalogSource' :: S3CatalogSource -> Maybe S3SourceAdditionalOptions
additionalOptions} -> Maybe S3SourceAdditionalOptions
additionalOptions) (\s :: S3CatalogSource
s@S3CatalogSource' {} Maybe S3SourceAdditionalOptions
a -> S3CatalogSource
s {$sel:additionalOptions:S3CatalogSource' :: Maybe S3SourceAdditionalOptions
additionalOptions = Maybe S3SourceAdditionalOptions
a} :: S3CatalogSource)

-- | Partitions satisfying this predicate are deleted. Files within the
-- retention period in these partitions are not deleted. Set to @\"\"@ –
-- empty by default.
s3CatalogSource_partitionPredicate :: Lens.Lens' S3CatalogSource (Prelude.Maybe Prelude.Text)
s3CatalogSource_partitionPredicate :: Lens' S3CatalogSource (Maybe Text)
s3CatalogSource_partitionPredicate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3CatalogSource' {Maybe Text
partitionPredicate :: Maybe Text
$sel:partitionPredicate:S3CatalogSource' :: S3CatalogSource -> Maybe Text
partitionPredicate} -> Maybe Text
partitionPredicate) (\s :: S3CatalogSource
s@S3CatalogSource' {} Maybe Text
a -> S3CatalogSource
s {$sel:partitionPredicate:S3CatalogSource' :: Maybe Text
partitionPredicate = Maybe Text
a} :: S3CatalogSource)

-- | The name of the data store.
s3CatalogSource_name :: Lens.Lens' S3CatalogSource Prelude.Text
s3CatalogSource_name :: Lens' S3CatalogSource Text
s3CatalogSource_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3CatalogSource' {Text
name :: Text
$sel:name:S3CatalogSource' :: S3CatalogSource -> Text
name} -> Text
name) (\s :: S3CatalogSource
s@S3CatalogSource' {} Text
a -> S3CatalogSource
s {$sel:name:S3CatalogSource' :: Text
name = Text
a} :: S3CatalogSource)

-- | The database to read from.
s3CatalogSource_database :: Lens.Lens' S3CatalogSource Prelude.Text
s3CatalogSource_database :: Lens' S3CatalogSource Text
s3CatalogSource_database = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3CatalogSource' {Text
database :: Text
$sel:database:S3CatalogSource' :: S3CatalogSource -> Text
database} -> Text
database) (\s :: S3CatalogSource
s@S3CatalogSource' {} Text
a -> S3CatalogSource
s {$sel:database:S3CatalogSource' :: Text
database = Text
a} :: S3CatalogSource)

-- | The database table to read from.
s3CatalogSource_table :: Lens.Lens' S3CatalogSource Prelude.Text
s3CatalogSource_table :: Lens' S3CatalogSource Text
s3CatalogSource_table = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3CatalogSource' {Text
table :: Text
$sel:table:S3CatalogSource' :: S3CatalogSource -> Text
table} -> Text
table) (\s :: S3CatalogSource
s@S3CatalogSource' {} Text
a -> S3CatalogSource
s {$sel:table:S3CatalogSource' :: Text
table = Text
a} :: S3CatalogSource)

instance Data.FromJSON S3CatalogSource where
  parseJSON :: Value -> Parser S3CatalogSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3CatalogSource"
      ( \Object
x ->
          Maybe S3SourceAdditionalOptions
-> Maybe Text -> Text -> Text -> Text -> S3CatalogSource
S3CatalogSource'
            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
"AdditionalOptions")
            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
"PartitionPredicate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Database")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Table")
      )

instance Prelude.Hashable S3CatalogSource where
  hashWithSalt :: Int -> S3CatalogSource -> Int
hashWithSalt Int
_salt S3CatalogSource' {Maybe Text
Maybe S3SourceAdditionalOptions
Text
table :: Text
database :: Text
name :: Text
partitionPredicate :: Maybe Text
additionalOptions :: Maybe S3SourceAdditionalOptions
$sel:table:S3CatalogSource' :: S3CatalogSource -> Text
$sel:database:S3CatalogSource' :: S3CatalogSource -> Text
$sel:name:S3CatalogSource' :: S3CatalogSource -> Text
$sel:partitionPredicate:S3CatalogSource' :: S3CatalogSource -> Maybe Text
$sel:additionalOptions:S3CatalogSource' :: S3CatalogSource -> Maybe S3SourceAdditionalOptions
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3SourceAdditionalOptions
additionalOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
partitionPredicate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
database
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
table

instance Prelude.NFData S3CatalogSource where
  rnf :: S3CatalogSource -> ()
rnf S3CatalogSource' {Maybe Text
Maybe S3SourceAdditionalOptions
Text
table :: Text
database :: Text
name :: Text
partitionPredicate :: Maybe Text
additionalOptions :: Maybe S3SourceAdditionalOptions
$sel:table:S3CatalogSource' :: S3CatalogSource -> Text
$sel:database:S3CatalogSource' :: S3CatalogSource -> Text
$sel:name:S3CatalogSource' :: S3CatalogSource -> Text
$sel:partitionPredicate:S3CatalogSource' :: S3CatalogSource -> Maybe Text
$sel:additionalOptions:S3CatalogSource' :: S3CatalogSource -> Maybe S3SourceAdditionalOptions
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe S3SourceAdditionalOptions
additionalOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
partitionPredicate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
database
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
table

instance Data.ToJSON S3CatalogSource where
  toJSON :: S3CatalogSource -> Value
toJSON S3CatalogSource' {Maybe Text
Maybe S3SourceAdditionalOptions
Text
table :: Text
database :: Text
name :: Text
partitionPredicate :: Maybe Text
additionalOptions :: Maybe S3SourceAdditionalOptions
$sel:table:S3CatalogSource' :: S3CatalogSource -> Text
$sel:database:S3CatalogSource' :: S3CatalogSource -> Text
$sel:name:S3CatalogSource' :: S3CatalogSource -> Text
$sel:partitionPredicate:S3CatalogSource' :: S3CatalogSource -> Maybe Text
$sel:additionalOptions:S3CatalogSource' :: S3CatalogSource -> Maybe S3SourceAdditionalOptions
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AdditionalOptions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3SourceAdditionalOptions
additionalOptions,
            (Key
"PartitionPredicate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
partitionPredicate,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Database" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
database),
            forall a. a -> Maybe a
Prelude.Just (Key
"Table" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
table)
          ]
      )