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

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

-- | Specifies a table definition in the Glue Data Catalog.
--
-- /See:/ 'newCatalogEntry' smart constructor.
data CatalogEntry = CatalogEntry'
  { -- | The database in which the table metadata resides.
    CatalogEntry -> Text
databaseName :: Prelude.Text,
    -- | The name of the table in question.
    CatalogEntry -> Text
tableName :: Prelude.Text
  }
  deriving (CatalogEntry -> CatalogEntry -> Bool
(CatalogEntry -> CatalogEntry -> Bool)
-> (CatalogEntry -> CatalogEntry -> Bool) -> Eq CatalogEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CatalogEntry -> CatalogEntry -> Bool
$c/= :: CatalogEntry -> CatalogEntry -> Bool
== :: CatalogEntry -> CatalogEntry -> Bool
$c== :: CatalogEntry -> CatalogEntry -> Bool
Prelude.Eq, ReadPrec [CatalogEntry]
ReadPrec CatalogEntry
Int -> ReadS CatalogEntry
ReadS [CatalogEntry]
(Int -> ReadS CatalogEntry)
-> ReadS [CatalogEntry]
-> ReadPrec CatalogEntry
-> ReadPrec [CatalogEntry]
-> Read CatalogEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CatalogEntry]
$creadListPrec :: ReadPrec [CatalogEntry]
readPrec :: ReadPrec CatalogEntry
$creadPrec :: ReadPrec CatalogEntry
readList :: ReadS [CatalogEntry]
$creadList :: ReadS [CatalogEntry]
readsPrec :: Int -> ReadS CatalogEntry
$creadsPrec :: Int -> ReadS CatalogEntry
Prelude.Read, Int -> CatalogEntry -> ShowS
[CatalogEntry] -> ShowS
CatalogEntry -> String
(Int -> CatalogEntry -> ShowS)
-> (CatalogEntry -> String)
-> ([CatalogEntry] -> ShowS)
-> Show CatalogEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CatalogEntry] -> ShowS
$cshowList :: [CatalogEntry] -> ShowS
show :: CatalogEntry -> String
$cshow :: CatalogEntry -> String
showsPrec :: Int -> CatalogEntry -> ShowS
$cshowsPrec :: Int -> CatalogEntry -> ShowS
Prelude.Show, (forall x. CatalogEntry -> Rep CatalogEntry x)
-> (forall x. Rep CatalogEntry x -> CatalogEntry)
-> Generic CatalogEntry
forall x. Rep CatalogEntry x -> CatalogEntry
forall x. CatalogEntry -> Rep CatalogEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CatalogEntry x -> CatalogEntry
$cfrom :: forall x. CatalogEntry -> Rep CatalogEntry x
Prelude.Generic)

-- |
-- Create a value of 'CatalogEntry' 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:
--
-- 'databaseName', 'catalogEntry_databaseName' - The database in which the table metadata resides.
--
-- 'tableName', 'catalogEntry_tableName' - The name of the table in question.
newCatalogEntry ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'tableName'
  Prelude.Text ->
  CatalogEntry
newCatalogEntry :: Text -> Text -> CatalogEntry
newCatalogEntry Text
pDatabaseName_ Text
pTableName_ =
  CatalogEntry' :: Text -> Text -> CatalogEntry
CatalogEntry'
    { $sel:databaseName:CatalogEntry' :: Text
databaseName = Text
pDatabaseName_,
      $sel:tableName:CatalogEntry' :: Text
tableName = Text
pTableName_
    }

-- | The database in which the table metadata resides.
catalogEntry_databaseName :: Lens.Lens' CatalogEntry Prelude.Text
catalogEntry_databaseName :: (Text -> f Text) -> CatalogEntry -> f CatalogEntry
catalogEntry_databaseName = (CatalogEntry -> Text)
-> (CatalogEntry -> Text -> CatalogEntry)
-> Lens CatalogEntry CatalogEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogEntry' {Text
databaseName :: Text
$sel:databaseName:CatalogEntry' :: CatalogEntry -> Text
databaseName} -> Text
databaseName) (\s :: CatalogEntry
s@CatalogEntry' {} Text
a -> CatalogEntry
s {$sel:databaseName:CatalogEntry' :: Text
databaseName = Text
a} :: CatalogEntry)

-- | The name of the table in question.
catalogEntry_tableName :: Lens.Lens' CatalogEntry Prelude.Text
catalogEntry_tableName :: (Text -> f Text) -> CatalogEntry -> f CatalogEntry
catalogEntry_tableName = (CatalogEntry -> Text)
-> (CatalogEntry -> Text -> CatalogEntry)
-> Lens CatalogEntry CatalogEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CatalogEntry' {Text
tableName :: Text
$sel:tableName:CatalogEntry' :: CatalogEntry -> Text
tableName} -> Text
tableName) (\s :: CatalogEntry
s@CatalogEntry' {} Text
a -> CatalogEntry
s {$sel:tableName:CatalogEntry' :: Text
tableName = Text
a} :: CatalogEntry)

instance Prelude.Hashable CatalogEntry

instance Prelude.NFData CatalogEntry

instance Core.ToJSON CatalogEntry where
  toJSON :: CatalogEntry -> Value
toJSON CatalogEntry' {Text
tableName :: Text
databaseName :: Text
$sel:tableName:CatalogEntry' :: CatalogEntry -> Text
$sel:databaseName:CatalogEntry' :: CatalogEntry -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DatabaseName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
databaseName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tableName)
          ]
      )