{-# 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.QuickSight.Types.RedshiftParameters
-- 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.QuickSight.Types.RedshiftParameters where

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

-- | The parameters for Amazon Redshift. The @ClusterId@ field can be blank
-- if @Host@ and @Port@ are both set. The @Host@ and @Port@ fields can be
-- blank if the @ClusterId@ field is set.
--
-- /See:/ 'newRedshiftParameters' smart constructor.
data RedshiftParameters = RedshiftParameters'
  { -- | Cluster ID. This field can be blank if the @Host@ and @Port@ are
    -- provided.
    RedshiftParameters -> Maybe Text
clusterId :: Prelude.Maybe Prelude.Text,
    -- | Host. This field can be blank if @ClusterId@ is provided.
    RedshiftParameters -> Maybe Text
host :: Prelude.Maybe Prelude.Text,
    -- | Port. This field can be blank if the @ClusterId@ is provided.
    RedshiftParameters -> Maybe Natural
port :: Prelude.Maybe Prelude.Natural,
    -- | Database.
    RedshiftParameters -> Text
database :: Prelude.Text
  }
  deriving (RedshiftParameters -> RedshiftParameters -> Bool
(RedshiftParameters -> RedshiftParameters -> Bool)
-> (RedshiftParameters -> RedshiftParameters -> Bool)
-> Eq RedshiftParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RedshiftParameters -> RedshiftParameters -> Bool
$c/= :: RedshiftParameters -> RedshiftParameters -> Bool
== :: RedshiftParameters -> RedshiftParameters -> Bool
$c== :: RedshiftParameters -> RedshiftParameters -> Bool
Prelude.Eq, ReadPrec [RedshiftParameters]
ReadPrec RedshiftParameters
Int -> ReadS RedshiftParameters
ReadS [RedshiftParameters]
(Int -> ReadS RedshiftParameters)
-> ReadS [RedshiftParameters]
-> ReadPrec RedshiftParameters
-> ReadPrec [RedshiftParameters]
-> Read RedshiftParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RedshiftParameters]
$creadListPrec :: ReadPrec [RedshiftParameters]
readPrec :: ReadPrec RedshiftParameters
$creadPrec :: ReadPrec RedshiftParameters
readList :: ReadS [RedshiftParameters]
$creadList :: ReadS [RedshiftParameters]
readsPrec :: Int -> ReadS RedshiftParameters
$creadsPrec :: Int -> ReadS RedshiftParameters
Prelude.Read, Int -> RedshiftParameters -> ShowS
[RedshiftParameters] -> ShowS
RedshiftParameters -> String
(Int -> RedshiftParameters -> ShowS)
-> (RedshiftParameters -> String)
-> ([RedshiftParameters] -> ShowS)
-> Show RedshiftParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RedshiftParameters] -> ShowS
$cshowList :: [RedshiftParameters] -> ShowS
show :: RedshiftParameters -> String
$cshow :: RedshiftParameters -> String
showsPrec :: Int -> RedshiftParameters -> ShowS
$cshowsPrec :: Int -> RedshiftParameters -> ShowS
Prelude.Show, (forall x. RedshiftParameters -> Rep RedshiftParameters x)
-> (forall x. Rep RedshiftParameters x -> RedshiftParameters)
-> Generic RedshiftParameters
forall x. Rep RedshiftParameters x -> RedshiftParameters
forall x. RedshiftParameters -> Rep RedshiftParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RedshiftParameters x -> RedshiftParameters
$cfrom :: forall x. RedshiftParameters -> Rep RedshiftParameters x
Prelude.Generic)

-- |
-- Create a value of 'RedshiftParameters' 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:
--
-- 'clusterId', 'redshiftParameters_clusterId' - Cluster ID. This field can be blank if the @Host@ and @Port@ are
-- provided.
--
-- 'host', 'redshiftParameters_host' - Host. This field can be blank if @ClusterId@ is provided.
--
-- 'port', 'redshiftParameters_port' - Port. This field can be blank if the @ClusterId@ is provided.
--
-- 'database', 'redshiftParameters_database' - Database.
newRedshiftParameters ::
  -- | 'database'
  Prelude.Text ->
  RedshiftParameters
newRedshiftParameters :: Text -> RedshiftParameters
newRedshiftParameters Text
pDatabase_ =
  RedshiftParameters' :: Maybe Text
-> Maybe Text -> Maybe Natural -> Text -> RedshiftParameters
RedshiftParameters'
    { $sel:clusterId:RedshiftParameters' :: Maybe Text
clusterId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:host:RedshiftParameters' :: Maybe Text
host = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:port:RedshiftParameters' :: Maybe Natural
port = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:database:RedshiftParameters' :: Text
database = Text
pDatabase_
    }

