{-# 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.AdminDeleteUser
-- 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)
--
-- Deletes a user as an administrator. Works on any user.
--
-- Calling this action requires developer credentials.
module Amazonka.CognitoIdentityProvider.AdminDeleteUser
  ( -- * Creating a Request
    AdminDeleteUser (..),
    newAdminDeleteUser,

    -- * Request Lenses
    adminDeleteUser_userPoolId,
    adminDeleteUser_username,

    -- * Destructuring the Response
    AdminDeleteUserResponse (..),
    newAdminDeleteUserResponse,
  )
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

-- | Represents the request to delete a user as an administrator.
--
-- /See:/ 'newAdminDeleteUser' smart constructor.
data AdminDeleteUser = AdminDeleteUser'
  { -- | The user pool ID for the user pool where you want to delete the user.
    AdminDeleteUser -> Text
userPoolId :: Prelude.Text,
    -- | The user name of the user you wish to delete.
    AdminDeleteUser -> Sensitive Text
username :: Core.Sensitive Prelude.Text
  }
  deriving (AdminDeleteUser -> AdminDeleteUser -> Bool
(AdminDeleteUser -> AdminDeleteUser -> Bool)
-> (AdminDeleteUser -> AdminDeleteUser -> Bool)
-> Eq AdminDeleteUser
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdminDeleteUser -> AdminDeleteUser -> Bool
$c/= :: AdminDeleteUser -> AdminDeleteUser -> Bool
== :: AdminDeleteUser -> AdminDeleteUser -> Bool
$c== :: AdminDeleteUser -> AdminDeleteUser -> Bool
Prelude.Eq, Int -> AdminDeleteUser -> ShowS
[AdminDeleteUser] -> ShowS
AdminDeleteUser -> String
(Int -> AdminDeleteUser -> ShowS)
-> (AdminDeleteUser -> String)
-> ([AdminDeleteUser] -> ShowS)
-> Show AdminDeleteUser
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdminDeleteUser] -> ShowS
$cshowList :: [AdminDeleteUser] -> ShowS
show :: AdminDeleteUser -> String
$cshow :: AdminDeleteUser -> String
showsPrec :: Int -> AdminDeleteUser -> ShowS
$cshowsPrec :: Int -> AdminDeleteUser -> ShowS
Prelude.Show, (forall x. AdminDeleteUser -> Rep AdminDeleteUser x)
-> (forall x. Rep AdminDeleteUser x -> AdminDeleteUser)
-> Generic AdminDeleteUser
forall x. Rep AdminDeleteUser x -> AdminDeleteUser
forall x. AdminDeleteUser -> Rep AdminDeleteUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AdminDeleteUser x -> AdminDeleteUser
$cfrom :: forall x. AdminDeleteUser -> Rep AdminDeleteUser x
Prelude.Generic)

-- |
-- Create a value of 'AdminDeleteUser' 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', 'adminDeleteUser_userPoolId' - The user pool ID for the user pool where you want to delete the user.
--
-- 'username', 'adminDeleteUser_username' - The user name of the user you wish to delete.
newAdminDeleteUser ::
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  AdminDeleteUser
newAdminDeleteUser :: Text -> Text -> AdminDeleteUser
newAdminDeleteUser Text
pUserPoolId_ Text
pUsername_ =
  AdminDeleteUser' :: Text -> Sensitive Text -> AdminDeleteUser
AdminDeleteUser'
    { $sel:userPoolId:AdminDeleteUser' :: Text
userPoolId = Text
pUserPoolId_,
      $sel:username:AdminDeleteUser' :: 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_
    }

-- | The user pool ID for the user pool where you want to delete the user.
adminDeleteUser_userPoolId :: Lens.Lens' AdminDeleteUser Prelude.Text
adminDeleteUser_userPoolId :: (Text -> f Text) -> AdminDeleteUser -> f AdminDeleteUser
adminDeleteUser_userPoolId = (AdminDeleteUser -> Text)
-> (AdminDeleteUser -> Text -> AdminDeleteUser)
-> Lens AdminDeleteUser AdminDeleteUser Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminDeleteUser' {Text
userPoolId :: Text
$sel:userPoolId:AdminDeleteUser' :: AdminDeleteUser -> Text
userPoolId} -> Text
userPoolId) (\s :: AdminDeleteUser
s@AdminDeleteUser' {} Text
a -> AdminDeleteUser
s {$sel:userPoolId:AdminDeleteUser' :: Text
userPoolId = Text
a} :: AdminDeleteUser)

-- | The user name of the user you wish to delete.
adminDeleteUser_username :: Lens.Lens' AdminDeleteUser Prelude.Text
adminDeleteUser_username :: (Text -> f Text) -> AdminDeleteUser -> f AdminDeleteUser
adminDeleteUser_username = (AdminDeleteUser -> Sensitive Text)
-> (AdminDeleteUser -> Sensitive Text -> AdminDeleteUser)
-> Lens
     AdminDeleteUser AdminDeleteUser (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminDeleteUser' {Sensitive Text
username :: Sensitive Text
$sel:username:AdminDeleteUser' :: AdminDeleteUser -> Sensitive Text
username} -> Sensitive Text
username) (\s :: AdminDeleteUser
s@AdminDeleteUser' {} Sensitive Text
a -> AdminDeleteUser
s {$sel:username:AdminDeleteUser' :: Sensitive Text
username = Sensitive Text
a} :: AdminDeleteUser) ((Sensitive Text -> f (Sensitive Text))
 -> AdminDeleteUser -> f AdminDeleteUser)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> AdminDeleteUser
-> f AdminDeleteUser
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

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

instance Prelude.Hashable AdminDeleteUser

instance Prelude.NFData AdminDeleteUser

instance Core.ToHeaders AdminDeleteUser where
  toHeaders :: AdminDeleteUser -> [Header]
toHeaders =
    [Header] -> AdminDeleteUser -> [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.AdminDeleteUser" ::
                          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 AdminDeleteUser where
  toJSON :: AdminDeleteUser -> Value
toJSON AdminDeleteUser' {Text
Sensitive Text
username :: Sensitive Text
userPoolId :: Text
$sel:username:AdminDeleteUser' :: AdminDeleteUser -> Sensitive Text
$sel:userPoolId:AdminDeleteUser' :: AdminDeleteUser -> 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)
          ]
      )

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

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

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

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

instance Prelude.NFData AdminDeleteUserResponse