{-# 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.CognitoIdentityProvider.AdminRemoveUserFromGroup
-- 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)
--
-- Removes the specified user from the specified group.
--
-- Calling this action requires developer credentials.
module Amazonka.CognitoIdentityProvider.AdminRemoveUserFromGroup
  ( -- * Creating a Request
    AdminRemoveUserFromGroup (..),
    newAdminRemoveUserFromGroup,

    -- * Request Lenses
    adminRemoveUserFromGroup_userPoolId,
    adminRemoveUserFromGroup_username,
    adminRemoveUserFromGroup_groupName,

    -- * Destructuring the Response
    AdminRemoveUserFromGroupResponse (..),
    newAdminRemoveUserFromGroupResponse,
  )
where

import Amazonka.CognitoIdentityProvider.Types
import qualified Amazonka.Core as Core
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:/ 'newAdminRemoveUserFromGroup' smart constructor.
data AdminRemoveUserFromGroup = AdminRemoveUserFromGroup'
  { -- | The user pool ID for the user pool.
    AdminRemoveUserFromGroup -> Text
userPoolId :: Prelude.Text,
    -- | The username for the user.
    AdminRemoveUserFromGroup -> Sensitive Text
username :: Core.Sensitive Prelude.Text,
    -- | The group name.
    AdminRemoveUserFromGroup -> Text
groupName :: Prelude.Text
  }
  deriving (AdminRemoveUserFromGroup -> AdminRemoveUserFromGroup -> Bool
(AdminRemoveUserFromGroup -> AdminRemoveUserFromGroup -> Bool)
-> (AdminRemoveUserFromGroup -> AdminRemoveUserFromGroup -> Bool)
-> Eq AdminRemoveUserFromGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdminRemoveUserFromGroup -> AdminRemoveUserFromGroup -> Bool
$c/= :: AdminRemoveUserFromGroup -> AdminRemoveUserFromGroup -> Bool
== :: AdminRemoveUserFromGroup -> AdminRemoveUserFromGroup -> Bool
$c== :: AdminRemoveUserFromGroup -> AdminRemoveUserFromGroup -> Bool
Prelude.Eq, Int -> AdminRemoveUserFromGroup -> ShowS
[AdminRemoveUserFromGroup] -> ShowS
AdminRemoveUserFromGroup -> String
(Int -> AdminRemoveUserFromGroup -> ShowS)
-> (AdminRemoveUserFromGroup -> String)
-> ([AdminRemoveUserFromGroup] -> ShowS)
-> Show AdminRemoveUserFromGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdminRemoveUserFromGroup] -> ShowS
$cshowList :: [AdminRemoveUserFromGroup] -> ShowS
show :: AdminRemoveUserFromGroup -> String
$cshow :: AdminRemoveUserFromGroup -> String
showsPrec :: Int -> AdminRemoveUserFromGroup -> ShowS
$cshowsPrec :: Int -> AdminRemoveUserFromGroup -> ShowS
Prelude.Show, (forall x.
 AdminRemoveUserFromGroup -> Rep AdminRemoveUserFromGroup x)
-> (forall x.
    Rep AdminRemoveUserFromGroup x -> AdminRemoveUserFromGroup)
-> Generic AdminRemoveUserFromGroup
forall x.
Rep AdminRemoveUserFromGroup x -> AdminRemoveUserFromGroup
forall x.
AdminRemoveUserFromGroup -> Rep AdminRemoveUserFromGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AdminRemoveUserFromGroup x -> AdminRemoveUserFromGroup
$cfrom :: forall x.
AdminRemoveUserFromGroup -> Rep AdminRemoveUserFromGroup x
Prelude.Generic)

-- |
-- Create a value of 'AdminRemoveUserFromGroup' 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:
--
-- 'userPoolId', 'adminRemoveUserFromGroup_userPoolId' - The user pool ID for the user pool.
--
-- 'username', 'adminRemoveUserFromGroup_username' - The username for the user.
--
-- 'groupName', 'adminRemoveUserFromGroup_groupName' - The group name.
newAdminRemoveUserFromGroup ::
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  -- | 'groupName'
  Prelude.Text ->
  AdminRemoveUserFromGroup
newAdminRemoveUserFromGroup :: Text -> Text -> Text -> AdminRemoveUserFromGroup
newAdminRemoveUserFromGroup
  Text
pUserPoolId_
  Text
pUsername_
  Text
pGroupName_ =
    AdminRemoveUserFromGroup' :: Text -> Sensitive Text -> Text -> AdminRemoveUserFromGroup
AdminRemoveUserFromGroup'
      { $sel:userPoolId:AdminRemoveUserFromGroup' :: Text
userPoolId =
          Text
pUserPoolId_,
        $sel:username:AdminRemoveUserFromGroup' :: Sensitive Text
username = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pUsername_,
        $sel:groupName:AdminRemoveUserFromGroup' :: Text
groupName = Text
pGroupName_
      }

-- | The user pool ID for the user pool.
adminRemoveUserFromGroup_userPoolId :: Lens.Lens' AdminRemoveUserFromGroup Prelude.Text
adminRemoveUserFromGroup_userPoolId :: (Text -> f Text)
-> AdminRemoveUserFromGroup -> f AdminRemoveUserFromGroup
adminRemoveUserFromGroup_userPoolId = (AdminRemoveUserFromGroup -> Text)
-> (AdminRemoveUserFromGroup -> Text -> AdminRemoveUserFromGroup)
-> Lens AdminRemoveUserFromGroup AdminRemoveUserFromGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminRemoveUserFromGroup' {Text
userPoolId :: Text
$sel:userPoolId:AdminRemoveUserFromGroup' :: AdminRemoveUserFromGroup -> Text
userPoolId} -> Text
userPoolId) (\s :: AdminRemoveUserFromGroup
s@AdminRemoveUserFromGroup' {} Text
a -> AdminRemoveUserFromGroup
s {$sel:userPoolId:AdminRemoveUserFromGroup' :: Text
userPoolId = Text
a} :: AdminRemoveUserFromGroup)

