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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The database and table in the Glue Data Catalog that is used for input
-- or output data.
--
-- /See:/ 'newGlueTable' smart constructor.
data GlueTable = GlueTable'
  { -- | Additional options for the table. Currently there are two keys
    -- supported:
    --
    -- -   @pushDownPredicate@: to filter on partitions without having to list
    --     and read all the files in your dataset.
    --
    -- -   @catalogPartitionPredicate@: to use server-side partition pruning
    --     using partition indexes in the Glue Data Catalog.
    GlueTable -> Maybe (HashMap Text Text)
additionalOptions :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | A unique identifier for the Glue Data Catalog.
    GlueTable -> Maybe Text
catalogId :: Prelude.Maybe Prelude.Text,
    -- | The name of the connection to the Glue Data Catalog.
    GlueTable -> Maybe Text
connectionName :: Prelude.Maybe Prelude.Text,
    -- | A database name in the Glue Data Catalog.
    GlueTable -> Text
databaseName :: Prelude.Text,
    -- | A table name in the Glue Data Catalog.
    GlueTable -> Text
tableName :: Prelude.Text
  }
  deriving (GlueTable -> GlueTable -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlueTable -> GlueTable -> Bool
$c/= :: GlueTable -> GlueTable -> Bool
== :: GlueTable -> GlueTable -> Bool
$c== :: GlueTable -> GlueTable -> Bool
Prelude.Eq, ReadPrec [GlueTable]
ReadPrec GlueTable
Int -> ReadS GlueTable
ReadS [GlueTable]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GlueTable]
$creadListPrec :: ReadPrec [GlueTable]
readPrec :: ReadPrec GlueTable
$creadPrec :: ReadPrec GlueTable
readList :: ReadS [GlueTable]
$creadList :: ReadS [GlueTable]
readsPrec :: Int -> ReadS GlueTable
$creadsPrec :: Int -> ReadS GlueTable
Prelude.Read, Int -> GlueTable -> ShowS
[GlueTable] -> ShowS
GlueTable -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlueTable] -> ShowS
$cshowList :: [GlueTable] -> ShowS
show :: GlueTable -> String
$cshow :: GlueTable -> String
showsPrec :: Int -> GlueTable -> ShowS
$cshowsPrec :: Int -> GlueTable -> ShowS
Prelude.Show, forall x. Rep GlueTable x -> GlueTable
forall x. GlueTable -> Rep GlueTable x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GlueTable x -> GlueTable
$cfrom :: forall x. GlueTable -> Rep GlueTable x
Prelude.Generic)

-- |
-- Create a value of 'GlueTable' 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', 'glueTable_additionalOptions' - Additional options for the table. Currently there are two keys
-- supported:
--
-- -   @pushDownPredicate@: to filter on partitions without having to list
--     and read all the files in your dataset.
--
-- -   @catalogPartitionPredicate@: to use server-side partition pruning
--     using partition indexes in the Glue Data Catalog.
--
-- 'catalogId', 'glueTable_catalogId' - A unique identifier for the Glue Data Catalog.
--
-- 'connectionName', 'glueTable_connectionName' - The name of the connection to the Glue Data Catalog.
--
-- 'databaseName', 'glueTable_databaseName' - A database name in the Glue Data Catalog.
--
-- 'tableName', 'glueTable_tableName' - A table name in the Glue Data Catalog.
newGlueTable ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  GlueTable
newGlueTable :: Text -> Text -> GlueTable
newGlueTable Text
pDatabaseName_ Text
pTableName_ =
  GlueTable'
    { $sel:additionalOptions:GlueTable' :: Maybe (HashMap Text Text)
additionalOptions = forall a. Maybe a
Prelude.Nothing,
      $sel:catalogId:GlueTable' :: Maybe Text
catalogId = forall a. Maybe a
Prelude.Nothing,
      $sel:connectionName:GlueTable' :: Maybe Text
connectionName = forall a. Maybe a
Prelude.Nothing,
      $sel:databaseName:GlueTable' :: Text
databaseName = Text
pDatabaseName_,
      $sel:tableName:GlueTable' :: Text
tableName = Text
pTableName_
    }

-- | Additional options for the table. Currently there are two keys
-- supported:
--
-- -   @pushDownPredicate@: to filter on partitions without having to list
--     and read all the files in your dataset.
--
-- -   @catalogPartitionPredicate@: to use server-side partition pruning
--     using partition indexes in the Glue Data Catalog.
glueTable_additionalOptions :: Lens.Lens' GlueTable (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
glueTable_additionalOptions :: Lens' GlueTable (Maybe (HashMap Text Text))
glueTable_additionalOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueTable' {Maybe (HashMap Text Text)
additionalOptions :: Maybe (HashMap Text Text)
$sel:additionalOptions:GlueTable' :: GlueTable -> Maybe (HashMap Text Text)
additionalOptions} -> Maybe (HashMap Text Text)
additionalOptions) (\s :: GlueTable
s@GlueTable' {} Maybe (HashMap Text Text)
a -> GlueTable
s {$sel:additionalOptions:GlueTable' :: Maybe (HashMap Text Text)
additionalOptions = Maybe (HashMap Text Text)
a} :: GlueTable) 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 unique identifier for the Glue Data Catalog.
glueTable_catalogId :: Lens.Lens' GlueTable (Prelude.Maybe Prelude.Text)
glueTable_catalogId :: Lens' GlueTable (Maybe Text)
glueTable_catalogId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueTable' {Maybe Text
catalogId :: Maybe Text
$sel:catalogId:GlueTable' :: GlueTable -> Maybe Text
catalogId} -> Maybe Text
catalogId) (\s :: GlueTable
s@GlueTable' {} Maybe Text
a -> GlueTable
s {$sel:catalogId:GlueTable' :: Maybe Text
catalogId = Maybe Text
a} :: GlueTable)