-- | Cluster ID. This field can be blank if the @Host@ and @Port@ are
-- provided.
redshiftParameters_clusterId :: Lens.Lens' RedshiftParameters (Prelude.Maybe Prelude.Text)
redshiftParameters_clusterId :: (Maybe Text -> f (Maybe Text))
-> RedshiftParameters -> f RedshiftParameters
redshiftParameters_clusterId = (RedshiftParameters -> Maybe Text)
-> (RedshiftParameters -> Maybe Text -> RedshiftParameters)
-> Lens
     RedshiftParameters RedshiftParameters (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftParameters' {Maybe Text
clusterId :: Maybe Text
$sel:clusterId:RedshiftParameters' :: RedshiftParameters -> Maybe Text
clusterId} -> Maybe Text
clusterId) (\s :: RedshiftParameters
s@RedshiftParameters' {} Maybe Text
a -> RedshiftParameters
s {$sel:clusterId:RedshiftParameters' :: Maybe Text
clusterId = Maybe Text
a} :: RedshiftParameters)

-- | Host. This field can be blank if @ClusterId@ is provided.
redshiftParameters_host :: Lens.Lens' RedshiftParameters (Prelude.Maybe Prelude.Text)
redshiftParameters_host :: (Maybe Text -> f (Maybe Text))
-> RedshiftParameters -> f RedshiftParameters
redshiftParameters_host = (RedshiftParameters -> Maybe Text)
-> (RedshiftParameters -> Maybe Text -> RedshiftParameters)
-> Lens
     RedshiftParameters RedshiftParameters (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftParameters' {Maybe Text
host :: Maybe Text
$sel:host:RedshiftParameters' :: RedshiftParameters -> Maybe Text
host} -> Maybe Text
host) (\s :: RedshiftParameters
s@RedshiftParameters' {} Maybe Text
a -> RedshiftParameters
s {$sel:host:RedshiftParameters' :: Maybe Text
host = Maybe Text
a} :: RedshiftParameters)

-- | Port. This field can be blank if the @ClusterId@ is provided.
redshiftParameters_port :: Lens.Lens' RedshiftParameters (Prelude.Maybe Prelude.Natural)
redshiftParameters_port :: (Maybe Natural -> f (Maybe Natural))
-> RedshiftParameters -> f RedshiftParameters
redshiftParameters_port = (RedshiftParameters -> Maybe Natural)
-> (RedshiftParameters -> Maybe Natural -> RedshiftParameters)
-> Lens
     RedshiftParameters
     RedshiftParameters
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftParameters' {Maybe Natural
port :: Maybe Natural
$sel:port:RedshiftParameters' :: RedshiftParameters -> Maybe Natural
port} -> Maybe Natural
port) (\s :: RedshiftParameters
s@RedshiftParameters' {} Maybe Natural
a -> RedshiftParameters
s {$sel:port:RedshiftParameters' :: Maybe Natural
port = Maybe Natural
a} :: RedshiftParameters)

-- | Database.
redshiftParameters_database :: Lens.Lens' RedshiftParameters Prelude.Text
redshiftParameters_database :: (Text -> f Text) -> RedshiftParameters -> f RedshiftParameters
redshiftParameters_database = (RedshiftParameters -> Text)
-> (RedshiftParameters -> Text -> RedshiftParameters)
-> Lens RedshiftParameters RedshiftParameters Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RedshiftParameters' {Text
database :: Text
$sel:database:RedshiftParameters' :: RedshiftParameters -> Text
database} -> Text
database) (\s :: RedshiftParameters
s@RedshiftParameters' {} Text
a -> RedshiftParameters
s {$sel:database:RedshiftParameters' :: Text
database = Text
a} :: RedshiftParameters)

instance Core.FromJSON RedshiftParameters where
  parseJSON :: Value -> Parser RedshiftParameters
parseJSON =
    String
-> (Object -> Parser RedshiftParameters)
-> Value
-> Parser RedshiftParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RedshiftParameters"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Natural -> Text -> RedshiftParameters
RedshiftParameters'
            (Maybe Text
 -> Maybe Text -> Maybe Natural -> Text -> RedshiftParameters)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Natural -> Text -> RedshiftParameters)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ClusterId")
            Parser (Maybe Text -> Maybe Natural -> Text -> RedshiftParameters)
-> Parser (Maybe Text)
-> Parser (Maybe Natural -> Text -> RedshiftParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Host")
            Parser (Maybe Natural -> Text -> RedshiftParameters)
-> Parser (Maybe Natural) -> Parser (Text -> RedshiftParameters)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Port")
            Parser (Text -> RedshiftParameters)
-> Parser Text -> Parser RedshiftParameters
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
"Database")
      )

instance Prelude.Hashable RedshiftParameters

instance Prelude.NFData RedshiftParameters

instance Core.ToJSON RedshiftParameters where
  toJSON :: RedshiftParameters -> Value
toJSON RedshiftParameters' {Maybe Natural
Maybe Text
Text
database :: Text
port :: Maybe Natural
host :: Maybe Text
clusterId :: Maybe Text
$sel:database:RedshiftParameters' :: RedshiftParameters -> Text
$sel:port:RedshiftParameters' :: RedshiftParameters -> Maybe Natural
$sel:host:RedshiftParameters' :: RedshiftParameters -> Maybe Text
$sel:clusterId:RedshiftParameters' :: RedshiftParameters -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ClusterId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clusterId,
            (Text
"Host" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
host,
            (Text
"Port" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
port,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Database" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
database)
          ]
      )