{-# 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.ResetCacheParameterGroup
-- 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 to the engine or
-- system default value. You can reset specific parameters by submitting a
-- list of parameter names. To reset the entire cache parameter group,
-- specify the @ResetAllParameters@ and @CacheParameterGroupName@
-- parameters.
module Amazonka.ElastiCache.ResetCacheParameterGroup
  ( -- * Creating a Request
    ResetCacheParameterGroup (..),
    newResetCacheParameterGroup,

    -- * Request Lenses
    resetCacheParameterGroup_resetAllParameters,
    resetCacheParameterGroup_parameterNameValues,
    resetCacheParameterGroup_cacheParameterGroupName,

    -- * 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 @ResetCacheParameterGroup@ operation.
--
-- /See:/ 'newResetCacheParameterGroup' smart constructor.
data ResetCacheParameterGroup = ResetCacheParameterGroup'
  { -- | If @true@, all parameters in the cache parameter group are reset to
    -- their default values. If @false@, only the parameters listed by
    -- @ParameterNameValues@ are reset to their default values.
    --
    -- Valid values: @true@ | @false@
    ResetCacheParameterGroup -> Maybe Bool
resetAllParameters :: Prelude.Maybe Prelude.Bool,
    -- | An array of parameter names to reset to their default values. If
    -- @ResetAllParameters@ is @true@, do not use @ParameterNameValues@. If
    -- @ResetAllParameters@ is @false@, you must specify the name of at least
    -- one parameter to reset.
    ResetCacheParameterGroup -> Maybe [ParameterNameValue]
parameterNameValues :: Prelude.Maybe [ParameterNameValue],
    -- | The name of the cache parameter group to reset.
    ResetCacheParameterGroup -> Text
cacheParameterGroupName :: Prelude.Text
  }
  deriving (ResetCacheParameterGroup -> ResetCacheParameterGroup -> Bool
(ResetCacheParameterGroup -> ResetCacheParameterGroup -> Bool)
-> (ResetCacheParameterGroup -> ResetCacheParameterGroup -> Bool)
-> Eq ResetCacheParameterGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResetCacheParameterGroup -> ResetCacheParameterGroup -> Bool
$c/= :: ResetCacheParameterGroup -> ResetCacheParameterGroup -> Bool
== :: ResetCacheParameterGroup -> ResetCacheParameterGroup -> Bool
$c== :: ResetCacheParameterGroup -> ResetCacheParameterGroup -> Bool
Prelude.Eq, ReadPrec [ResetCacheParameterGroup]
ReadPrec ResetCacheParameterGroup
Int -> ReadS ResetCacheParameterGroup
ReadS [ResetCacheParameterGroup]
(Int -> ReadS ResetCacheParameterGroup)
-> ReadS [ResetCacheParameterGroup]
-> ReadPrec ResetCacheParameterGroup
-> ReadPrec [ResetCacheParameterGroup]
-> Read ResetCacheParameterGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResetCacheParameterGroup]
$creadListPrec :: ReadPrec [ResetCacheParameterGroup]
readPrec :: ReadPrec ResetCacheParameterGroup
$creadPrec :: ReadPrec ResetCacheParameterGroup
readList :: ReadS [ResetCacheParameterGroup]
$creadList :: ReadS [ResetCacheParameterGroup]
readsPrec :: Int -> ReadS ResetCacheParameterGroup
$creadsPrec :: Int -> ReadS ResetCacheParameterGroup
Prelude.Read, Int -> ResetCacheParameterGroup -> ShowS
[ResetCacheParameterGroup] -> ShowS
ResetCacheParameterGroup -> String
(Int -> ResetCacheParameterGroup -> ShowS)
-> (ResetCacheParameterGroup -> String)
-> ([ResetCacheParameterGroup] -> ShowS)
-> Show ResetCacheParameterGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResetCacheParameterGroup] -> ShowS
$cshowList :: [ResetCacheParameterGroup] -> ShowS
show :: ResetCacheParameterGroup -> String
$cshow :: ResetCacheParameterGroup -> String
showsPrec :: Int -> ResetCacheParameterGroup -> ShowS
$cshowsPrec :: Int -> ResetCacheParameterGroup -> ShowS
Prelude.Show, (forall x.
 ResetCacheParameterGroup -> Rep ResetCacheParameterGroup x)
-> (forall x.
    Rep ResetCacheParameterGroup x -> ResetCacheParameterGroup)
-> Generic ResetCacheParameterGroup
forall x.
Rep ResetCacheParameterGroup x -> ResetCacheParameterGroup
forall x.
ResetCacheParameterGroup -> Rep ResetCacheParameterGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResetCacheParameterGroup x -> ResetCacheParameterGroup
$cfrom :: forall x.
ResetCacheParameterGroup -> Rep ResetCacheParameterGroup x
Prelude.Generic)

