{-# 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.ResetClusterParameterGroup
-- 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)
--
-- Sets one or more parameters of the specified parameter group to their
-- default values and sets the source values of the parameters to
-- \"engine-default\". To reset the entire parameter group specify the
-- /ResetAllParameters/ parameter. For parameter changes to take effect you
-- must reboot any associated clusters.
module Amazonka.Redshift.ResetClusterParameterGroup
  ( -- * Creating a Request
    ResetClusterParameterGroup (..),
    newResetClusterParameterGroup,

    -- * Request Lenses
    resetClusterParameterGroup_resetAllParameters,
    resetClusterParameterGroup_parameters,
    resetClusterParameterGroup_parameterGroupName,

    -- * 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

-- |
--
-- /See:/ 'newResetClusterParameterGroup' smart constructor.
data ResetClusterParameterGroup = ResetClusterParameterGroup'
  { -- | If @true@, all parameters in the specified parameter group will be reset
    -- to their default values.
    --
    -- Default: @true@
    ResetClusterParameterGroup -> Maybe Bool
resetAllParameters :: Prelude.Maybe Prelude.Bool,
    -- | An array of names of parameters to be reset. If /ResetAllParameters/
    -- option is not used, then at least one parameter name must be supplied.
    --
    -- Constraints: A maximum of 20 parameters can be reset in a single
    -- request.
    ResetClusterParameterGroup -> Maybe [Parameter]
parameters :: Prelude.Maybe [Parameter],
    -- | The name of the cluster parameter group to be reset.
    ResetClusterParameterGroup -> Text
parameterGroupName :: Prelude.Text
  }
  deriving (ResetClusterParameterGroup -> ResetClusterParameterGroup -> Bool
(ResetClusterParameterGroup -> ResetClusterParameterGroup -> Bool)
-> (ResetClusterParameterGroup
    -> ResetClusterParameterGroup -> Bool)
-> Eq ResetClusterParameterGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResetClusterParameterGroup -> ResetClusterParameterGroup -> Bool
$c/= :: ResetClusterParameterGroup -> ResetClusterParameterGroup -> Bool
== :: ResetClusterParameterGroup -> ResetClusterParameterGroup -> Bool
$c== :: ResetClusterParameterGroup -> ResetClusterParameterGroup -> Bool
Prelude.Eq, ReadPrec [ResetClusterParameterGroup]
ReadPrec ResetClusterParameterGroup
Int -> ReadS ResetClusterParameterGroup
ReadS [ResetClusterParameterGroup]
(Int -> ReadS ResetClusterParameterGroup)
-> ReadS [ResetClusterParameterGroup]
-> ReadPrec ResetClusterParameterGroup
-> ReadPrec [ResetClusterParameterGroup]
-> Read ResetClusterParameterGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResetClusterParameterGroup]
$creadListPrec :: ReadPrec [ResetClusterParameterGroup]
readPrec :: ReadPrec ResetClusterParameterGroup
$creadPrec :: ReadPrec ResetClusterParameterGroup
readList :: ReadS [ResetClusterParameterGroup]
$creadList :: ReadS [ResetClusterParameterGroup]
readsPrec :: Int -> ReadS ResetClusterParameterGroup
$creadsPrec :: Int -> ReadS ResetClusterParameterGroup
Prelude.Read, Int -> ResetClusterParameterGroup -> ShowS
[ResetClusterParameterGroup] -> ShowS
ResetClusterParameterGroup -> String
(Int -> ResetClusterParameterGroup -> ShowS)
-> (ResetClusterParameterGroup -> String)
-> ([ResetClusterParameterGroup] -> ShowS)
-> Show ResetClusterParameterGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResetClusterParameterGroup] -> ShowS
$cshowList :: [ResetClusterParameterGroup] -> ShowS
show :: ResetClusterParameterGroup -> String
$cshow :: ResetClusterParameterGroup -> String
showsPrec :: Int -> ResetClusterParameterGroup -> ShowS
$cshowsPrec :: Int -> ResetClusterParameterGroup -> ShowS
Prelude.Show, (forall x.
 ResetClusterParameterGroup -> Rep ResetClusterParameterGroup x)
-> (forall x.
    Rep ResetClusterParameterGroup x -> ResetClusterParameterGroup)
-> Generic ResetClusterParameterGroup
forall x.
Rep ResetClusterParameterGroup x -> ResetClusterParameterGroup
forall x.
ResetClusterParameterGroup -> Rep ResetClusterParameterGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResetClusterParameterGroup x -> ResetClusterParameterGroup
$cfrom :: forall x.
ResetClusterParameterGroup -> Rep ResetClusterParameterGroup x
Prelude.Generic)

-- |
-- Create a value of 'ResetClusterParameterGroup' 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', 'resetClusterParameterGroup_resetAllParameters' - If @true@, all parameters in the specified parameter group will be reset
-- to their default values.
--
-- Default: @true@
--
-- 'parameters', 'resetClusterParameterGroup_parameters' - An array of names of parameters to be reset. If /ResetAllParameters/
-- option is not used, then at least one parameter name must be supplied.
--
-- Constraints: A maximum of 20 parameters can be reset in a single
-- request.
--
-- 'parameterGroupName', 'resetClusterParameterGroup_parameterGroupName' - The name of the cluster parameter group to be reset.
newResetClusterParameterGroup ::
  -- | 'parameterGroupName'
  Prelude.Text ->
  ResetClusterParameterGroup
