{-# 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.DeleteUserGroup
-- 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)
--
-- For Redis engine version 6.x onwards: Deletes a user group. The user
-- group must first be disassociated from the replication group before it
-- can be deleted. For more information, see
-- <http://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Clusters.RBAC.html Using Role Based Access Control (RBAC)>.
module Amazonka.ElastiCache.DeleteUserGroup
  ( -- * Creating a Request
    DeleteUserGroup (..),
    newDeleteUserGroup,

    -- * Request Lenses
    deleteUserGroup_userGroupId,

    -- * Destructuring the Response
    UserGroup (..),
    newUserGroup,

    -- * Response Lenses
    userGroup_status,
    userGroup_userIds,
    userGroup_arn,
    userGroup_userGroupId,
    userGroup_engine,
    userGroup_pendingChanges,
    userGroup_replicationGroups,
  )
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

-- | /See:/ 'newDeleteUserGroup' smart constructor.
data DeleteUserGroup = DeleteUserGroup'
  { -- | The ID of the user group.
    DeleteUserGroup -> Text
userGroupId :: Prelude.Text
  }
  deriving (DeleteUserGroup -> DeleteUserGroup -> Bool
(DeleteUserGroup -> DeleteUserGroup -> Bool)
-> (DeleteUserGroup -> DeleteUserGroup -> Bool)
-> Eq DeleteUserGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteUserGroup -> DeleteUserGroup -> Bool
$c/= :: DeleteUserGroup -> DeleteUserGroup -> Bool
== :: DeleteUserGroup -> DeleteUserGroup -> Bool
$c== :: DeleteUserGroup -> DeleteUserGroup -> Bool
Prelude.Eq, ReadPrec [DeleteUserGroup]
ReadPrec DeleteUserGroup
Int -> ReadS DeleteUserGroup
ReadS [DeleteUserGroup]
(Int -> ReadS DeleteUserGroup)
-> ReadS [DeleteUserGroup]
-> ReadPrec DeleteUserGroup
-> ReadPrec [DeleteUserGroup]
-> Read DeleteUserGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteUserGroup]
$creadListPrec :: ReadPrec [DeleteUserGroup]
readPrec :: ReadPrec DeleteUserGroup
$creadPrec :: ReadPrec DeleteUserGroup
readList :: ReadS [DeleteUserGroup]
$creadList :: ReadS [DeleteUserGroup]
readsPrec :: Int -> ReadS DeleteUserGroup
$creadsPrec :: Int -> ReadS DeleteUserGroup
Prelude.Read, Int -> DeleteUserGroup -> ShowS
[DeleteUserGroup] -> ShowS
DeleteUserGroup -> String
(Int -> DeleteUserGroup -> ShowS)
-> (DeleteUserGroup -> String)
-> ([DeleteUserGroup] -> ShowS)
-> Show DeleteUserGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteUserGroup] -> ShowS
$cshowList :: [DeleteUserGroup] -> ShowS
show :: DeleteUserGroup -> String
$cshow :: DeleteUserGroup -> String
showsPrec :: Int -> DeleteUserGroup -> ShowS
$cshowsPrec :: Int -> DeleteUserGroup -> ShowS
Prelude.Show, (forall x. DeleteUserGroup -> Rep DeleteUserGroup x)
-> (forall x. Rep DeleteUserGroup x -> DeleteUserGroup)
-> Generic DeleteUserGroup
forall x. Rep DeleteUserGroup x -> DeleteUserGroup
forall x. DeleteUserGroup -> Rep DeleteUserGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteUserGroup x -> DeleteUserGroup
$cfrom :: forall x. DeleteUserGroup -> Rep DeleteUserGroup x
Prelude.Generic)

-- |
-- Create a value of 'DeleteUserGroup' 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:
--
-- 'userGroupId', 'deleteUserGroup_userGroupId' - The ID of the user group.
newDeleteUserGroup ::
  -- | 'userGroupId'
  Prelude.Text ->
  DeleteUserGroup
newDeleteUserGroup :: Text -> DeleteUserGroup
newDeleteUserGroup Text
pUserGroupId_ =
  DeleteUserGroup' :: Text -> DeleteUserGroup
DeleteUserGroup' {$sel:userGroupId:DeleteUserGroup' :: Text
userGroupId = Text
pUserGroupId_}

-- | The ID of the user group.
deleteUserGroup_userGroupId :: Lens.Lens' DeleteUserGroup Prelude.Text
deleteUserGroup_userGroupId :: (Text -> f Text) -> DeleteUserGroup -> f DeleteUserGroup
deleteUserGroup_userGroupId = (DeleteUserGroup -> Text)
-> (DeleteUserGroup -> Text -> DeleteUserGroup)
-> Lens DeleteUserGroup DeleteUserGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUserGroup' {Text
userGroupId :: Text
$sel:userGroupId:DeleteUserGroup' :: DeleteUserGroup -> Text
userGroupId} -> Text
userGroupId) (\s :: DeleteUserGroup
s@DeleteUserGroup' {} Text
a -> DeleteUserGroup
s {$sel:userGroupId:DeleteUserGroup' :: Text
userGroupId = Text
a} :: DeleteUserGroup)

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

instance Prelude.Hashable DeleteUserGroup

instance Prelude.NFData DeleteUserGroup

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

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

instance Core.ToQuery DeleteUserGroup where
  toQuery :: DeleteUserGroup -> QueryString
toQuery DeleteUserGroup' {Text
userGroupId :: Text
$sel:userGroupId:DeleteUserGroup' :: DeleteUserGroup -> 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
"DeleteUserGroup" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2015-02-02" :: Prelude.ByteString),
        ByteString
"UserGroupId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
userGroupId
      ]