-- |
-- Create a value of 'ResetCacheParameterGroup' 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:
--
-- 'resetAllParameters', 'resetCacheParameterGroup_resetAllParameters' - If @true@, all parameters in the cache parameter group are reset to
-- their default values. If @false@, only the parameters listed by
-- @ParameterNameValues@ are reset to their default values.
--
-- Valid values: @true@ | @false@
--
-- 'parameterNameValues', 'resetCacheParameterGroup_parameterNameValues' - An array of parameter names to reset to their default values. If
-- @ResetAllParameters@ is @true@, do not use @ParameterNameValues@. If
-- @ResetAllParameters@ is @false@, you must specify the name of at least
-- one parameter to reset.
--
-- 'cacheParameterGroupName', 'resetCacheParameterGroup_cacheParameterGroupName' - The name of the cache parameter group to reset.
newResetCacheParameterGroup ::
  -- | 'cacheParameterGroupName'
  Prelude.Text ->
  ResetCacheParameterGroup
newResetCacheParameterGroup :: Text -> ResetCacheParameterGroup
newResetCacheParameterGroup Text
pCacheParameterGroupName_ =
  ResetCacheParameterGroup' :: Maybe Bool
-> Maybe [ParameterNameValue] -> Text -> ResetCacheParameterGroup
ResetCacheParameterGroup'
    { $sel:resetAllParameters:ResetCacheParameterGroup' :: Maybe Bool
resetAllParameters =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:parameterNameValues:ResetCacheParameterGroup' :: Maybe [ParameterNameValue]
parameterNameValues = Maybe [ParameterNameValue]
forall a. Maybe a
Prelude.Nothing,
      $sel:cacheParameterGroupName:ResetCacheParameterGroup' :: Text
cacheParameterGroupName =
        Text
pCacheParameterGroupName_
    }

-- | If @true@, all parameters in the cache parameter group are reset to
-- their default values. If @false@, only the parameters listed by
-- @ParameterNameValues@ are reset to their default values.
--
-- Valid values: @true@ | @false@
resetCacheParameterGroup_resetAllParameters :: Lens.Lens' ResetCacheParameterGroup (Prelude.Maybe Prelude.Bool)
resetCacheParameterGroup_resetAllParameters :: (Maybe Bool -> f (Maybe Bool))
-> ResetCacheParameterGroup -> f ResetCacheParameterGroup
resetCacheParameterGroup_resetAllParameters = (ResetCacheParameterGroup -> Maybe Bool)
-> (ResetCacheParameterGroup
    -> Maybe Bool -> ResetCacheParameterGroup)
-> Lens
     ResetCacheParameterGroup
     ResetCacheParameterGroup
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResetCacheParameterGroup' {Maybe Bool
resetAllParameters :: Maybe Bool
$sel:resetAllParameters:ResetCacheParameterGroup' :: ResetCacheParameterGroup -> Maybe Bool
resetAllParameters} -> Maybe Bool
resetAllParameters) (\s :: ResetCacheParameterGroup
s@ResetCacheParameterGroup' {} Maybe Bool
a -> ResetCacheParameterGroup
s {$sel:resetAllParameters:ResetCacheParameterGroup' :: Maybe Bool
resetAllParameters = Maybe Bool
a} :: ResetCacheParameterGroup)

