{-# 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.ElastiCache.ModifyCacheParameterGroup
-- 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 cache parameter group. You can modify up to
-- 20 parameters in a single request by submitting a list parameter name
-- and value pairs.
module Amazonka.ElastiCache.ModifyCacheParameterGroup
  ( -- * Creating a Request
    ModifyCacheParameterGroup (..),
    newModifyCacheParameterGroup,

    -- * Request Lenses
    modifyCacheParameterGroup_cacheParameterGroupName,
    modifyCacheParameterGroup_parameterNameValues,

    -- * Destructuring the Response
    CacheParameterGroupNameMessage (..),
    newCacheParameterGroupNameMessage,

    -- * Response Lenses
    cacheParameterGroupNameMessage_cacheParameterGroupName,
  )
where

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

-- | Represents the input of a @ModifyCacheParameterGroup@ operation.
--
-- /See:/ 'newModifyCacheParameterGroup' smart constructor.
data ModifyCacheParameterGroup = ModifyCacheParameterGroup'
  { -- | The name of the cache parameter group to modify.
    ModifyCacheParameterGroup -> Text
cacheParameterGroupName :: Prelude.Text,
    -- | An array of parameter names and values for the parameter update. You
    -- must supply at least one parameter name and value; subsequent arguments
    -- are optional. A maximum of 20 parameters may be modified per request.
    ModifyCacheParameterGroup -> [ParameterNameValue]
parameterNameValues :: [ParameterNameValue]
  }
  deriving (ModifyCacheParameterGroup -> ModifyCacheParameterGroup -> Bool
(ModifyCacheParameterGroup -> ModifyCacheParameterGroup -> Bool)
-> (ModifyCacheParameterGroup -> ModifyCacheParameterGroup -> Bool)
-> Eq ModifyCacheParameterGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyCacheParameterGroup -> ModifyCacheParameterGroup -> Bool
$c/= :: ModifyCacheParameterGroup -> ModifyCacheParameterGroup -> Bool
== :: ModifyCacheParameterGroup -> ModifyCacheParameterGroup -> Bool
$c== :: ModifyCacheParameterGroup -> ModifyCacheParameterGroup -> Bool
Prelude.Eq, ReadPrec [ModifyCacheParameterGroup]
ReadPrec ModifyCacheParameterGroup
Int -> ReadS ModifyCacheParameterGroup
ReadS [ModifyCacheParameterGroup]
(Int -> ReadS ModifyCacheParameterGroup)
-> ReadS [ModifyCacheParameterGroup]
-> ReadPrec ModifyCacheParameterGroup
-> ReadPrec [ModifyCacheParameterGroup]
-> Read ModifyCacheParameterGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyCacheParameterGroup]
$creadListPrec :: ReadPrec [ModifyCacheParameterGroup]
readPrec :: ReadPrec ModifyCacheParameterGroup
$creadPrec :: ReadPrec ModifyCacheParameterGroup
readList :: ReadS [ModifyCacheParameterGroup]
$creadList :: ReadS [ModifyCacheParameterGroup]
readsPrec :: Int -> ReadS ModifyCacheParameterGroup
$creadsPrec :: Int -> ReadS ModifyCacheParameterGroup
Prelude.Read, Int -> ModifyCacheParameterGroup -> ShowS
[ModifyCacheParameterGroup] -> ShowS
ModifyCacheParameterGroup -> String
(Int -> ModifyCacheParameterGroup -> ShowS)
-> (ModifyCacheParameterGroup -> String)
-> ([ModifyCacheParameterGroup] -> ShowS)
-> Show ModifyCacheParameterGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyCacheParameterGroup] -> ShowS
$cshowList :: [ModifyCacheParameterGroup] -> ShowS
show :: ModifyCacheParameterGroup -> String
$cshow :: ModifyCacheParameterGroup -> String
showsPrec :: Int -> ModifyCacheParameterGroup -> ShowS
$cshowsPrec :: Int -> ModifyCacheParameterGroup -> ShowS
Prelude.Show, (forall x.
 ModifyCacheParameterGroup -> Rep ModifyCacheParameterGroup x)
-> (forall x.
    Rep ModifyCacheParameterGroup x -> ModifyCacheParameterGroup)
-> Generic ModifyCacheParameterGroup
forall x.
Rep ModifyCacheParameterGroup x -> ModifyCacheParameterGroup
forall x.
ModifyCacheParameterGroup -> Rep ModifyCacheParameterGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ModifyCacheParameterGroup x -> ModifyCacheParameterGroup
$cfrom :: forall x.
ModifyCacheParameterGroup -> Rep ModifyCacheParameterGroup x
Prelude.Generic)

-- |
-- Create a value of 'ModifyCacheParameterGroup' 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:
--
-- 'cacheParameterGroupName', 'modifyCacheParameterGroup_cacheParameterGroupName' - The name of the cache parameter group to modify.
--
-- 'parameterNameValues', 'modifyCacheParameterGroup_parameterNameValues' - An array of parameter names and values for the parameter update. You
-- must supply at least one parameter name and value; subsequent arguments
-- are optional. A maximum of 20 parameters may be modified per request.
newModifyCacheParameterGroup ::
  -- | 'cacheParameterGroupName'
  Prelude.Text ->
  ModifyCacheParameterGroup
newModifyCacheParameterGroup :: Text -> ModifyCacheParameterGroup
newModifyCacheParameterGroup
  Text
