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

-- | 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
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]
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
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. 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'
    { $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 :: Lens' CatalogEntry Text
catalogEntry_databaseName = 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 :: Lens' CatalogEntry Text
catalogEntry_tableName = 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 where
  hashWithSalt :: Int -> CatalogEntry -> Int
hashWithSalt Int
_salt CatalogEntry' {Text
tableName :: Text
databaseName :: Text
$sel:tableName:CatalogEntry' :: CatalogEntry -> Text
$sel:databaseName:CatalogEntry' :: CatalogEntry -> Text
..} =
    Int
_salt
      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 CatalogEntry where
  rnf :: CatalogEntry -> ()
rnf CatalogEntry' {Text
tableName :: Text
databaseName :: Text
$sel:tableName:CatalogEntry' :: CatalogEntry -> Text
$sel:databaseName:CatalogEntry' :: CatalogEntry -> Text
..} =
    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 CatalogEntry where
  toJSON :: CatalogEntry -> Value
toJSON CatalogEntry' {Text
tableName :: Text
databaseName :: Text
$sel:tableName:CatalogEntry' :: CatalogEntry -> Text
$sel:databaseName:CatalogEntry' :: CatalogEntry -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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)
          ]
      )