{-# 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.RelationalCatalogSource
-- 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.RelationalCatalogSource 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 Relational database data source in the Glue Data Catalog.
--
-- /See:/ 'newRelationalCatalogSource' smart constructor.
data RelationalCatalogSource = RelationalCatalogSource'
  { -- | The name of the data source.
    RelationalCatalogSource -> Text
name :: Prelude.Text,
    -- | The name of the database to read from.
    RelationalCatalogSource -> Text
database :: Prelude.Text,
    -- | The name of the table in the database to read from.
    RelationalCatalogSource -> Text
table :: Prelude.Text
  }
  deriving (RelationalCatalogSource -> RelationalCatalogSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RelationalCatalogSource -> RelationalCatalogSource -> Bool
$c/= :: RelationalCatalogSource -> RelationalCatalogSource -> Bool
== :: RelationalCatalogSource -> RelationalCatalogSource -> Bool
$c== :: RelationalCatalogSource -> RelationalCatalogSource -> Bool
Prelude.Eq, ReadPrec [RelationalCatalogSource]
ReadPrec RelationalCatalogSource
Int -> ReadS RelationalCatalogSource
ReadS [RelationalCatalogSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RelationalCatalogSource]
$creadListPrec :: ReadPrec [RelationalCatalogSource]
readPrec :: ReadPrec RelationalCatalogSource
$creadPrec :: ReadPrec RelationalCatalogSource
readList :: ReadS [RelationalCatalogSource]
$creadList :: ReadS [RelationalCatalogSource]
readsPrec :: Int -> ReadS RelationalCatalogSource
$creadsPrec :: Int -> ReadS RelationalCatalogSource
Prelude.Read, Int -> RelationalCatalogSource -> ShowS
[RelationalCatalogSource] -> ShowS
RelationalCatalogSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RelationalCatalogSource] -> ShowS
$cshowList :: [RelationalCatalogSource] -> ShowS
show :: RelationalCatalogSource -> String
$cshow :: RelationalCatalogSource -> String
showsPrec :: Int -> RelationalCatalogSource -> ShowS
$cshowsPrec :: Int -> RelationalCatalogSource -> ShowS
Prelude.Show, forall x. Rep RelationalCatalogSource x -> RelationalCatalogSource
forall x. RelationalCatalogSource -> Rep RelationalCatalogSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RelationalCatalogSource x -> RelationalCatalogSource
$cfrom :: forall x. RelationalCatalogSource -> Rep RelationalCatalogSource x
Prelude.Generic)

-- |
-- Create a value of 'RelationalCatalogSource' 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:
--
-- 'name', 'relationalCatalogSource_name' - The name of the data source.
--
-- 'database', 'relationalCatalogSource_database' - The name of the database to read from.
--
-- 'table', 'relationalCatalogSource_table' - The name of the table in the database to read from.
newRelationalCatalogSource ::
  -- | 'name'
  Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  -- | 'table'
  Prelude.Text ->
  RelationalCatalogSource
newRelationalCatalogSource :: Text -> Text -> Text -> RelationalCatalogSource
newRelationalCatalogSource Text
pName_ Text
pDatabase_ Text
pTable_ =
  RelationalCatalogSource'
    { $sel:name:RelationalCatalogSource' :: Text
name = Text
pName_,
      $sel:database:RelationalCatalogSource' :: Text
database = Text
pDatabase_,
      $sel:table:RelationalCatalogSource' :: Text
table = Text
pTable_
    }

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

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

-- | The name of the table in the database to read from.
relationalCatalogSource_table :: Lens.Lens' RelationalCatalogSource Prelude.Text
relationalCatalogSource_table :: Lens' RelationalCatalogSource Text
relationalCatalogSource_table = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RelationalCatalogSource' {Text
table :: Text
$sel:table:RelationalCatalogSource' :: RelationalCatalogSource -> Text
table} -> Text
table) (\s :: RelationalCatalogSource
s@RelationalCatalogSource' {} Text
a -> RelationalCatalogSource
s {$sel:table:RelationalCatalogSource' :: Text
table = Text
a} :: RelationalCatalogSource)

instance Data.FromJSON RelationalCatalogSource where
  parseJSON :: Value -> Parser RelationalCatalogSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RelationalCatalogSource"
      ( \Object
x ->
          Text -> Text -> Text -> RelationalCatalogSource
RelationalCatalogSource'
            forall (f :: * -> *) a b. Functor 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 RelationalCatalogSource where
  hashWithSalt :: Int -> RelationalCatalogSource -> Int
hashWithSalt Int
_salt RelationalCatalogSource' {Text
table :: Text
database :: Text
name :: Text
$sel:table:RelationalCatalogSource' :: RelationalCatalogSource -> Text
$sel:database:RelationalCatalogSource' :: RelationalCatalogSource -> Text
$sel:name:RelationalCatalogSource' :: RelationalCatalogSource -> Text
..} =
    Int
_salt
      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 RelationalCatalogSource where
  rnf :: RelationalCatalogSource -> ()
rnf RelationalCatalogSource' {Text
table :: Text
database :: Text
name :: Text
$sel:table:RelationalCatalogSource' :: RelationalCatalogSource -> Text
$sel:database:RelationalCatalogSource' :: RelationalCatalogSource -> Text
$sel:name:RelationalCatalogSource' :: RelationalCatalogSource -> Text
..} =
    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 RelationalCatalogSource where
  toJSON :: RelationalCatalogSource -> Value
toJSON RelationalCatalogSource' {Text
table :: Text
database :: Text
name :: Text
$sel:table:RelationalCatalogSource' :: RelationalCatalogSource -> Text
$sel:database:RelationalCatalogSource' :: RelationalCatalogSource -> Text
$sel:name:RelationalCatalogSource' :: RelationalCatalogSource -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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)
          ]
      )