{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Redshift.ModifyClusterParameterGroup
-- 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)
--
-- Modifies the parameters of a parameter group. For the parameters
-- parameter, it can\'t contain ASCII characters.
--
-- For more information about parameters and parameter groups, go to
-- <https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-parameter-groups.html Amazon Redshift Parameter Groups>
-- in the /Amazon Redshift Cluster Management Guide/.
module Amazonka.Redshift.ModifyClusterParameterGroup
  ( -- * Creating a Request
    ModifyClusterParameterGroup (..),
    newModifyClusterParameterGroup,

    -- * Request Lenses
    modifyClusterParameterGroup_parameterGroupName,
    modifyClusterParameterGroup_parameters,

    -- * Destructuring the Response
    ClusterParameterGroupNameMessage (..),
    newClusterParameterGroupNameMessage,

    -- * Response Lenses
    clusterParameterGroupNameMessage_parameterGroupStatus,
    clusterParameterGroupNameMessage_parameterGroupName,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Describes a modify cluster parameter group operation.
--
-- /See:/ 'newModifyClusterParameterGroup' smart constructor.
data ModifyClusterParameterGroup = ModifyClusterParameterGroup'
  { -- | The name of the parameter group to be modified.
    ModifyClusterParameterGroup -> Text
parameterGroupName :: Prelude.Text,
    -- | An array of parameters to be modified. A maximum of 20 parameters can be
    -- modified in a single request.
    --
    -- For each parameter to be modified, you must supply at least the
    -- parameter name and parameter value; other name-value pairs of the
    -- parameter are optional.
    --
    -- For the workload management (WLM) configuration, you must supply all the
    -- name-value pairs in the wlm_json_configuration parameter.
    ModifyClusterParameterGroup -> [Parameter]
parameters :: [Parameter]
  }
  deriving (ModifyClusterParameterGroup -> ModifyClusterParameterGroup -> Bool
(ModifyClusterParameterGroup
 -> ModifyClusterParameterGroup -> Bool)
-> (ModifyClusterParameterGroup
    -> ModifyClusterParameterGroup -> Bool)
-> Eq ModifyClusterParameterGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyClusterParameterGroup -> ModifyClusterParameterGroup -> Bool
$c/= :: ModifyClusterParameterGroup -> ModifyClusterParameterGroup -> Bool
== :: ModifyClusterParameterGroup -> ModifyClusterParameterGroup -> Bool
$c== :: ModifyClusterParameterGroup -> ModifyClusterParameterGroup -> Bool
Prelude.Eq, ReadPrec [ModifyClusterParameterGroup]
ReadPrec ModifyClusterParameterGroup
Int -> ReadS ModifyClusterParameterGroup
ReadS [ModifyClusterParameterGroup]
(Int -> ReadS ModifyClusterParameterGroup)
-> ReadS [ModifyClusterParameterGroup]
-> ReadPrec ModifyClusterParameterGroup
-> ReadPrec [ModifyClusterParameterGroup]
-> Read ModifyClusterParameterGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyClusterParameterGroup]
$creadListPrec :: ReadPrec [ModifyClusterParameterGroup]
readPrec :: ReadPrec ModifyClusterParameterGroup
$creadPrec :: ReadPrec ModifyClusterParameterGroup
readList :: ReadS [ModifyClusterParameterGroup]
$creadList :: ReadS [ModifyClusterParameterGroup]
readsPrec :: Int -> ReadS ModifyClusterParameterGroup
$creadsPrec :: Int -> ReadS ModifyClusterParameterGroup
Prelude.Read, Int -> ModifyClusterParameterGroup -> ShowS
[ModifyClusterParameterGroup] -> ShowS
ModifyClusterParameterGroup -> String
(Int -> ModifyClusterParameterGroup -> ShowS)
-> (ModifyClusterParameterGroup -> String)
-> ([ModifyClusterParameterGroup] -> ShowS)
-> Show ModifyClusterParameterGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyClusterParameterGroup] -> ShowS
$cshowList :: [ModifyClusterParameterGroup] -> ShowS
show :: ModifyClusterParameterGroup -> String
$cshow :: ModifyClusterParameterGroup -> String
showsPrec :: Int -> ModifyClusterParameterGroup -> ShowS
$cshowsPrec :: Int -> ModifyClusterParameterGroup -> ShowS
Prelude.Show, (forall x.
 ModifyClusterParameterGroup -> Rep ModifyClusterParameterGroup x)
-> (forall x.
    Rep ModifyClusterParameterGroup x -> ModifyClusterParameterGroup)
-> Generic ModifyClusterParameterGroup
forall x.
Rep ModifyClusterParameterGroup x -> ModifyClusterParameterGroup
forall x.
ModifyClusterParameterGroup -> Rep ModifyClusterParameterGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ModifyClusterParameterGroup x -> ModifyClusterParameterGroup
$cfrom :: forall x.
ModifyClusterParameterGroup -> Rep ModifyClusterParameterGroup x
Prelude.Generic)

-- |
-- Create a value of 'ModifyClusterParameterGroup' 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:
--
-- 'parameterGroupName', 'modifyClusterParameterGroup_parameterGroupName' - The name of the parameter group to be modified.
--
-- 'parameters', 'modifyClusterParameterGroup_parameters' - An array of parameters to be modified. A maximum of 20 parameters can be
-- modified in a single request.
--
-- For each parameter to be modified, you must supply at least the
-- parameter name and parameter value; other name-value pairs of the
-- parameter are optional.
--
-- For the workload management (WLM) configuration, you must supply all the
-- name-value pairs in the wlm_json_configuration parameter.
newModifyClusterParameterGroup ::
  -- | 'parameterGroupName'
  Prelude.Text ->
  ModifyClusterParameterGroup
