{-# 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-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)
--
-- Disables the specified user.
--
-- Calling this action requires developer credentials.
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.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 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 wish to disable.
    AdminDisableUser -> Sensitive Text
username :: Core.Sensitive Prelude.Text
  }
  deriving (AdminDisableUser -> AdminDisableUser -> Bool
(AdminDisableUser -> AdminDisableUser -> Bool)
-> (AdminDisableUser -> AdminDisableUser -> Bool)
-> Eq AdminDisableUser
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
(Int -> AdminDisableUser -> ShowS)
-> (AdminDisableUser -> String)
-> ([AdminDisableUser] -> ShowS)
-> Show AdminDisableUser
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. AdminDisableUser -> Rep AdminDisableUser x)
-> (forall x. Rep AdminDisableUser x -> AdminDisableUser)
-> Generic AdminDisableUser
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 wish to disable.
newAdminDisableUser ::
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  AdminDisableUser
newAdminDisableUser :: Text -> Text -> AdminDisableUser
newAdminDisableUser Text
pUserPoolId_ Text
pUsername_ =
  AdminDisableUser' :: Text -> Sensitive Text -> AdminDisableUser
AdminDisableUser'
    { $sel:userPoolId:AdminDisableUser' :: Text
userPoolId = Text
pUserPoolId_,
      $sel:username:AdminDisableUser' :: 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 disable the user.
adminDisableUser_userPoolId :: Lens.Lens' AdminDisableUser Prelude.Text
adminDisableUser_userPoolId :: (Text -> f Text) -> AdminDisableUser -> f AdminDisableUser
adminDisableUser_userPoolId = (AdminDisableUser -> Text)
-> (AdminDisableUser -> Text -> AdminDisableUser)
-> Lens AdminDisableUser AdminDisableUser Text Text
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 wish to disable.
adminDisableUser_username :: Lens.Lens' AdminDisableUser Prelude.Text
adminDisableUser_username :: (Text -> f Text) -> AdminDisableUser -> f AdminDisableUser
adminDisableUser_username = (AdminDisableUser -> Sensitive Text)
-> (AdminDisableUser -> Sensitive Text -> AdminDisableUser)
-> Lens
     AdminDisableUser AdminDisableUser (Sensitive Text) (Sensitive Text)
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) ((Sensitive Text -> f (Sensitive Text))
 -> AdminDisableUser -> f AdminDisableUser)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> AdminDisableUser
-> f AdminDisableUser
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 AdminDisableUser where
  type
    AWSResponse AdminDisableUser =
      AdminDisableUserResponse
  request :: AdminDisableUser -> Request AdminDisableUser
request = Service -> AdminDisableUser -> Request AdminDisableUser
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AdminDisableUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AdminDisableUser)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AdminDisableUser))
-> Logger
-> Service
-> Proxy AdminDisableUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse AdminDisableUser)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AdminDisableUserResponse
AdminDisableUserResponse'
            (Int -> AdminDisableUserResponse)
-> Either String Int -> Either String AdminDisableUserResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable AdminDisableUser

instance Prelude.NFData AdminDisableUser

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

instance Core.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
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 AdminDisableUser where
  toPath :: AdminDisableUser -> ByteString
toPath = ByteString -> AdminDisableUser -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery AdminDisableUser where
  toQuery :: AdminDisableUser -> QueryString
toQuery = QueryString -> AdminDisableUser -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(AdminDisableUserResponse -> AdminDisableUserResponse -> Bool)
-> (AdminDisableUserResponse -> AdminDisableUserResponse -> Bool)
-> Eq AdminDisableUserResponse
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]
(Int -> ReadS AdminDisableUserResponse)
-> ReadS [AdminDisableUserResponse]
-> ReadPrec AdminDisableUserResponse
-> ReadPrec [AdminDisableUserResponse]
-> Read 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
(Int -> AdminDisableUserResponse -> ShowS)
-> (AdminDisableUserResponse -> String)
-> ([AdminDisableUserResponse] -> ShowS)
-> Show AdminDisableUserResponse
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.
 AdminDisableUserResponse -> Rep AdminDisableUserResponse x)
-> (forall x.
    Rep AdminDisableUserResponse x -> AdminDisableUserResponse)
-> Generic AdminDisableUserResponse
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' :: Int -> AdminDisableUserResponse
AdminDisableUserResponse'
    { $sel:httpStatus:AdminDisableUserResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
adminDisableUserResponse_httpStatus :: Lens.Lens' AdminDisableUserResponse Prelude.Int
adminDisableUserResponse_httpStatus :: (Int -> f Int)
-> AdminDisableUserResponse -> f AdminDisableUserResponse
adminDisableUserResponse_httpStatus = (AdminDisableUserResponse -> Int)
-> (AdminDisableUserResponse -> Int -> AdminDisableUserResponse)
-> Lens AdminDisableUserResponse AdminDisableUserResponse Int Int
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