{-# 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.Neptune.ModifyDBParameterGroup
-- 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 DB parameter group. To modify more than one
-- parameter, submit a list of the following: @ParameterName@,
-- @ParameterValue@, and @ApplyMethod@. A maximum of 20 parameters can be
-- modified in a single request.
--
-- Changes to dynamic parameters are applied immediately. Changes to static
-- parameters require a reboot without failover to the DB instance
-- associated with the parameter group before the change can take effect.
--
-- After you modify a DB parameter group, you should wait at least 5
-- minutes before creating your first DB instance that uses that DB
-- parameter group as the default parameter group. This allows Amazon
-- Neptune to fully complete the modify action before the parameter group
-- is used as the default for a new DB instance. This is especially
-- important for parameters that are critical when creating the default
-- database for a DB instance, such as the character set for the default
-- database defined by the @character_set_database@ parameter. You can use
-- the /Parameter Groups/ option of the Amazon Neptune console or the
-- /DescribeDBParameters/ command to verify that your DB parameter group
-- has been created or modified.
module Amazonka.Neptune.ModifyDBParameterGroup
  ( -- * Creating a Request
    ModifyDBParameterGroup (..),
    newModifyDBParameterGroup,

    -- * Request Lenses
    modifyDBParameterGroup_dbParameterGroupName,
    modifyDBParameterGroup_parameters,

    -- * Destructuring the Response
    DBParameterGroupNameMessage (..),
    newDBParameterGroupNameMessage,

    -- * Response Lenses
    dbParameterGroupNameMessage_dbParameterGroupName,
  )
where

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

-- | /See:/ 'newModifyDBParameterGroup' smart constructor.
data ModifyDBParameterGroup = ModifyDBParameterGroup'
  { -- | The name of the DB parameter group.
    --
    -- Constraints:
    --
    -- -   If supplied, must match the name of an existing DBParameterGroup.
    ModifyDBParameterGroup -> Text
dbParameterGroupName :: Prelude.Text,
    -- | An array of parameter names, values, and the apply method for the
    -- parameter update. At least one parameter name, value, and apply method
    -- must be supplied; subsequent arguments are optional. A maximum of 20
    -- parameters can be modified in a single request.
    --
    -- Valid Values (for the application method): @immediate | pending-reboot@
    --
    -- You can use the immediate value with dynamic parameters only. You can
    -- use the pending-reboot value for both dynamic and static parameters, and
    -- changes are applied when you reboot the DB instance without failover.
    ModifyDBParameterGroup -> [Parameter]
parameters :: [Parameter]
  }
  deriving (ModifyDBParameterGroup -> ModifyDBParameterGroup -> Bool
(ModifyDBParameterGroup -> ModifyDBParameterGroup -> Bool)
-> (ModifyDBParameterGroup -> ModifyDBParameterGroup -> Bool)
-> Eq ModifyDBParameterGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyDBParameterGroup -> ModifyDBParameterGroup -> Bool
$c/= :: ModifyDBParameterGroup -> ModifyDBParameterGroup -> Bool
== :: ModifyDBParameterGroup -> ModifyDBParameterGroup -> Bool
$c== :: ModifyDBParameterGroup -> ModifyDBParameterGroup -> Bool
Prelude.Eq, ReadPrec [ModifyDBParameterGroup]
ReadPrec ModifyDBParameterGroup
Int -> ReadS ModifyDBParameterGroup
ReadS [ModifyDBParameterGroup]
(Int -> ReadS ModifyDBParameterGroup)
-> ReadS [ModifyDBParameterGroup]
-> ReadPrec ModifyDBParameterGroup
-> ReadPrec [ModifyDBParameterGroup]
-> Read ModifyDBParameterGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyDBParameterGroup]
$creadListPrec :: ReadPrec [ModifyDBParameterGroup]
readPrec :: ReadPrec ModifyDBParameterGroup
$creadPrec :: ReadPrec ModifyDBParameterGroup
readList :: ReadS [ModifyDBParameterGroup]
$creadList :: ReadS [ModifyDBParameterGroup]
readsPrec :: Int -> ReadS ModifyDBParameterGroup
$creadsPrec :: Int -> ReadS ModifyDBParameterGroup
Prelude.Read, Int -> ModifyDBParameterGroup -> ShowS
[ModifyDBParameterGroup] -> ShowS
ModifyDBParameterGroup -> String
(Int -> ModifyDBParameterGroup -> ShowS)
-> (ModifyDBParameterGroup -> String)
-> ([ModifyDBParameterGroup] -> ShowS)
-> Show ModifyDBParameterGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyDBParameterGroup] -> ShowS
$cshowList :: [ModifyDBParameterGroup] -> ShowS
show :: ModifyDBParameterGroup -> String
$cshow :: ModifyDBParameterGroup -> String
showsPrec :: Int -> ModifyDBParameterGroup -> ShowS
$cshowsPrec :: Int -> ModifyDBParameterGroup -> ShowS
Prelude.Show, (forall x. ModifyDBParameterGroup -> Rep ModifyDBParameterGroup x)
-> (forall x.
    Rep ModifyDBParameterGroup x -> ModifyDBParameterGroup)
