{-# 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.RedshiftSource
-- 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.RedshiftSource 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 an Amazon Redshift data store.
--
-- /See:/ 'newRedshiftSource' smart constructor.
data RedshiftSource = RedshiftSource'
  { -- | The Amazon S3 path where temporary data can be staged when copying out
    -- of the database.
    RedshiftSource -> Maybe Text
redshiftTmpDir :: Prelude.Maybe Prelude.Text,
    -- | The IAM role with permissions.
    RedshiftSource -> Maybe Text
tmpDirIAMRole :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon Redshift data store.
    RedshiftSource -> Text
name :: Prelude.Text,
    -- | The database to read from.
    RedshiftSource -> Text
database :: Prelude.Text,
    -- | The database table to read from.
    RedshiftSource -> Text
table :: Prelude.Text
  }
  deriving (RedshiftSource -> RedshiftSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RedshiftSource -> RedshiftSource -> Bool
$c/= :: RedshiftSource -> RedshiftSource -> Bool
== :: RedshiftSource -> RedshiftSource -> Bool
$c== :: RedshiftSource -> RedshiftSource -> Bool
Prelude.Eq, ReadPrec [RedshiftSource]
ReadPrec RedshiftSource
Int -> ReadS RedshiftSource
ReadS [RedshiftSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RedshiftSource]
$creadListPrec :: ReadPrec [RedshiftSource]
readPrec :: ReadPrec RedshiftSource
$creadPrec :: ReadPrec RedshiftSource
readList :: ReadS [RedshiftSource]
$creadList :: ReadS [RedshiftSource]
readsPrec :: Int -> ReadS RedshiftSource
$creadsPrec :: Int -> ReadS RedshiftSource
Prelude.Read, Int -> RedshiftSource -> ShowS
[RedshiftSource] -> ShowS
RedshiftSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RedshiftSource] -> ShowS
$cshowList :: [RedshiftSource] -> ShowS
show :: RedshiftSource -> String
$cshow :: RedshiftSource -> String
showsPrec :: Int -> RedshiftSource -> ShowS
$cshowsPrec :: Int -> RedshiftSource -> ShowS
Prelude.Show, forall x. Rep RedshiftSource x -> RedshiftSource
forall x. RedshiftSource -> Rep RedshiftSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RedshiftSource x -> RedshiftSource
$cfrom :: forall x. RedshiftSource -> Rep RedshiftSource x
Prelude.Generic)

-- |
-- Create a value of 'RedshiftSource' 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:
--
-- 'redshiftTmpDir', 'redshiftSource_redshiftTmpDir' - The Amazon S3 path where temporary data can be staged when copying out
-- of the database.
--
-- 'tmpDirIAMRole', 'redshiftSource_tmpDirIAMRole' - The IAM role with permissions.
--
-- 'name', 'redshiftSource_name' - The name of the Amazon Redshift data store.
--
-- 'database', 'redshiftSource_database' - The database to read from.
--
-- 'table', 'redshiftSource_table' - The database table to read from.
newRedshiftSource ::
  -- | 'name'
  Prelude.Text ->
  -- | 'database'
  Prelude.Text ->
  -- | 'table'
  Prelude.Text ->
  RedshiftSource
newRedshiftSource :: Text -> Text -> Text -> RedshiftSource
newRedshiftSource Text
pName_ Text
pDatabase_ Text
pTable_ =
  RedshiftSource'
    { $sel:redshiftTmpDir:RedshiftSource' :: Maybe Text
redshiftTmpDir = forall a. Maybe a
Prelude.Nothing,
      $sel:tmpDirIAMRole:RedshiftSource' :: Maybe Text
tmpDirIAMRole = forall a. Maybe a
Prelude.Nothing,
      $sel:name:RedshiftSource' :: Text
name = Text
pName_,
      $sel:database:RedshiftSource' :: Text
database = Text
pDatabase_,
      $sel:table:RedshiftSource' :: Text
table = Text
pTable_
    }

-- | The Amazon S3 path where temporary data can be staged when copying out
-- of the database.
redshiftSource_redshiftTmpDir :: Lens.Lens' RedshiftSource (Prelude.Maybe Prelude.Text)
redshiftSource_redshiftTmpDir :: Lens' RedshiftSource (Maybe Text)
redshiftSource_redshiftTmpDir = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftSource' {Maybe Text
redshiftTmpDir :: Maybe Text
$sel:redshiftTmpDir:RedshiftSource' :: RedshiftSource -> Maybe Text
redshiftTmpDir} -> Maybe Text
redshiftTmpDir) (\s :: RedshiftSource
s@RedshiftSource' {} Maybe Text
a -> RedshiftSource
s {$sel:redshiftTmpDir:RedshiftSource' :: Maybe Text
redshiftTmpDir = Maybe Text
a} :: RedshiftSource)

