{-# 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.DataBrew.Types.DatabaseInputDefinition
-- 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.DataBrew.Types.DatabaseInputDefinition where

import qualified Amazonka.Core as Core
import Amazonka.DataBrew.Types.S3Location
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Connection information for dataset input files stored in a database.
--
-- /See:/ 'newDatabaseInputDefinition' smart constructor.
data DatabaseInputDefinition = DatabaseInputDefinition'
  { DatabaseInputDefinition -> Maybe S3Location
tempDirectory :: Prelude.Maybe S3Location,
    -- | The Glue Connection that stores the connection information for the
    -- target database.
    DatabaseInputDefinition -> Text
glueConnectionName :: Prelude.Text,
    -- | The table within the target database.
    DatabaseInputDefinition -> Text
databaseTableName :: Prelude.Text
  }
  deriving (DatabaseInputDefinition -> DatabaseInputDefinition -> Bool
(DatabaseInputDefinition -> DatabaseInputDefinition -> Bool)
-> (DatabaseInputDefinition -> DatabaseInputDefinition -> Bool)
-> Eq DatabaseInputDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatabaseInputDefinition -> DatabaseInputDefinition -> Bool
$c/= :: DatabaseInputDefinition -> DatabaseInputDefinition -> Bool
== :: DatabaseInputDefinition -> DatabaseInputDefinition -> Bool
$c== :: DatabaseInputDefinition -> DatabaseInputDefinition -> Bool
Prelude.Eq, ReadPrec [DatabaseInputDefinition]
ReadPrec DatabaseInputDefinition
Int -> ReadS DatabaseInputDefinition
ReadS [DatabaseInputDefinition]
(Int -> ReadS DatabaseInputDefinition)
-> ReadS [DatabaseInputDefinition]
-> ReadPrec DatabaseInputDefinition
-> ReadPrec [DatabaseInputDefinition]
-> Read DatabaseInputDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatabaseInputDefinition]
$creadListPrec :: ReadPrec [DatabaseInputDefinition]
readPrec :: ReadPrec DatabaseInputDefinition
$creadPrec :: ReadPrec DatabaseInputDefinition
readList :: ReadS [DatabaseInputDefinition]
$creadList :: ReadS [DatabaseInputDefinition]
readsPrec :: Int -> ReadS DatabaseInputDefinition
$creadsPrec :: Int -> ReadS DatabaseInputDefinition
Prelude.Read, Int -> DatabaseInputDefinition -> ShowS
[DatabaseInputDefinition] -> ShowS
DatabaseInputDefinition -> String
(Int -> DatabaseInputDefinition -> ShowS)
-> (DatabaseInputDefinition -> String)
-> ([DatabaseInputDefinition] -> ShowS)
-> Show DatabaseInputDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatabaseInputDefinition] -> ShowS
$cshowList :: [DatabaseInputDefinition] -> ShowS
show :: DatabaseInputDefinition -> String
$cshow :: DatabaseInputDefinition -> String
showsPrec :: Int -> DatabaseInputDefinition -> ShowS
$cshowsPrec :: Int -> DatabaseInputDefinition -> ShowS
Prelude.Show, (forall x.
 DatabaseInputDefinition -> Rep DatabaseInputDefinition x)
-> (forall x.
    Rep DatabaseInputDefinition x -> DatabaseInputDefinition)
-> Generic DatabaseInputDefinition
forall x. Rep DatabaseInputDefinition x -> DatabaseInputDefinition
forall x. DatabaseInputDefinition -> Rep DatabaseInputDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DatabaseInputDefinition x -> DatabaseInputDefinition
$cfrom :: forall x. DatabaseInputDefinition -> Rep DatabaseInputDefinition x
Prelude.Generic)

-- |
-- Create a value of 'DatabaseInputDefinition' 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:
--
-- 'tempDirectory', 'databaseInputDefinition_tempDirectory' - Undocumented member.
--
-- 'glueConnectionName', 'databaseInputDefinition_glueConnectionName' - The Glue Connection that stores the connection information for the
-- target database.
--
-- 'databaseTableName', 'databaseInputDefinition_databaseTableName' - The table within the target database.
newDatabaseInputDefinition ::
  -- | 'glueConnectionName'
  Prelude.Text ->
  -- | 'databaseTableName'
  Prelude.Text ->
  DatabaseInputDefinition
newDatabaseInputDefinition :: Text -> Text -> DatabaseInputDefinition
newDatabaseInputDefinition
  Text
pGlueConnectionName_
  Text
pDatabaseTableName_ =
    DatabaseInputDefinition' :: Maybe S3Location -> Text -> Text -> DatabaseInputDefinition
DatabaseInputDefinition'
      { $sel:tempDirectory:DatabaseInputDefinition' :: Maybe S3Location
tempDirectory =
          Maybe S3Location
forall a. Maybe a
Prelude.Nothing,
        $sel:glueConnectionName:DatabaseInputDefinition' :: Text
glueConnectionName = Text
pGlueConnectionName_,
        $sel:databaseTableName:DatabaseInputDefinition' :: Text
databaseTableName = Text
pDatabaseTableName_
      }