-> Generic ModifyDBParameterGroup
forall x. Rep ModifyDBParameterGroup x -> ModifyDBParameterGroup
forall x. ModifyDBParameterGroup -> Rep ModifyDBParameterGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifyDBParameterGroup x -> ModifyDBParameterGroup
$cfrom :: forall x. ModifyDBParameterGroup -> Rep ModifyDBParameterGroup x
Prelude.Generic)

-- |
-- Create a value of 'ModifyDBParameterGroup' 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:
--
-- 'dbParameterGroupName', 'modifyDBParameterGroup_dbParameterGroupName' - The name of the DB parameter group.
--
-- Constraints:
--
-- -   If supplied, must match the name of an existing DBParameterGroup.
--
-- 'parameters', 'modifyDBParameterGroup_parameters' - An array of parameter names, values, and the apply method for the
-- parameter update. At least one parameter name, value, and apply method
-- must be supplied; subsequent arguments are optional. A maximum of 20
-- parameters can be modified in a single request.
--
-- Valid Values (for the application method): @immediate | pending-reboot@
--
-- You can use the immediate value with dynamic parameters only. You can
-- use the pending-reboot value for both dynamic and static parameters, and
-- changes are applied when you reboot the DB instance without failover.
newModifyDBParameterGroup ::
  -- | 'dbParameterGroupName'
  Prelude.Text ->
  ModifyDBParameterGroup
newModifyDBParameterGroup :: Text -> ModifyDBParameterGroup
newModifyDBParameterGroup Text
pDBParameterGroupName_ =
  ModifyDBParameterGroup' :: Text -> [Parameter] -> ModifyDBParameterGroup
ModifyDBParameterGroup'
    { $sel:dbParameterGroupName:ModifyDBParameterGroup' :: Text
dbParameterGroupName =
        Text
pDBParameterGroupName_,
      $sel:parameters:ModifyDBParameterGroup' :: [Parameter]
parameters = [Parameter]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the DB parameter group.
--
-- Constraints:
--
-- -   If supplied, must match the name of an existing DBParameterGroup.
modifyDBParameterGroup_dbParameterGroupName :: Lens.Lens' ModifyDBParameterGroup Prelude.Text
modifyDBParameterGroup_dbParameterGroupName :: (Text -> f Text)
-> ModifyDBParameterGroup -> f ModifyDBParameterGroup
modifyDBParameterGroup_dbParameterGroupName = (ModifyDBParameterGroup -> Text)
-> (ModifyDBParameterGroup -> Text -> ModifyDBParameterGroup)
-> Lens ModifyDBParameterGroup ModifyDBParameterGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyDBParameterGroup' {Text
dbParameterGroupName :: Text
$sel:dbParameterGroupName:ModifyDBParameterGroup' :: ModifyDBParameterGroup -> Text
dbParameterGroupName} -> Text
dbParameterGroupName) (\s :: ModifyDBParameterGroup
s@ModifyDBParameterGroup' {} Text
a -> ModifyDBParameterGroup
s {$sel:dbParameterGroupName:ModifyDBParameterGroup' :: Text
dbParameterGroupName = Text
a} :: ModifyDBParameterGroup)