-- | The username for the user.
adminRemoveUserFromGroup_username :: Lens.Lens' AdminRemoveUserFromGroup Prelude.Text
adminRemoveUserFromGroup_username :: (Text -> f Text)
-> AdminRemoveUserFromGroup -> f AdminRemoveUserFromGroup
adminRemoveUserFromGroup_username = (AdminRemoveUserFromGroup -> Sensitive Text)
-> (AdminRemoveUserFromGroup
    -> Sensitive Text -> AdminRemoveUserFromGroup)
-> Lens
     AdminRemoveUserFromGroup
     AdminRemoveUserFromGroup
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminRemoveUserFromGroup' {Sensitive Text
username :: Sensitive Text
$sel:username:AdminRemoveUserFromGroup' :: AdminRemoveUserFromGroup -> Sensitive Text
username} -> Sensitive Text
username) (\s :: AdminRemoveUserFromGroup
s@AdminRemoveUserFromGroup' {} Sensitive Text
a -> AdminRemoveUserFromGroup
s {$sel:username:AdminRemoveUserFromGroup' :: Sensitive Text
username = Sensitive Text
a} :: AdminRemoveUserFromGroup) ((Sensitive Text -> f (Sensitive Text))
 -> AdminRemoveUserFromGroup -> f AdminRemoveUserFromGroup)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> AdminRemoveUserFromGroup
-> f AdminRemoveUserFromGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The group name.
adminRemoveUserFromGroup_groupName :: Lens.Lens' AdminRemoveUserFromGroup Prelude.Text
adminRemoveUserFromGroup_groupName :: (Text -> f Text)
-> AdminRemoveUserFromGroup -> f AdminRemoveUserFromGroup
adminRemoveUserFromGroup_groupName = (AdminRemoveUserFromGroup -> Text)
-> (AdminRemoveUserFromGroup -> Text -> AdminRemoveUserFromGroup)
-> Lens AdminRemoveUserFromGroup AdminRemoveUserFromGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminRemoveUserFromGroup' {Text
groupName :: Text
$sel:groupName:AdminRemoveUserFromGroup' :: AdminRemoveUserFromGroup -> Text
groupName} -> Text
groupName) (\s :: AdminRemoveUserFromGroup
s@AdminRemoveUserFromGroup' {} Text
a -> AdminRemoveUserFromGroup
s {$sel:groupName:AdminRemoveUserFromGroup' :: Text
groupName = Text
a} :: AdminRemoveUserFromGroup)

instance Core.AWSRequest AdminRemoveUserFromGroup where
  type
    AWSResponse AdminRemoveUserFromGroup =
      AdminRemoveUserFromGroupResponse
  request :: AdminRemoveUserFromGroup -> Request AdminRemoveUserFromGroup
request = Service
-> AdminRemoveUserFromGroup -> Request AdminRemoveUserFromGroup
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AdminRemoveUserFromGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AdminRemoveUserFromGroup)))
response =
    AWSResponse AdminRemoveUserFromGroup
-> Logger
-> Service
-> Proxy AdminRemoveUserFromGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AdminRemoveUserFromGroup)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse AdminRemoveUserFromGroup
AdminRemoveUserFromGroupResponse
AdminRemoveUserFromGroupResponse'

instance Prelude.Hashable AdminRemoveUserFromGroup

instance Prelude.NFData AdminRemoveUserFromGroup

instance Core.ToHeaders AdminRemoveUserFromGroup where
  toHeaders :: AdminRemoveUserFromGroup -> [Header]
toHeaders =
    [Header] -> AdminRemoveUserFromGroup -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"AWSCognitoIdentityProviderService.AdminRemoveUserFromGroup" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON AdminRemoveUserFromGroup where
  toJSON :: AdminRemoveUserFromGroup -> Value
toJSON AdminRemoveUserFromGroup' {Text
Sensitive Text
groupName :: Text
username :: Sensitive Text
userPoolId :: Text
$sel:groupName:AdminRemoveUserFromGroup' :: AdminRemoveUserFromGroup -> Text
$sel:username:AdminRemoveUserFromGroup' :: AdminRemoveUserFromGroup -> Sensitive Text
$sel:userPoolId:AdminRemoveUserFromGroup' :: AdminRemoveUserFromGroup -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UserPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userPoolId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Username" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
username),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
groupName)
          ]
      )

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

instance Core.ToQuery AdminRemoveUserFromGroup where
  toQuery :: AdminRemoveUserFromGroup -> QueryString
toQuery = QueryString -> AdminRemoveUserFromGroup -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'AdminRemoveUserFromGroupResponse' 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.
newAdminRemoveUserFromGroupResponse ::
  AdminRemoveUserFromGroupResponse
newAdminRemoveUserFromGroupResponse :: AdminRemoveUserFromGroupResponse
newAdminRemoveUserFromGroupResponse =
  AdminRemoveUserFromGroupResponse
AdminRemoveUserFromGroupResponse'

instance
  Prelude.NFData
    AdminRemoveUserFromGroupResponse