-- | An array of parameter names to reset to their default values. If
-- @ResetAllParameters@ is @true@, do not use @ParameterNameValues@. If
-- @ResetAllParameters@ is @false@, you must specify the name of at least
-- one parameter to reset.
resetCacheParameterGroup_parameterNameValues :: Lens.Lens' ResetCacheParameterGroup (Prelude.Maybe [ParameterNameValue])
resetCacheParameterGroup_parameterNameValues :: (Maybe [ParameterNameValue] -> f (Maybe [ParameterNameValue]))
-> ResetCacheParameterGroup -> f ResetCacheParameterGroup
resetCacheParameterGroup_parameterNameValues = (ResetCacheParameterGroup -> Maybe [ParameterNameValue])
-> (ResetCacheParameterGroup
    -> Maybe [ParameterNameValue] -> ResetCacheParameterGroup)
-> Lens
     ResetCacheParameterGroup
     ResetCacheParameterGroup
     (Maybe [ParameterNameValue])
     (Maybe [ParameterNameValue])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResetCacheParameterGroup' {Maybe [ParameterNameValue]
parameterNameValues :: Maybe [ParameterNameValue]
$sel:parameterNameValues:ResetCacheParameterGroup' :: ResetCacheParameterGroup -> Maybe [ParameterNameValue]
parameterNameValues} -> Maybe [ParameterNameValue]
parameterNameValues) (\s :: ResetCacheParameterGroup
s@ResetCacheParameterGroup' {} Maybe [ParameterNameValue]
a -> ResetCacheParameterGroup
s {$sel:parameterNameValues:ResetCacheParameterGroup' :: Maybe [ParameterNameValue]
parameterNameValues = Maybe [ParameterNameValue]
a} :: ResetCacheParameterGroup) ((Maybe [ParameterNameValue] -> f (Maybe [ParameterNameValue]))
 -> ResetCacheParameterGroup -> f ResetCacheParameterGroup)
-> ((Maybe [ParameterNameValue] -> f (Maybe [ParameterNameValue]))
    -> Maybe [ParameterNameValue] -> f (Maybe [ParameterNameValue]))
-> (Maybe [ParameterNameValue] -> f (Maybe [ParameterNameValue]))
-> ResetCacheParameterGroup
-> f ResetCacheParameterGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ParameterNameValue]
  [ParameterNameValue]
  [ParameterNameValue]
  [ParameterNameValue]
-> Iso
     (Maybe [ParameterNameValue])
     (Maybe [ParameterNameValue])
     (Maybe [ParameterNameValue])
     (Maybe [ParameterNameValue])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ParameterNameValue]
  [ParameterNameValue]
  [ParameterNameValue]
  [ParameterNameValue]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.NFData ResetCacheParameterGroup

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

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

instance Core.ToQuery ResetCacheParameterGroup where
  toQuery :: ResetCacheParameterGroup -> QueryString
toQuery ResetCacheParameterGroup' {Maybe Bool
Maybe [ParameterNameValue]
Text
cacheParameterGroupName :: Text
parameterNameValues :: Maybe [ParameterNameValue]
resetAllParameters :: Maybe Bool
$sel:cacheParameterGroupName:ResetCacheParameterGroup' :: ResetCacheParameterGroup -> Text
$sel:parameterNameValues:ResetCacheParameterGroup' :: ResetCacheParameterGroup -> Maybe [ParameterNameValue]
$sel:resetAllParameters:ResetCacheParameterGroup' :: ResetCacheParameterGroup -> Maybe Bool
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ResetCacheParameterGroup" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-02-02" :: Prelude.ByteString),
        ByteString
"ResetAllParameters" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
resetAllParameters,
        ByteString
"ParameterNameValues"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [ParameterNameValue] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"ParameterNameValue"
                ([ParameterNameValue] -> QueryString)
-> Maybe [ParameterNameValue] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ParameterNameValue]
parameterNameValues
            ),
        ByteString
"CacheParameterGroupName"
          ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
cacheParameterGroupName
      ]