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

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

-- | Represents options that specify how and where DataBrew writes the
-- database output generated by recipe jobs.
--
-- /See:/ 'newDatabaseTableOutputOptions' smart constructor.
data DatabaseTableOutputOptions = DatabaseTableOutputOptions'
  { -- | Represents an Amazon S3 location (bucket name and object key) where
    -- DataBrew can store intermediate results.
    DatabaseTableOutputOptions -> Maybe S3Location
tempDirectory :: Prelude.Maybe S3Location,
    -- | A prefix for the name of a table DataBrew will create in the database.
    DatabaseTableOutputOptions -> Text
tableName :: Prelude.Text
  }
  deriving (DatabaseTableOutputOptions -> DatabaseTableOutputOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatabaseTableOutputOptions -> DatabaseTableOutputOptions -> Bool
$c/= :: DatabaseTableOutputOptions -> DatabaseTableOutputOptions -> Bool
== :: DatabaseTableOutputOptions -> DatabaseTableOutputOptions -> Bool
$c== :: DatabaseTableOutputOptions -> DatabaseTableOutputOptions -> Bool
Prelude.Eq, ReadPrec [DatabaseTableOutputOptions]
ReadPrec DatabaseTableOutputOptions
Int -> ReadS DatabaseTableOutputOptions
ReadS [DatabaseTableOutputOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DatabaseTableOutputOptions]
$creadListPrec :: ReadPrec [DatabaseTableOutputOptions]
readPrec :: ReadPrec DatabaseTableOutputOptions
$creadPrec :: ReadPrec DatabaseTableOutputOptions
readList :: ReadS [DatabaseTableOutputOptions]
$creadList :: ReadS [DatabaseTableOutputOptions]
readsPrec :: Int -> ReadS DatabaseTableOutputOptions
$creadsPrec :: Int -> ReadS DatabaseTableOutputOptions
Prelude.Read, Int -> DatabaseTableOutputOptions -> ShowS
[DatabaseTableOutputOptions] -> ShowS
DatabaseTableOutputOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatabaseTableOutputOptions] -> ShowS
$cshowList :: [DatabaseTableOutputOptions] -> ShowS
show :: DatabaseTableOutputOptions -> String
$cshow :: DatabaseTableOutputOptions -> String
showsPrec :: Int -> DatabaseTableOutputOptions -> ShowS
$cshowsPrec :: Int -> DatabaseTableOutputOptions -> ShowS
Prelude.Show, forall x.
Rep DatabaseTableOutputOptions x -> DatabaseTableOutputOptions
forall x.
DatabaseTableOutputOptions -> Rep DatabaseTableOutputOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DatabaseTableOutputOptions x -> DatabaseTableOutputOptions
$cfrom :: forall x.
DatabaseTableOutputOptions -> Rep DatabaseTableOutputOptions x
Prelude.Generic)

-- |
-- Create a value of 'DatabaseTableOutputOptions' 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', 'databaseTableOutputOptions_tempDirectory' - Represents an Amazon S3 location (bucket name and object key) where
-- DataBrew can store intermediate results.
--
-- 'tableName', 'databaseTableOutputOptions_tableName' - A prefix for the name of a table DataBrew will create in the database.
newDatabaseTableOutputOptions ::
  -- | 'tableName'
  Prelude.Text ->
  DatabaseTableOutputOptions
newDatabaseTableOutputOptions :: Text -> DatabaseTableOutputOptions
newDatabaseTableOutputOptions Text
pTableName_ =
  DatabaseTableOutputOptions'
    { $sel:tempDirectory:DatabaseTableOutputOptions' :: Maybe S3Location
tempDirectory =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tableName:DatabaseTableOutputOptions' :: Text
tableName = Text
pTableName_
    }