-- | Undocumented member.
databaseInputDefinition_tempDirectory :: Lens.Lens' DatabaseInputDefinition (Prelude.Maybe S3Location)
databaseInputDefinition_tempDirectory :: (Maybe S3Location -> f (Maybe S3Location))
-> DatabaseInputDefinition -> f DatabaseInputDefinition
databaseInputDefinition_tempDirectory = (DatabaseInputDefinition -> Maybe S3Location)
-> (DatabaseInputDefinition
    -> Maybe S3Location -> DatabaseInputDefinition)
-> Lens
     DatabaseInputDefinition
     DatabaseInputDefinition
     (Maybe S3Location)
     (Maybe S3Location)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatabaseInputDefinition' {Maybe S3Location
tempDirectory :: Maybe S3Location
$sel:tempDirectory:DatabaseInputDefinition' :: DatabaseInputDefinition -> Maybe S3Location
tempDirectory} -> Maybe S3Location
tempDirectory) (\s :: DatabaseInputDefinition
s@DatabaseInputDefinition' {} Maybe S3Location
a -> DatabaseInputDefinition
s {$sel:tempDirectory:DatabaseInputDefinition' :: Maybe S3Location
tempDirectory = Maybe S3Location
a} :: DatabaseInputDefinition)

-- | The Glue Connection that stores the connection information for the
-- target database.
databaseInputDefinition_glueConnectionName :: Lens.Lens' DatabaseInputDefinition Prelude.Text
databaseInputDefinition_glueConnectionName :: (Text -> f Text)
-> DatabaseInputDefinition -> f DatabaseInputDefinition
databaseInputDefinition_glueConnectionName = (DatabaseInputDefinition -> Text)
-> (DatabaseInputDefinition -> Text -> DatabaseInputDefinition)
-> Lens DatabaseInputDefinition DatabaseInputDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatabaseInputDefinition' {Text
glueConnectionName :: Text
$sel:glueConnectionName:DatabaseInputDefinition' :: DatabaseInputDefinition -> Text
glueConnectionName} -> Text
glueConnectionName) (\s :: DatabaseInputDefinition
s@DatabaseInputDefinition' {} Text
a -> DatabaseInputDefinition
s {$sel:glueConnectionName:DatabaseInputDefinition' :: Text
glueConnectionName = Text
a} :: DatabaseInputDefinition)

-- | The table within the target database.
databaseInputDefinition_databaseTableName :: Lens.Lens' DatabaseInputDefinition Prelude.Text
databaseInputDefinition_databaseTableName :: (Text -> f Text)
-> DatabaseInputDefinition -> f DatabaseInputDefinition
databaseInputDefinition_databaseTableName = (DatabaseInputDefinition -> Text)
-> (DatabaseInputDefinition -> Text -> DatabaseInputDefinition)
-> Lens DatabaseInputDefinition DatabaseInputDefinition Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatabaseInputDefinition' {Text
databaseTableName :: Text
$sel:databaseTableName:DatabaseInputDefinition' :: DatabaseInputDefinition -> Text
databaseTableName} -> Text
databaseTableName) (\s :: DatabaseInputDefinition
s@DatabaseInputDefinition' {} Text
a -> DatabaseInputDefinition
s {$sel:databaseTableName:DatabaseInputDefinition' :: Text
databaseTableName = Text
a} :: DatabaseInputDefinition)

instance Core.FromJSON DatabaseInputDefinition where
  parseJSON :: Value -> Parser DatabaseInputDefinition
parseJSON =
    String
-> (Object -> Parser DatabaseInputDefinition)
-> Value
-> Parser DatabaseInputDefinition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DatabaseInputDefinition"
      ( \Object
x ->
          Maybe S3Location -> Text -> Text -> DatabaseInputDefinition
DatabaseInputDefinition'
            (Maybe S3Location -> Text -> Text -> DatabaseInputDefinition)
-> Parser (Maybe S3Location)
-> Parser (Text -> Text -> DatabaseInputDefinition)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe S3Location)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TempDirectory")
            Parser (Text -> Text -> DatabaseInputDefinition)
-> Parser Text -> Parser (Text -> DatabaseInputDefinition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"GlueConnectionName")
            Parser (Text -> DatabaseInputDefinition)
-> Parser Text -> Parser DatabaseInputDefinition
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DatabaseTableName")
      )

instance Prelude.Hashable DatabaseInputDefinition

instance Prelude.NFData DatabaseInputDefinition

instance Core.ToJSON DatabaseInputDefinition where
  toJSON :: DatabaseInputDefinition -> Value
toJSON DatabaseInputDefinition' {Maybe S3Location
Text
databaseTableName :: Text
glueConnectionName :: Text
tempDirectory :: Maybe S3Location
$sel:databaseTableName:DatabaseInputDefinition' :: DatabaseInputDefinition -> Text
$sel:glueConnectionName:DatabaseInputDefinition' :: DatabaseInputDefinition -> Text
$sel:tempDirectory:DatabaseInputDefinition' :: DatabaseInputDefinition -> Maybe S3Location
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TempDirectory" Text -> S3Location -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3Location -> Pair) -> Maybe S3Location -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3Location
tempDirectory,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"GlueConnectionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
glueConnectionName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"DatabaseTableName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
databaseTableName)
          ]
      )