{-# 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.MachineLearning.Types.RedshiftDatabase
-- 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.MachineLearning.Types.RedshiftDatabase where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the database details required to connect to an Amazon Redshift
-- database.
--
-- /See:/ 'newRedshiftDatabase' smart constructor.
data RedshiftDatabase = RedshiftDatabase'
  { RedshiftDatabase -> Text
databaseName :: Prelude.Text,
    RedshiftDatabase -> Text
clusterIdentifier :: Prelude.Text
  }
  deriving (RedshiftDatabase -> RedshiftDatabase -> Bool
(RedshiftDatabase -> RedshiftDatabase -> Bool)
-> (RedshiftDatabase -> RedshiftDatabase -> Bool)
-> Eq RedshiftDatabase
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RedshiftDatabase -> RedshiftDatabase -> Bool
$c/= :: RedshiftDatabase -> RedshiftDatabase -> Bool
== :: RedshiftDatabase -> RedshiftDatabase -> Bool
$c== :: RedshiftDatabase -> RedshiftDatabase -> Bool
Prelude.Eq, ReadPrec [RedshiftDatabase]
ReadPrec RedshiftDatabase
Int -> ReadS RedshiftDatabase
ReadS [RedshiftDatabase]
(Int -> ReadS RedshiftDatabase)
-> ReadS [RedshiftDatabase]
-> ReadPrec RedshiftDatabase
-> ReadPrec [RedshiftDatabase]
-> Read RedshiftDatabase
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RedshiftDatabase]
$creadListPrec :: ReadPrec [RedshiftDatabase]
readPrec :: ReadPrec RedshiftDatabase
$creadPrec :: ReadPrec RedshiftDatabase
readList :: ReadS [RedshiftDatabase]
$creadList :: ReadS [RedshiftDatabase]
readsPrec :: Int -> ReadS RedshiftDatabase
$creadsPrec :: Int -> ReadS RedshiftDatabase
Prelude.Read, Int -> RedshiftDatabase -> ShowS
[RedshiftDatabase] -> ShowS
RedshiftDatabase -> String
(Int -> RedshiftDatabase -> ShowS)
-> (RedshiftDatabase -> String)
-> ([RedshiftDatabase] -> ShowS)
-> Show RedshiftDatabase
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RedshiftDatabase] -> ShowS
$cshowList :: [RedshiftDatabase] -> ShowS
show :: RedshiftDatabase -> String
$cshow :: RedshiftDatabase -> String
showsPrec :: Int -> RedshiftDatabase -> ShowS
$cshowsPrec :: Int -> RedshiftDatabase -> ShowS
Prelude.Show, (forall x. RedshiftDatabase -> Rep RedshiftDatabase x)
-> (forall x. Rep RedshiftDatabase x -> RedshiftDatabase)
-> Generic RedshiftDatabase
forall x. Rep RedshiftDatabase x -> RedshiftDatabase
forall x. RedshiftDatabase -> Rep RedshiftDatabase x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RedshiftDatabase x -> RedshiftDatabase
$cfrom :: forall x. RedshiftDatabase -> Rep RedshiftDatabase x
Prelude.Generic)

-- |
-- Create a value of 'RedshiftDatabase' 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:
--
-- 'databaseName', 'redshiftDatabase_databaseName' - Undocumented member.
--
-- 'clusterIdentifier', 'redshiftDatabase_clusterIdentifier' - Undocumented member.
newRedshiftDatabase ::
  -- | 'databaseName'
  Prelude.Text ->
  -- | 'clusterIdentifier'
  Prelude.Text ->
  RedshiftDatabase
newRedshiftDatabase :: Text -> Text -> RedshiftDatabase
newRedshiftDatabase
  Text
pDatabaseName_
  Text
pClusterIdentifier_ =
    RedshiftDatabase' :: Text -> Text -> RedshiftDatabase
RedshiftDatabase'
      { $sel:databaseName:RedshiftDatabase' :: Text
databaseName = Text
pDatabaseName_,
        $sel:clusterIdentifier:RedshiftDatabase' :: Text
clusterIdentifier = Text
pClusterIdentifier_
      }

-- | Undocumented member.
redshiftDatabase_databaseName :: Lens.Lens' RedshiftDatabase Prelude.Text
redshiftDatabase_databaseName :: (Text -> f Text) -> RedshiftDatabase -> f RedshiftDatabase
redshiftDatabase_databaseName = (RedshiftDatabase -> Text)
-> (RedshiftDatabase -> Text -> RedshiftDatabase)
-> Lens RedshiftDatabase RedshiftDatabase Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDatabase' {Text
databaseName :: Text
$sel:databaseName:RedshiftDatabase' :: RedshiftDatabase -> Text
databaseName} -> Text
databaseName) (\s :: RedshiftDatabase
s@RedshiftDatabase' {} Text
a -> RedshiftDatabase
s {$sel:databaseName:RedshiftDatabase' :: Text
databaseName = Text
a} :: RedshiftDatabase)

-- | Undocumented member.
redshiftDatabase_clusterIdentifier :: Lens.Lens' RedshiftDatabase Prelude.Text
redshiftDatabase_clusterIdentifier :: (Text -> f Text) -> RedshiftDatabase -> f RedshiftDatabase
redshiftDatabase_clusterIdentifier = (RedshiftDatabase -> Text)
-> (RedshiftDatabase -> Text -> RedshiftDatabase)
-> Lens RedshiftDatabase RedshiftDatabase Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftDatabase' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:RedshiftDatabase' :: RedshiftDatabase -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: RedshiftDatabase
s@RedshiftDatabase' {} Text
a -> RedshiftDatabase
s {$sel:clusterIdentifier:RedshiftDatabase' :: Text
clusterIdentifier = Text
a} :: RedshiftDatabase)

instance Core.FromJSON RedshiftDatabase where
  parseJSON :: Value -> Parser RedshiftDatabase
parseJSON =
    String
-> (Object -> Parser RedshiftDatabase)
-> Value
-> Parser RedshiftDatabase
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RedshiftDatabase"
      ( \Object
x ->
          Text -> Text -> RedshiftDatabase
RedshiftDatabase'
            (Text -> Text -> RedshiftDatabase)
-> Parser Text -> Parser (Text -> RedshiftDatabase)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"DatabaseName")
            Parser (Text -> RedshiftDatabase)
-> Parser Text -> Parser RedshiftDatabase
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
"ClusterIdentifier")
      )

instance Prelude.Hashable RedshiftDatabase

instance Prelude.NFData RedshiftDatabase

instance Core.ToJSON RedshiftDatabase where
  toJSON :: RedshiftDatabase -> Value
toJSON RedshiftDatabase' {Text
clusterIdentifier :: Text
databaseName :: Text
$sel:clusterIdentifier:RedshiftDatabase' :: RedshiftDatabase -> Text
$sel:databaseName:RedshiftDatabase' :: RedshiftDatabase -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DatabaseName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
databaseName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ClusterIdentifier" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clusterIdentifier)
          ]
      )