{-# 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.RedshiftServerLess.Types.ConfigParameter
-- 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.RedshiftServerLess.Types.ConfigParameter 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

-- | An array of key-value pairs to set for advanced control over Amazon
-- Redshift Serverless.
--
-- /See:/ 'newConfigParameter' smart constructor.
data ConfigParameter = ConfigParameter'
  { -- | The key of the parameter. The options are @datestyle@,
    -- @enable_user_activity_logging@, @query_group@, @search_path@, and
    -- @max_query_execution_time@.
    ConfigParameter -> Maybe Text
parameterKey :: Prelude.Maybe Prelude.Text,
    -- | The value of the parameter to set.
    ConfigParameter -> Maybe Text
parameterValue :: Prelude.Maybe Prelude.Text
  }
  deriving (ConfigParameter -> ConfigParameter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfigParameter -> ConfigParameter -> Bool
$c/= :: ConfigParameter -> ConfigParameter -> Bool
== :: ConfigParameter -> ConfigParameter -> Bool
$c== :: ConfigParameter -> ConfigParameter -> Bool
Prelude.Eq, ReadPrec [ConfigParameter]
ReadPrec ConfigParameter
Int -> ReadS ConfigParameter
ReadS [ConfigParameter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfigParameter]
$creadListPrec :: ReadPrec [ConfigParameter]
readPrec :: ReadPrec ConfigParameter
$creadPrec :: ReadPrec ConfigParameter
readList :: ReadS [ConfigParameter]
$creadList :: ReadS [ConfigParameter]
readsPrec :: Int -> ReadS ConfigParameter
$creadsPrec :: Int -> ReadS ConfigParameter
Prelude.Read, Int -> ConfigParameter -> ShowS
[ConfigParameter] -> ShowS
ConfigParameter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfigParameter] -> ShowS
$cshowList :: [ConfigParameter] -> ShowS
show :: ConfigParameter -> String
$cshow :: ConfigParameter -> String
showsPrec :: Int -> ConfigParameter -> ShowS
$cshowsPrec :: Int -> ConfigParameter -> ShowS
Prelude.Show, forall x. Rep ConfigParameter x -> ConfigParameter
forall x. ConfigParameter -> Rep ConfigParameter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConfigParameter x -> ConfigParameter
$cfrom :: forall x. ConfigParameter -> Rep ConfigParameter x
Prelude.Generic)

-- |
-- Create a value of 'ConfigParameter' 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:
--
-- 'parameterKey', 'configParameter_parameterKey' - The key of the parameter. The options are @datestyle@,
-- @enable_user_activity_logging@, @query_group@, @search_path@, and
-- @max_query_execution_time@.
--
-- 'parameterValue', 'configParameter_parameterValue' - The value of the parameter to set.
newConfigParameter ::
  ConfigParameter
newConfigParameter :: ConfigParameter
newConfigParameter =
  ConfigParameter'
    { $sel:parameterKey:ConfigParameter' :: Maybe Text
parameterKey = forall a. Maybe a
Prelude.Nothing,
      $sel:parameterValue:ConfigParameter' :: Maybe Text
parameterValue = forall a. Maybe a
Prelude.Nothing
    }

-- | The key of the parameter. The options are @datestyle@,
-- @enable_user_activity_logging@, @query_group@, @search_path@, and
-- @max_query_execution_time@.
configParameter_parameterKey :: Lens.Lens' ConfigParameter (Prelude.Maybe Prelude.Text)
configParameter_parameterKey :: Lens' ConfigParameter (Maybe Text)
configParameter_parameterKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigParameter' {Maybe Text
parameterKey :: Maybe Text
$sel:parameterKey:ConfigParameter' :: ConfigParameter -> Maybe Text
parameterKey} -> Maybe Text
parameterKey) (\s :: ConfigParameter
s@ConfigParameter' {} Maybe Text
a -> ConfigParameter
s {$sel:parameterKey:ConfigParameter' :: Maybe Text
parameterKey = Maybe Text
a} :: ConfigParameter)

-- | The value of the parameter to set.
configParameter_parameterValue :: Lens.Lens' ConfigParameter (Prelude.Maybe Prelude.Text)
configParameter_parameterValue :: Lens' ConfigParameter (Maybe Text)
configParameter_parameterValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfigParameter' {Maybe Text
parameterValue :: Maybe Text
$sel:parameterValue:ConfigParameter' :: ConfigParameter -> Maybe Text
parameterValue} -> Maybe Text
parameterValue) (\s :: ConfigParameter
s@ConfigParameter' {} Maybe Text
a -> ConfigParameter
s {$sel:parameterValue:ConfigParameter' :: Maybe Text
parameterValue = Maybe Text
a} :: ConfigParameter)

instance Data.FromJSON ConfigParameter where
  parseJSON :: Value -> Parser ConfigParameter
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConfigParameter"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> ConfigParameter
ConfigParameter'
            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
"parameterKey")
            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
"parameterValue")
      )

instance Prelude.Hashable ConfigParameter where
  hashWithSalt :: Int -> ConfigParameter -> Int
hashWithSalt Int
_salt ConfigParameter' {Maybe Text
parameterValue :: Maybe Text
parameterKey :: Maybe Text
$sel:parameterValue:ConfigParameter' :: ConfigParameter -> Maybe Text
$sel:parameterKey:ConfigParameter' :: ConfigParameter -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parameterKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parameterValue

instance Prelude.NFData ConfigParameter where
  rnf :: ConfigParameter -> ()
rnf ConfigParameter' {Maybe Text
parameterValue :: Maybe Text
parameterKey :: Maybe Text
$sel:parameterValue:ConfigParameter' :: ConfigParameter -> Maybe Text
$sel:parameterKey:ConfigParameter' :: ConfigParameter -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parameterKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parameterValue

instance Data.ToJSON ConfigParameter where
  toJSON :: ConfigParameter -> Value
toJSON ConfigParameter' {Maybe Text
parameterValue :: Maybe Text
parameterKey :: Maybe Text
$sel:parameterValue:ConfigParameter' :: ConfigParameter -> Maybe Text
$sel:parameterKey:ConfigParameter' :: ConfigParameter -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"parameterKey" 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
parameterKey,
            (Key
"parameterValue" 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
parameterValue
          ]
      )