-- | The name of the connection to the Glue Data Catalog.
glueTable_connectionName :: Lens.Lens' GlueTable (Prelude.Maybe Prelude.Text)
glueTable_connectionName :: Lens' GlueTable (Maybe Text)
glueTable_connectionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueTable' {Maybe Text
connectionName :: Maybe Text
$sel:connectionName:GlueTable' :: GlueTable -> Maybe Text
connectionName} -> Maybe Text
connectionName) (\s :: GlueTable
s@GlueTable' {} Maybe Text
a -> GlueTable
s {$sel:connectionName:GlueTable' :: Maybe Text
connectionName = Maybe Text
a} :: GlueTable)

-- | A database name in the Glue Data Catalog.
glueTable_databaseName :: Lens.Lens' GlueTable Prelude.Text
glueTable_databaseName :: Lens' GlueTable Text
glueTable_databaseName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueTable' {Text
databaseName :: Text
$sel:databaseName:GlueTable' :: GlueTable -> Text
databaseName} -> Text
databaseName) (\s :: GlueTable
s@GlueTable' {} Text
a -> GlueTable
s {$sel:databaseName:GlueTable' :: Text
databaseName = Text
a} :: GlueTable)

-- | A table name in the Glue Data Catalog.
glueTable_tableName :: Lens.Lens' GlueTable Prelude.Text
glueTable_tableName :: Lens' GlueTable Text
glueTable_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlueTable' {Text
tableName :: Text
$sel:tableName:GlueTable' :: GlueTable -> Text
tableName} -> Text
tableName) (\s :: GlueTable
s@GlueTable' {} Text
a -> GlueTable
s {$sel:tableName:GlueTable' :: Text
tableName = Text
a} :: GlueTable)

instance Data.FromJSON GlueTable where
  parseJSON :: Value -> Parser GlueTable
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"GlueTable"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe Text -> Maybe Text -> Text -> Text -> GlueTable
GlueTable'
            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 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
"CatalogId")
            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
"ConnectionName")
            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
"DatabaseName")
            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
"TableName")
      )

instance Prelude.Hashable GlueTable where
  hashWithSalt :: Int -> GlueTable -> Int
hashWithSalt Int
_salt GlueTable' {Maybe Text
Maybe (HashMap Text Text)
Text
tableName :: Text
databaseName :: Text
connectionName :: Maybe Text
catalogId :: Maybe Text
additionalOptions :: Maybe (HashMap Text Text)
$sel:tableName:GlueTable' :: GlueTable -> Text
$sel:databaseName:GlueTable' :: GlueTable -> Text
$sel:connectionName:GlueTable' :: GlueTable -> Maybe Text
$sel:catalogId:GlueTable' :: GlueTable -> Maybe Text
$sel:additionalOptions:GlueTable' :: GlueTable -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
additionalOptions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
catalogId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
connectionName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
databaseName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableName

instance Prelude.NFData GlueTable where
  rnf :: GlueTable -> ()
rnf GlueTable' {Maybe Text
Maybe (HashMap Text Text)
Text
tableName :: Text
databaseName :: Text
connectionName :: Maybe Text
catalogId :: Maybe Text
additionalOptions :: Maybe (HashMap Text Text)
$sel:tableName:GlueTable' :: GlueTable -> Text
$sel:databaseName:GlueTable' :: GlueTable -> Text
$sel:connectionName:GlueTable' :: GlueTable -> Maybe Text
$sel:catalogId:GlueTable' :: GlueTable -> Maybe Text
$sel:additionalOptions:GlueTable' :: GlueTable -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
additionalOptions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
catalogId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
connectionName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
databaseName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tableName

instance Data.ToJSON GlueTable where
  toJSON :: GlueTable -> Value
toJSON GlueTable' {Maybe Text
Maybe (HashMap Text Text)
Text
tableName :: Text
databaseName :: Text
connectionName :: Maybe Text
catalogId :: Maybe Text
additionalOptions :: Maybe (HashMap Text Text)
$sel:tableName:GlueTable' :: GlueTable -> Text
$sel:databaseName:GlueTable' :: GlueTable -> Text
$sel:connectionName:GlueTable' :: GlueTable -> Maybe Text
$sel:catalogId:GlueTable' :: GlueTable -> Maybe Text
$sel:additionalOptions:GlueTable' :: GlueTable -> Maybe (HashMap Text Text)
..} =
    [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 (HashMap Text Text)
additionalOptions,
            (Key
"CatalogId" 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
catalogId,
            (Key
"ConnectionName" 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
connectionName,
            forall a. a -> Maybe a
Prelude.Just (Key
"DatabaseName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
databaseName),
            forall a. a -> Maybe a
Prelude.Just (Key
"TableName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tableName)
          ]
      )