newResetClusterParameterGroup :: Text -> ResetClusterParameterGroup
newResetClusterParameterGroup Text
pParameterGroupName_ =
  ResetClusterParameterGroup' :: Maybe Bool
-> Maybe [Parameter] -> Text -> ResetClusterParameterGroup
ResetClusterParameterGroup'
    { $sel:resetAllParameters:ResetClusterParameterGroup' :: Maybe Bool
resetAllParameters =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:parameters:ResetClusterParameterGroup' :: Maybe [Parameter]
parameters = Maybe [Parameter]
forall a. Maybe a
Prelude.Nothing,
      $sel:parameterGroupName:ResetClusterParameterGroup' :: Text
parameterGroupName = Text
pParameterGroupName_
    }

-- | If @true@, all parameters in the specified parameter group will be reset
-- to their default values.
--
-- Default: @true@
resetClusterParameterGroup_resetAllParameters :: Lens.Lens' ResetClusterParameterGroup (Prelude.Maybe Prelude.Bool)
resetClusterParameterGroup_resetAllParameters :: (Maybe Bool -> f (Maybe Bool))
-> ResetClusterParameterGroup -> f ResetClusterParameterGroup
resetClusterParameterGroup_resetAllParameters = (ResetClusterParameterGroup -> Maybe Bool)
-> (ResetClusterParameterGroup
    -> Maybe Bool -> ResetClusterParameterGroup)
-> Lens
     ResetClusterParameterGroup
     ResetClusterParameterGroup
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResetClusterParameterGroup' {Maybe Bool
resetAllParameters :: Maybe Bool
$sel:resetAllParameters:ResetClusterParameterGroup' :: ResetClusterParameterGroup -> Maybe Bool
resetAllParameters} -> Maybe Bool
resetAllParameters) (\s :: ResetClusterParameterGroup
s@ResetClusterParameterGroup' {} Maybe Bool
a -> ResetClusterParameterGroup
s {$sel:resetAllParameters:ResetClusterParameterGroup' :: Maybe Bool
resetAllParameters = Maybe Bool
a} :: ResetClusterParameterGroup)

-- | An array of names of parameters to be reset. If /ResetAllParameters/
-- option is not used, then at least one parameter name must be supplied.
--
-- Constraints: A maximum of 20 parameters can be reset in a single
-- request.
resetClusterParameterGroup_parameters :: Lens.Lens' ResetClusterParameterGroup (Prelude.Maybe [Parameter])
resetClusterParameterGroup_parameters :: (Maybe [Parameter] -> f (Maybe [Parameter]))
-> ResetClusterParameterGroup -> f ResetClusterParameterGroup
resetClusterParameterGroup_parameters = (ResetClusterParameterGroup -> Maybe [Parameter])
-> (ResetClusterParameterGroup
    -> Maybe [Parameter] -> ResetClusterParameterGroup)
-> Lens
     ResetClusterParameterGroup
     ResetClusterParameterGroup
     (Maybe [Parameter])
     (Maybe [Parameter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResetClusterParameterGroup' {Maybe [Parameter]
parameters :: Maybe [Parameter]
$sel:parameters:ResetClusterParameterGroup' :: ResetClusterParameterGroup -> Maybe [Parameter]
parameters} -> Maybe [Parameter]
parameters) (\s :: ResetClusterParameterGroup
s@ResetClusterParameterGroup' {} Maybe [Parameter]
a -> ResetClusterParameterGroup
s {$sel:parameters:ResetClusterParameterGroup' :: Maybe [Parameter]
parameters = Maybe [Parameter]
a} :: ResetClusterParameterGroup) ((Maybe [Parameter] -> f (Maybe [Parameter]))
 -> ResetClusterParameterGroup -> f ResetClusterParameterGroup)
-> ((Maybe [Parameter] -> f (Maybe [Parameter]))
    -> Maybe [Parameter] -> f (Maybe [Parameter]))
-> (Maybe [Parameter] -> f (Maybe [Parameter]))
-> ResetClusterParameterGroup
-> f ResetClusterParameterGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Parameter] [Parameter] [Parameter] [Parameter]
-> Iso
     (Maybe [Parameter])
     (Maybe [Parameter])
     (Maybe [Parameter])
     (Maybe [Parameter])
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 [Parameter] [Parameter] [Parameter] [Parameter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

instance Prelude.NFData ResetClusterParameterGroup

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

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

instance Core.ToQuery ResetClusterParameterGroup where
  toQuery :: ResetClusterParameterGroup -> QueryString
toQuery ResetClusterParameterGroup' {Maybe Bool
Maybe [Parameter]
Text
parameterGroupName :: Text
parameters :: Maybe [Parameter]
resetAllParameters :: Maybe Bool
$sel:parameterGroupName:ResetClusterParameterGroup' :: ResetClusterParameterGroup -> Text
$sel:parameters:ResetClusterParameterGroup' :: ResetClusterParameterGroup -> Maybe [Parameter]
$sel:resetAllParameters:ResetClusterParameterGroup' :: ResetClusterParameterGroup -> 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
"ResetClusterParameterGroup" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"ResetAllParameters" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
resetAllParameters,
        ByteString
"Parameters"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [Parameter] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"Parameter"
                ([Parameter] -> QueryString)
-> Maybe [Parameter] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Parameter]
parameters
            ),
        ByteString
"ParameterGroupName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
parameterGroupName
      ]