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

-- |
-- Create a value of 'DynamoDBCatalogSource' 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', 'dynamoDBCatalogSource_name' - The name of the data source.
--
-- 'database', 'dynamoDBCatalogSource_database' - The name of the database to read from.
--
-- 'table', 'dynamoDBCatalogSource_table' - The name of the table in the database to read from.
newDynamoDBCatalogSource ::
  -- | 'name'
  Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  -- | 'table'
  Prelude.Text ->
  DynamoDBCatalogSource
newDynamoDBCatalogSource :: Text -> Text -> Text -> DynamoDBCatalogSource
newDynamoDBCatalogSource Text
pName_ Text
pDatabase_ Text
pTable_ =
  DynamoDBCatalogSource'
    { $sel:name:DynamoDBCatalogSource' :: Text
name = Text
pName_,
      $sel:database:DynamoDBCatalogSource' :: Text
database = Text
pDatabase_,
      $sel:table:DynamoDBCatalogSource' :: Text
table = Text
pTable_
    }

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

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

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

instance Data.FromJSON DynamoDBCatalogSource where
  parseJSON :: Value -> Parser DynamoDBCatalogSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DynamoDBCatalogSource"
      ( \Object
x ->
          Text -> Text -> Text -> DynamoDBCatalogSource
DynamoDBCatalogSource'
            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 DynamoDBCatalogSource where
  hashWithSalt :: Int -> DynamoDBCatalogSource -> Int
hashWithSalt Int
_salt DynamoDBCatalogSource' {Text
table :: Text
database :: Text
name :: Text
$sel:table:DynamoDBCatalogSource' :: DynamoDBCatalogSource -> Text
$sel:database:DynamoDBCatalogSource' :: DynamoDBCatalogSource -> Text
$sel:name:DynamoDBCatalogSource' :: DynamoDBCatalogSource -> 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 DynamoDBCatalogSource where
  rnf :: DynamoDBCatalogSource -> ()
rnf DynamoDBCatalogSource' {Text
table :: Text
database :: Text
name :: Text
$sel:table:DynamoDBCatalogSource' :: DynamoDBCatalogSource -> Text
$sel:database:DynamoDBCatalogSource' :: DynamoDBCatalogSource -> Text
$sel:name:DynamoDBCatalogSource' :: DynamoDBCatalogSource -> 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 DynamoDBCatalogSource where
  toJSON :: DynamoDBCatalogSource -> Value
toJSON DynamoDBCatalogSource' {Text
table :: Text
database :: Text
name :: Text
$sel:table:DynamoDBCatalogSource' :: DynamoDBCatalogSource -> Text
$sel:database:DynamoDBCatalogSource' :: DynamoDBCatalogSource -> Text
$sel:name:DynamoDBCatalogSource' :: DynamoDBCatalogSource -> 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)
          ]
      )