-- | An array of parameter names, values, and the apply method for the
-- parameter update. At least one parameter name, value, and apply method
-- must be supplied; subsequent arguments are optional. A maximum of 20
-- parameters can be modified in a single request.
--
-- Valid Values (for the application method): @immediate | pending-reboot@
--
-- You can use the immediate value with dynamic parameters only. You can
-- use the pending-reboot value for both dynamic and static parameters, and
-- changes are applied when you reboot the DB instance without failover.
modifyDBParameterGroup_parameters :: Lens.Lens' ModifyDBParameterGroup [Parameter]
modifyDBParameterGroup_parameters :: ([Parameter] -> f [Parameter])
-> ModifyDBParameterGroup -> f ModifyDBParameterGroup
modifyDBParameterGroup_parameters = (ModifyDBParameterGroup -> [Parameter])
-> (ModifyDBParameterGroup
    -> [Parameter] -> ModifyDBParameterGroup)
-> Lens
     ModifyDBParameterGroup
     ModifyDBParameterGroup
     [Parameter]
     [Parameter]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyDBParameterGroup' {[Parameter]
parameters :: [Parameter]
$sel:parameters:ModifyDBParameterGroup' :: ModifyDBParameterGroup -> [Parameter]
parameters} -> [Parameter]
parameters) (\s :: ModifyDBParameterGroup
s@ModifyDBParameterGroup' {} [Parameter]
a -> ModifyDBParameterGroup
s {$sel:parameters:ModifyDBParameterGroup' :: [Parameter]
parameters = [Parameter]
a} :: ModifyDBParameterGroup) (([Parameter] -> f [Parameter])
 -> ModifyDBParameterGroup -> f ModifyDBParameterGroup)
-> (([Parameter] -> f [Parameter]) -> [Parameter] -> f [Parameter])
-> ([Parameter] -> f [Parameter])
-> ModifyDBParameterGroup
-> f ModifyDBParameterGroup
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 ModifyDBParameterGroup where
  type
    AWSResponse ModifyDBParameterGroup =
      DBParameterGroupNameMessage
  request :: ModifyDBParameterGroup -> Request ModifyDBParameterGroup
request = Service -> ModifyDBParameterGroup -> Request ModifyDBParameterGroup
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ModifyDBParameterGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifyDBParameterGroup)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ModifyDBParameterGroup))
-> Logger
-> Service
-> Proxy ModifyDBParameterGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifyDBParameterGroup)))
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
"ModifyDBParameterGroupResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String DBParameterGroupNameMessage
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable ModifyDBParameterGroup

instance Prelude.NFData ModifyDBParameterGroup

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

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

instance Core.ToQuery ModifyDBParameterGroup where
  toQuery :: ModifyDBParameterGroup -> QueryString
toQuery ModifyDBParameterGroup' {[Parameter]
Text
parameters :: [Parameter]
dbParameterGroupName :: Text
$sel:parameters:ModifyDBParameterGroup' :: ModifyDBParameterGroup -> [Parameter]
$sel:dbParameterGroupName:ModifyDBParameterGroup' :: ModifyDBParameterGroup -> 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
"ModifyDBParameterGroup" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2014-10-31" :: Prelude.ByteString),
        ByteString
"DBParameterGroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
dbParameterGroupName,
        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
      ]