newModifyClusterParameterGroup :: Text -> ModifyClusterParameterGroup
newModifyClusterParameterGroup Text
pParameterGroupName_ =
  ModifyClusterParameterGroup' :: Text -> [Parameter] -> ModifyClusterParameterGroup
ModifyClusterParameterGroup'
    { $sel:parameterGroupName:ModifyClusterParameterGroup' :: Text
parameterGroupName =
        Text
pParameterGroupName_,
      $sel:parameters:ModifyClusterParameterGroup' :: [Parameter]
parameters = [Parameter]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the parameter group to be modified.
modifyClusterParameterGroup_parameterGroupName :: Lens.Lens' ModifyClusterParameterGroup Prelude.Text
modifyClusterParameterGroup_parameterGroupName :: (Text -> f Text)
-> ModifyClusterParameterGroup -> f ModifyClusterParameterGroup
modifyClusterParameterGroup_parameterGroupName = (ModifyClusterParameterGroup -> Text)
-> (ModifyClusterParameterGroup
    -> Text -> ModifyClusterParameterGroup)
-> Lens
     ModifyClusterParameterGroup ModifyClusterParameterGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyClusterParameterGroup' {Text
parameterGroupName :: Text
$sel:parameterGroupName:ModifyClusterParameterGroup' :: ModifyClusterParameterGroup -> Text
parameterGroupName} -> Text
parameterGroupName) (\s :: ModifyClusterParameterGroup
s@ModifyClusterParameterGroup' {} Text
a -> ModifyClusterParameterGroup
s {$sel:parameterGroupName:ModifyClusterParameterGroup' :: Text
parameterGroupName = Text
a} :: ModifyClusterParameterGroup)

-- | An array of parameters to be modified. A maximum of 20 parameters can be
-- modified in a single request.
--
-- For each parameter to be modified, you must supply at least the
-- parameter name and parameter value; other name-value pairs of the
-- parameter are optional.
--
-- For the workload management (WLM) configuration, you must supply all the
-- name-value pairs in the wlm_json_configuration parameter.
modifyClusterParameterGroup_parameters :: Lens.Lens' ModifyClusterParameterGroup [Parameter]
modifyClusterParameterGroup_parameters :: ([Parameter] -> f [Parameter])
-> ModifyClusterParameterGroup -> f ModifyClusterParameterGroup
modifyClusterParameterGroup_parameters = (ModifyClusterParameterGroup -> [Parameter])
-> (ModifyClusterParameterGroup
    -> [Parameter] -> ModifyClusterParameterGroup)
-> Lens
     ModifyClusterParameterGroup
     ModifyClusterParameterGroup
     [Parameter]
     [Parameter]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyClusterParameterGroup' {[Parameter]
parameters :: [Parameter]
$sel:parameters:ModifyClusterParameterGroup' :: ModifyClusterParameterGroup -> [Parameter]
parameters} -> [Parameter]
parameters) (\s :: ModifyClusterParameterGroup
s@ModifyClusterParameterGroup' {} [Parameter]
a -> ModifyClusterParameterGroup
s {$sel:parameters:ModifyClusterParameterGroup' :: [Parameter]
parameters = [Parameter]
a} :: ModifyClusterParameterGroup) (([Parameter] -> f [Parameter])
 -> ModifyClusterParameterGroup -> f ModifyClusterParameterGroup)
-> (([Parameter] -> f [Parameter]) -> [Parameter] -> f [Parameter])
-> ([Parameter] -> f [Parameter])
-> ModifyClusterParameterGroup
-> f ModifyClusterParameterGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Parameter] -> f [Parameter]) -> [Parameter] -> f [Parameter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest ModifyClusterParameterGroup where
  type
    AWSResponse ModifyClusterParameterGroup =
      ClusterParameterGroupNameMessage
  request :: ModifyClusterParameterGroup -> Request ModifyClusterParameterGroup
request = Service
-> ModifyClusterParameterGroup
-> Request ModifyClusterParameterGroup
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ModifyClusterParameterGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifyClusterParameterGroup)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ModifyClusterParameterGroup))
-> Logger
-> Service
-> Proxy ModifyClusterParameterGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifyClusterParameterGroup)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ModifyClusterParameterGroupResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String ClusterParameterGroupNameMessage
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable ModifyClusterParameterGroup

instance Prelude.NFData ModifyClusterParameterGroup

instance Core.ToHeaders ModifyClusterParameterGroup where
  toHeaders :: ModifyClusterParameterGroup -> ResponseHeaders
toHeaders = ResponseHeaders -> ModifyClusterParameterGroup -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath ModifyClusterParameterGroup where
  toPath :: ModifyClusterParameterGroup -> ByteString
toPath = ByteString -> ModifyClusterParameterGroup -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ModifyClusterParameterGroup where
  toQuery :: ModifyClusterParameterGroup -> QueryString
toQuery ModifyClusterParameterGroup' {[Parameter]
Text
parameters :: [Parameter]
parameterGroupName :: Text
$sel:parameters:ModifyClusterParameterGroup' :: ModifyClusterParameterGroup -> [Parameter]
$sel:parameterGroupName:ModifyClusterParameterGroup' :: ModifyClusterParameterGroup -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ( ByteString
"ModifyClusterParameterGroup" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"ParameterGroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
parameterGroupName,
        ByteString
"Parameters"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [Parameter] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"Parameter" [Parameter]
parameters
      ]