pCacheParameterGroupName_ =
    ModifyCacheParameterGroup' :: Text -> [ParameterNameValue] -> ModifyCacheParameterGroup
ModifyCacheParameterGroup'
      { $sel:cacheParameterGroupName:ModifyCacheParameterGroup' :: Text
cacheParameterGroupName =
          Text
pCacheParameterGroupName_,
        $sel:parameterNameValues:ModifyCacheParameterGroup' :: [ParameterNameValue]
parameterNameValues = [ParameterNameValue]
forall a. Monoid a => a
Prelude.mempty
      }

-- | The name of the cache parameter group to modify.
modifyCacheParameterGroup_cacheParameterGroupName :: Lens.Lens' ModifyCacheParameterGroup Prelude.Text
modifyCacheParameterGroup_cacheParameterGroupName :: (Text -> f Text)
-> ModifyCacheParameterGroup -> f ModifyCacheParameterGroup
modifyCacheParameterGroup_cacheParameterGroupName = (ModifyCacheParameterGroup -> Text)
-> (ModifyCacheParameterGroup -> Text -> ModifyCacheParameterGroup)
-> Lens
     ModifyCacheParameterGroup ModifyCacheParameterGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyCacheParameterGroup' {Text
cacheParameterGroupName :: Text
$sel:cacheParameterGroupName:ModifyCacheParameterGroup' :: ModifyCacheParameterGroup -> Text
cacheParameterGroupName} -> Text
cacheParameterGroupName) (\s :: ModifyCacheParameterGroup
s@ModifyCacheParameterGroup' {} Text
a -> ModifyCacheParameterGroup
s {$sel:cacheParameterGroupName:ModifyCacheParameterGroup' :: Text
cacheParameterGroupName = Text
a} :: ModifyCacheParameterGroup)

-- | An array of parameter names and values for the parameter update. You
-- must supply at least one parameter name and value; subsequent arguments
-- are optional. A maximum of 20 parameters may be modified per request.
modifyCacheParameterGroup_parameterNameValues :: Lens.Lens' ModifyCacheParameterGroup [ParameterNameValue]
modifyCacheParameterGroup_parameterNameValues :: ([ParameterNameValue] -> f [ParameterNameValue])
-> ModifyCacheParameterGroup -> f ModifyCacheParameterGroup
modifyCacheParameterGroup_parameterNameValues = (ModifyCacheParameterGroup -> [ParameterNameValue])
-> (ModifyCacheParameterGroup
    -> [ParameterNameValue] -> ModifyCacheParameterGroup)
-> Lens
     ModifyCacheParameterGroup
     ModifyCacheParameterGroup
     [ParameterNameValue]
     [ParameterNameValue]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyCacheParameterGroup' {[ParameterNameValue]
parameterNameValues :: [ParameterNameValue]
$sel:parameterNameValues:ModifyCacheParameterGroup' :: ModifyCacheParameterGroup -> [ParameterNameValue]
parameterNameValues} -> [ParameterNameValue]
parameterNameValues) (\s :: ModifyCacheParameterGroup
s@ModifyCacheParameterGroup' {} [ParameterNameValue]
a -> ModifyCacheParameterGroup
s {$sel:parameterNameValues:ModifyCacheParameterGroup' :: [ParameterNameValue]
parameterNameValues = [ParameterNameValue]
a} :: ModifyCacheParameterGroup) (([ParameterNameValue] -> f [ParameterNameValue])
 -> ModifyCacheParameterGroup -> f ModifyCacheParameterGroup)
-> (([ParameterNameValue] -> f [ParameterNameValue])
    -> [ParameterNameValue] -> f [ParameterNameValue])
-> ([ParameterNameValue] -> f [ParameterNameValue])
-> ModifyCacheParameterGroup
-> f ModifyCacheParameterGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ParameterNameValue] -> f [ParameterNameValue])
-> [ParameterNameValue] -> f [ParameterNameValue]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest ModifyCacheParameterGroup where
  type
    AWSResponse ModifyCacheParameterGroup =
      CacheParameterGroupNameMessage
  request :: ModifyCacheParameterGroup -> Request ModifyCacheParameterGroup
request = Service
-> ModifyCacheParameterGroup -> Request ModifyCacheParameterGroup
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ModifyCacheParameterGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifyCacheParameterGroup)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ModifyCacheParameterGroup))
-> Logger
-> Service
-> Proxy ModifyCacheParameterGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ModifyCacheParameterGroup)))
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
"ModifyCacheParameterGroupResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String CacheParameterGroupNameMessage
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable ModifyCacheParameterGroup

instance Prelude.NFData ModifyCacheParameterGroup

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

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

instance Core.ToQuery ModifyCacheParameterGroup where
  toQuery :: ModifyCacheParameterGroup -> QueryString
toQuery ModifyCacheParameterGroup' {[ParameterNameValue]
Text
parameterNameValues :: [ParameterNameValue]
cacheParameterGroupName :: Text
$sel:parameterNameValues:ModifyCacheParameterGroup' :: ModifyCacheParameterGroup -> [ParameterNameValue]
$sel:cacheParameterGroupName:ModifyCacheParameterGroup' :: ModifyCacheParameterGroup -> 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
"ModifyCacheParameterGroup" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-02-02" :: Prelude.ByteString),
        ByteString
"CacheParameterGroupName"
          ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
cacheParameterGroupName,
        ByteString
"ParameterNameValues"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString -> [ParameterNameValue] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList
            ByteString
"ParameterNameValue"
            [ParameterNameValue]
parameterNameValues
      ]