-- | Represents an Amazon S3 location (bucket name and object key) where
-- DataBrew can store intermediate results.
databaseTableOutputOptions_tempDirectory :: Lens.Lens' DatabaseTableOutputOptions (Prelude.Maybe S3Location)
databaseTableOutputOptions_tempDirectory :: Lens' DatabaseTableOutputOptions (Maybe S3Location)
databaseTableOutputOptions_tempDirectory = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatabaseTableOutputOptions' {Maybe S3Location
tempDirectory :: Maybe S3Location
$sel:tempDirectory:DatabaseTableOutputOptions' :: DatabaseTableOutputOptions -> Maybe S3Location
tempDirectory} -> Maybe S3Location
tempDirectory) (\s :: DatabaseTableOutputOptions
s@DatabaseTableOutputOptions' {} Maybe S3Location
a -> DatabaseTableOutputOptions
s {$sel:tempDirectory:DatabaseTableOutputOptions' :: Maybe S3Location
tempDirectory = Maybe S3Location
a} :: DatabaseTableOutputOptions)

-- | A prefix for the name of a table DataBrew will create in the database.
databaseTableOutputOptions_tableName :: Lens.Lens' DatabaseTableOutputOptions Prelude.Text
databaseTableOutputOptions_tableName :: Lens' DatabaseTableOutputOptions Text
databaseTableOutputOptions_tableName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DatabaseTableOutputOptions' {Text
tableName :: Text
$sel:tableName:DatabaseTableOutputOptions' :: DatabaseTableOutputOptions -> Text
tableName} -> Text
tableName) (\s :: DatabaseTableOutputOptions
s@DatabaseTableOutputOptions' {} Text
a -> DatabaseTableOutputOptions
s {$sel:tableName:DatabaseTableOutputOptions' :: Text
tableName = Text
a} :: DatabaseTableOutputOptions)

instance Data.FromJSON DatabaseTableOutputOptions where
  parseJSON :: Value -> Parser DatabaseTableOutputOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DatabaseTableOutputOptions"
      ( \Object
x ->
          Maybe S3Location -> Text -> DatabaseTableOutputOptions
DatabaseTableOutputOptions'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TempDirectory")
            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
"TableName")
      )

instance Prelude.Hashable DatabaseTableOutputOptions where
  hashWithSalt :: Int -> DatabaseTableOutputOptions -> Int
hashWithSalt Int
_salt DatabaseTableOutputOptions' {Maybe S3Location
Text
tableName :: Text
tempDirectory :: Maybe S3Location
$sel:tableName:DatabaseTableOutputOptions' :: DatabaseTableOutputOptions -> Text
$sel:tempDirectory:DatabaseTableOutputOptions' :: DatabaseTableOutputOptions -> Maybe S3Location
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3Location
tempDirectory
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tableName

instance Prelude.NFData DatabaseTableOutputOptions where
  rnf :: DatabaseTableOutputOptions -> ()
rnf DatabaseTableOutputOptions' {Maybe S3Location
Text
tableName :: Text
tempDirectory :: Maybe S3Location
$sel:tableName:DatabaseTableOutputOptions' :: DatabaseTableOutputOptions -> Text
$sel:tempDirectory:DatabaseTableOutputOptions' :: DatabaseTableOutputOptions -> Maybe S3Location
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe S3Location
tempDirectory
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tableName

instance Data.ToJSON DatabaseTableOutputOptions where
  toJSON :: DatabaseTableOutputOptions -> Value
toJSON DatabaseTableOutputOptions' {Maybe S3Location
Text
tableName :: Text
tempDirectory :: Maybe S3Location
$sel:tableName:DatabaseTableOutputOptions' :: DatabaseTableOutputOptions -> Text
$sel:tempDirectory:DatabaseTableOutputOptions' :: DatabaseTableOutputOptions -> Maybe S3Location
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"TempDirectory" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3Location
tempDirectory,
            forall a. a -> Maybe a
Prelude.Just (Key
"TableName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tableName)
          ]
      )