{-# 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.PostgreSqlParameters
-- 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.PostgreSqlParameters where

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

-- | The parameters for PostgreSQL.
--
-- /See:/ 'newPostgreSqlParameters' smart constructor.
data PostgreSqlParameters = PostgreSqlParameters'
  { -- | Host.
    PostgreSqlParameters -> Text
host :: Prelude.Text,
    -- | Port.
    PostgreSqlParameters -> Natural
port :: Prelude.Natural,
    -- | Database.
    PostgreSqlParameters -> Text
database :: Prelude.Text
  }
  deriving (PostgreSqlParameters -> PostgreSqlParameters -> Bool
(PostgreSqlParameters -> PostgreSqlParameters -> Bool)
-> (PostgreSqlParameters -> PostgreSqlParameters -> Bool)
-> Eq PostgreSqlParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PostgreSqlParameters -> PostgreSqlParameters -> Bool
$c/= :: PostgreSqlParameters -> PostgreSqlParameters -> Bool
== :: PostgreSqlParameters -> PostgreSqlParameters -> Bool
$c== :: PostgreSqlParameters -> PostgreSqlParameters -> Bool
Prelude.Eq, ReadPrec [PostgreSqlParameters]
ReadPrec PostgreSqlParameters
Int -> ReadS PostgreSqlParameters
ReadS [PostgreSqlParameters]
(Int -> ReadS PostgreSqlParameters)
-> ReadS [PostgreSqlParameters]
-> ReadPrec PostgreSqlParameters
-> ReadPrec [PostgreSqlParameters]
-> Read PostgreSqlParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PostgreSqlParameters]
$creadListPrec :: ReadPrec [PostgreSqlParameters]
readPrec :: ReadPrec PostgreSqlParameters
$creadPrec :: ReadPrec PostgreSqlParameters
readList :: ReadS [PostgreSqlParameters]
$creadList :: ReadS [PostgreSqlParameters]
readsPrec :: Int -> ReadS PostgreSqlParameters
$creadsPrec :: Int -> ReadS PostgreSqlParameters
Prelude.Read, Int -> PostgreSqlParameters -> ShowS
[PostgreSqlParameters] -> ShowS
PostgreSqlParameters -> String
(Int -> PostgreSqlParameters -> ShowS)
-> (PostgreSqlParameters -> String)
-> ([PostgreSqlParameters] -> ShowS)
-> Show PostgreSqlParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PostgreSqlParameters] -> ShowS
$cshowList :: [PostgreSqlParameters] -> ShowS
show :: PostgreSqlParameters -> String
$cshow :: PostgreSqlParameters -> String
showsPrec :: Int -> PostgreSqlParameters -> ShowS
$cshowsPrec :: Int -> PostgreSqlParameters -> ShowS
Prelude.Show, (forall x. PostgreSqlParameters -> Rep PostgreSqlParameters x)
-> (forall x. Rep PostgreSqlParameters x -> PostgreSqlParameters)
-> Generic PostgreSqlParameters
forall x. Rep PostgreSqlParameters x -> PostgreSqlParameters
forall x. PostgreSqlParameters -> Rep PostgreSqlParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PostgreSqlParameters x -> PostgreSqlParameters
$cfrom :: forall x. PostgreSqlParameters -> Rep PostgreSqlParameters x
Prelude.Generic)

-- |
-- Create a value of 'PostgreSqlParameters' 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:
--
-- 'host', 'postgreSqlParameters_host' - Host.
--
-- 'port', 'postgreSqlParameters_port' - Port.
--
-- 'database', 'postgreSqlParameters_database' - Database.
newPostgreSqlParameters ::
  -- | 'host'
  Prelude.Text ->
  -- | 'port'
  Prelude.Natural ->
  -- | 'database'
  Prelude.Text ->
  PostgreSqlParameters
newPostgreSqlParameters :: Text -> Natural -> Text -> PostgreSqlParameters
newPostgreSqlParameters Text
pHost_ Natural
pPort_ Text
pDatabase_ =
  PostgreSqlParameters' :: Text -> Natural -> Text -> PostgreSqlParameters
PostgreSqlParameters'
    { $sel:host:PostgreSqlParameters' :: Text
host = Text
pHost_,
      $sel:port:PostgreSqlParameters' :: Natural
port = Natural
pPort_,
      $sel:database:PostgreSqlParameters' :: Text
database = Text
pDatabase_
    }

-- | Host.
postgreSqlParameters_host :: Lens.Lens' PostgreSqlParameters Prelude.Text
postgreSqlParameters_host :: (Text -> f Text) -> PostgreSqlParameters -> f PostgreSqlParameters
postgreSqlParameters_host = (PostgreSqlParameters -> Text)
-> (PostgreSqlParameters -> Text -> PostgreSqlParameters)
-> Lens PostgreSqlParameters PostgreSqlParameters Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PostgreSqlParameters' {Text
host :: Text
$sel:host:PostgreSqlParameters' :: PostgreSqlParameters -> Text
host} -> Text
host) (\s :: PostgreSqlParameters
s@PostgreSqlParameters' {} Text
a -> PostgreSqlParameters
s {$sel:host:PostgreSqlParameters' :: Text
host = Text
a} :: PostgreSqlParameters)

-- | Port.
postgreSqlParameters_port :: Lens.Lens' PostgreSqlParameters Prelude.Natural
postgreSqlParameters_port :: (Natural -> f Natural)
-> PostgreSqlParameters -> f PostgreSqlParameters
postgreSqlParameters_port = (PostgreSqlParameters -> Natural)
-> (PostgreSqlParameters -> Natural -> PostgreSqlParameters)
-> Lens PostgreSqlParameters PostgreSqlParameters Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PostgreSqlParameters' {Natural
port :: Natural
$sel:port:PostgreSqlParameters' :: PostgreSqlParameters -> Natural
port} -> Natural
port) (\s :: PostgreSqlParameters
s@PostgreSqlParameters' {} Natural
a -> PostgreSqlParameters
s {$sel:port:PostgreSqlParameters' :: Natural
port = Natural
a} :: PostgreSqlParameters)

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

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

instance Prelude.NFData PostgreSqlParameters

instance Core.ToJSON PostgreSqlParameters where
  toJSON :: PostgreSqlParameters -> Value
toJSON PostgreSqlParameters' {Natural
Text
database :: Text
port :: Natural
host :: Text
$sel:database:PostgreSqlParameters' :: PostgreSqlParameters -> Text
$sel:port:PostgreSqlParameters' :: PostgreSqlParameters -> Natural
$sel:host:PostgreSqlParameters' :: PostgreSqlParameters -> 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
"Host" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
host),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Port" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= 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)
          ]
      )