-- | The IAM role with permissions.
redshiftSource_tmpDirIAMRole :: Lens.Lens' RedshiftSource (Prelude.Maybe Prelude.Text)
redshiftSource_tmpDirIAMRole :: Lens' RedshiftSource (Maybe Text)
redshiftSource_tmpDirIAMRole = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftSource' {Maybe Text
tmpDirIAMRole :: Maybe Text
$sel:tmpDirIAMRole:RedshiftSource' :: RedshiftSource -> Maybe Text
tmpDirIAMRole} -> Maybe Text
tmpDirIAMRole) (\s :: RedshiftSource
s@RedshiftSource' {} Maybe Text
a -> RedshiftSource
s {$sel:tmpDirIAMRole:RedshiftSource' :: Maybe Text
tmpDirIAMRole = Maybe Text
a} :: RedshiftSource)

-- | The name of the Amazon Redshift data store.
redshiftSource_name :: Lens.Lens' RedshiftSource Prelude.Text
redshiftSource_name :: Lens' RedshiftSource Text
redshiftSource_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftSource' {Text
name :: Text
$sel:name:RedshiftSource' :: RedshiftSource -> Text
name} -> Text
name) (\s :: RedshiftSource
s@RedshiftSource' {} Text
a -> RedshiftSource
s {$sel:name:RedshiftSource' :: Text
name = Text
a} :: RedshiftSource)

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

-- | The database table to read from.
redshiftSource_table :: Lens.Lens' RedshiftSource Prelude.Text
redshiftSource_table :: Lens' RedshiftSource Text
redshiftSource_table = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftSource' {Text
table :: Text
$sel:table:RedshiftSource' :: RedshiftSource -> Text
table} -> Text
table) (\s :: RedshiftSource
s@RedshiftSource' {} Text
a -> RedshiftSource
s {$sel:table:RedshiftSource' :: Text
table = Text
a} :: RedshiftSource)

instance Data.FromJSON RedshiftSource where
  parseJSON :: Value -> Parser RedshiftSource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RedshiftSource"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Text -> Text -> Text -> RedshiftSource
RedshiftSource'
            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
"RedshiftTmpDir")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TmpDirIAMRole")
            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
"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 RedshiftSource where
  hashWithSalt :: Int -> RedshiftSource -> Int
hashWithSalt Int
_salt RedshiftSource' {Maybe Text
Text
table :: Text
database :: Text
name :: Text
tmpDirIAMRole :: Maybe Text
redshiftTmpDir :: Maybe Text
$sel:table:RedshiftSource' :: RedshiftSource -> Text
$sel:database:RedshiftSource' :: RedshiftSource -> Text
$sel:name:RedshiftSource' :: RedshiftSource -> Text
$sel:tmpDirIAMRole:RedshiftSource' :: RedshiftSource -> Maybe Text
$sel:redshiftTmpDir:RedshiftSource' :: RedshiftSource -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
redshiftTmpDir
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
tmpDirIAMRole
      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 RedshiftSource where
  rnf :: RedshiftSource -> ()
rnf RedshiftSource' {Maybe Text
Text
table :: Text
database :: Text
name :: Text
tmpDirIAMRole :: Maybe Text
redshiftTmpDir :: Maybe Text
$sel:table:RedshiftSource' :: RedshiftSource -> Text
$sel:database:RedshiftSource' :: RedshiftSource -> Text
$sel:name:RedshiftSource' :: RedshiftSource -> Text
$sel:tmpDirIAMRole:RedshiftSource' :: RedshiftSource -> Maybe Text
$sel:redshiftTmpDir:RedshiftSource' :: RedshiftSource -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
redshiftTmpDir
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tmpDirIAMRole
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 RedshiftSource where
  toJSON :: RedshiftSource -> Value
toJSON RedshiftSource' {Maybe Text
Text
table :: Text
database :: Text
name :: Text
tmpDirIAMRole :: Maybe Text
redshiftTmpDir :: Maybe Text
$sel:table:RedshiftSource' :: RedshiftSource -> Text
$sel:database:RedshiftSource' :: RedshiftSource -> Text
$sel:name:RedshiftSource' :: RedshiftSource -> Text
$sel:tmpDirIAMRole:RedshiftSource' :: RedshiftSource -> Maybe Text
$sel:redshiftTmpDir:RedshiftSource' :: RedshiftSource -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"RedshiftTmpDir" 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 Text
redshiftTmpDir,
            (Key
"TmpDirIAMRole" 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 Text
tmpDirIAMRole,
            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)
          ]
      )