{-# 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.AdminDisableUser
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deactivates a user and revokes all access tokens for the user. A
-- deactivated user can\'t sign in, but still appears in the responses to
-- @GetUser@ and @ListUsers@ API requests.
--
-- You must make this API request with Amazon Web Services credentials that
-- have @cognito-idp:AdminDisableUser@ permissions.
module Amazonka.CognitoIdentityProvider.AdminDisableUser
  ( -- * Creating a Request
    AdminDisableUser (..),
    newAdminDisableUser,

    -- * Request Lenses
    adminDisableUser_userPoolId,
    adminDisableUser_username,

    -- * Destructuring the Response
    AdminDisableUserResponse (..),
    newAdminDisableUserResponse,

    -- * Response Lenses
    adminDisableUserResponse_httpStatus,
  )
where

import Amazonka.CognitoIdentityProvider.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'AdminDisableUser' 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', 'adminDisableUser_userPoolId' - The user pool ID for the user pool where you want to disable the user.
--
-- 'username', 'adminDisableUser_username' - The user name of the user you want to disable.
newAdminDisableUser ::
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  AdminDisableUser
newAdminDisableUser :: Text -> Text -> AdminDisableUser
newAdminDisableUser Text
pUserPoolId_ Text
pUsername_ =
  AdminDisableUser'
    { $sel:userPoolId:AdminDisableUser' :: Text
userPoolId = Text
pUserPoolId_,
      $sel:username:AdminDisableUser' :: Sensitive Text
username = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pUsername_
    }

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

-- | The user name of the user you want to disable.
adminDisableUser_username :: Lens.Lens' AdminDisableUser Prelude.Text
adminDisableUser_username :: Lens' AdminDisableUser Text
adminDisableUser_username = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminDisableUser' {Sensitive Text
username :: Sensitive Text
$sel:username:AdminDisableUser' :: AdminDisableUser -> Sensitive Text
username} -> Sensitive Text
username) (\s :: AdminDisableUser
s@AdminDisableUser' {} Sensitive Text
a -> AdminDisableUser
s {$sel:username:AdminDisableUser' :: Sensitive Text
username = Sensitive Text
a} :: AdminDisableUser) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Core.AWSRequest AdminDisableUser where
  type
    AWSResponse AdminDisableUser =
      AdminDisableUserResponse
  request :: (Service -> Service)
-> AdminDisableUser -> Request AdminDisableUser
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy AdminDisableUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AdminDisableUser)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AdminDisableUserResponse
AdminDisableUserResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable AdminDisableUser where
  hashWithSalt :: Int -> AdminDisableUser -> Int
hashWithSalt Int
_salt AdminDisableUser' {Text
Sensitive Text
username :: Sensitive Text
userPoolId :: Text
$sel:username:AdminDisableUser' :: AdminDisableUser -> Sensitive Text
$sel:userPoolId:AdminDisableUser' :: AdminDisableUser -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userPoolId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
username

instance Prelude.NFData AdminDisableUser where
  rnf :: AdminDisableUser -> ()
rnf AdminDisableUser' {Text
Sensitive Text
username :: Sensitive Text
userPoolId :: Text
$sel:username:AdminDisableUser' :: AdminDisableUser -> Sensitive Text
$sel:userPoolId:AdminDisableUser' :: AdminDisableUser -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
userPoolId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
username

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

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

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

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

-- | Represents the response received from the server to disable the user as
-- an administrator.
--
-- /See:/ 'newAdminDisableUserResponse' smart constructor.
data AdminDisableUserResponse = AdminDisableUserResponse'
  { -- | The response's http status code.
    AdminDisableUserResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AdminDisableUserResponse -> AdminDisableUserResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdminDisableUserResponse -> AdminDisableUserResponse -> Bool
$c/= :: AdminDisableUserResponse -> AdminDisableUserResponse -> Bool
== :: AdminDisableUserResponse -> AdminDisableUserResponse -> Bool
$c== :: AdminDisableUserResponse -> AdminDisableUserResponse -> Bool
Prelude.Eq, ReadPrec [AdminDisableUserResponse]
ReadPrec AdminDisableUserResponse
Int -> ReadS AdminDisableUserResponse
ReadS [AdminDisableUserResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AdminDisableUserResponse]
$creadListPrec :: ReadPrec [AdminDisableUserResponse]
readPrec :: ReadPrec AdminDisableUserResponse
$creadPrec :: ReadPrec AdminDisableUserResponse
readList :: ReadS [AdminDisableUserResponse]
$creadList :: ReadS [AdminDisableUserResponse]
readsPrec :: Int -> ReadS AdminDisableUserResponse
$creadsPrec :: Int -> ReadS AdminDisableUserResponse
Prelude.Read, Int -> AdminDisableUserResponse -> ShowS
[AdminDisableUserResponse] -> ShowS
AdminDisableUserResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdminDisableUserResponse] -> ShowS
$cshowList :: [AdminDisableUserResponse] -> ShowS
show :: AdminDisableUserResponse -> String
$cshow :: AdminDisableUserResponse -> String
showsPrec :: Int -> AdminDisableUserResponse -> ShowS
$cshowsPrec :: Int -> AdminDisableUserResponse -> ShowS
Prelude.Show, forall x.
Rep AdminDisableUserResponse x -> AdminDisableUserResponse
forall x.
AdminDisableUserResponse -> Rep AdminDisableUserResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AdminDisableUserResponse x -> AdminDisableUserResponse
$cfrom :: forall x.
AdminDisableUserResponse -> Rep AdminDisableUserResponse x
Prelude.Generic)

-- |
-- Create a value of 'AdminDisableUserResponse' 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:
--
-- 'httpStatus', 'adminDisableUserResponse_httpStatus' - The response's http status code.
newAdminDisableUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AdminDisableUserResponse
newAdminDisableUserResponse :: Int -> AdminDisableUserResponse
newAdminDisableUserResponse Int
pHttpStatus_ =
  AdminDisableUserResponse'
    { $sel:httpStatus:AdminDisableUserResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
adminDisableUserResponse_httpStatus :: Lens.Lens' AdminDisableUserResponse Prelude.Int
adminDisableUserResponse_httpStatus :: Lens' AdminDisableUserResponse Int
adminDisableUserResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminDisableUserResponse' {Int
httpStatus :: Int
$sel:httpStatus:AdminDisableUserResponse' :: AdminDisableUserResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: AdminDisableUserResponse
s@AdminDisableUserResponse' {} Int
a -> AdminDisableUserResponse
s {$sel:httpStatus:AdminDisableUserResponse' :: Int
httpStatus = Int
a} :: AdminDisableUserResponse)

instance Prelude.NFData AdminDisableUserResponse where
  rnf :: AdminDisableUserResponse -> ()
rnf AdminDisableUserResponse' {Int
httpStatus :: Int
$sel:httpStatus:AdminDisableUserResponse' :: AdminDisableUserResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus