{-# 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.FinSpaceData.DisableUser
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Denies access to the FinSpace web application and API for the specified
-- user.
module Amazonka.FinSpaceData.DisableUser
  ( -- * Creating a Request
    DisableUser (..),
    newDisableUser,

    -- * Request Lenses
    disableUser_clientToken,
    disableUser_userId,

    -- * Destructuring the Response
    DisableUserResponse (..),
    newDisableUserResponse,

    -- * Response Lenses
    disableUserResponse_userId,
    disableUserResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDisableUser' smart constructor.
data DisableUser = DisableUser'
  { -- | A token that ensures idempotency. This token expires in 10 minutes.
    DisableUser -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier for the user account that you want to disable.
    DisableUser -> Text
userId :: Prelude.Text
  }
  deriving (DisableUser -> DisableUser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableUser -> DisableUser -> Bool
$c/= :: DisableUser -> DisableUser -> Bool
== :: DisableUser -> DisableUser -> Bool
$c== :: DisableUser -> DisableUser -> Bool
Prelude.Eq, ReadPrec [DisableUser]
ReadPrec DisableUser
Int -> ReadS DisableUser
ReadS [DisableUser]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableUser]
$creadListPrec :: ReadPrec [DisableUser]
readPrec :: ReadPrec DisableUser
$creadPrec :: ReadPrec DisableUser
readList :: ReadS [DisableUser]
$creadList :: ReadS [DisableUser]
readsPrec :: Int -> ReadS DisableUser
$creadsPrec :: Int -> ReadS DisableUser
Prelude.Read, Int -> DisableUser -> ShowS
[DisableUser] -> ShowS
DisableUser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableUser] -> ShowS
$cshowList :: [DisableUser] -> ShowS
show :: DisableUser -> String
$cshow :: DisableUser -> String
showsPrec :: Int -> DisableUser -> ShowS
$cshowsPrec :: Int -> DisableUser -> ShowS
Prelude.Show, forall x. Rep DisableUser x -> DisableUser
forall x. DisableUser -> Rep DisableUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableUser x -> DisableUser
$cfrom :: forall x. DisableUser -> Rep DisableUser x
Prelude.Generic)

-- |
-- Create a value of 'DisableUser' 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:
--
-- 'clientToken', 'disableUser_clientToken' - A token that ensures idempotency. This token expires in 10 minutes.
--
-- 'userId', 'disableUser_userId' - The unique identifier for the user account that you want to disable.
newDisableUser ::
  -- | 'userId'
  Prelude.Text ->
  DisableUser
newDisableUser :: Text -> DisableUser
newDisableUser Text
pUserId_ =
  DisableUser'
    { $sel:clientToken:DisableUser' :: Maybe Text
clientToken = forall a. Maybe a
Prelude.Nothing,
      $sel:userId:DisableUser' :: Text
userId = Text
pUserId_
    }

-- | A token that ensures idempotency. This token expires in 10 minutes.
disableUser_clientToken :: Lens.Lens' DisableUser (Prelude.Maybe Prelude.Text)
disableUser_clientToken :: Lens' DisableUser (Maybe Text)
disableUser_clientToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableUser' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:DisableUser' :: DisableUser -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: DisableUser
s@DisableUser' {} Maybe Text
a -> DisableUser
s {$sel:clientToken:DisableUser' :: Maybe Text
clientToken = Maybe Text
a} :: DisableUser)

-- | The unique identifier for the user account that you want to disable.
disableUser_userId :: Lens.Lens' DisableUser Prelude.Text
disableUser_userId :: Lens' DisableUser Text
disableUser_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableUser' {Text
userId :: Text
$sel:userId:DisableUser' :: DisableUser -> Text
userId} -> Text
userId) (\s :: DisableUser
s@DisableUser' {} Text
a -> DisableUser
s {$sel:userId:DisableUser' :: Text
userId = Text
a} :: DisableUser)

instance Core.AWSRequest DisableUser where
  type AWSResponse DisableUser = DisableUserResponse
  request :: (Service -> Service) -> DisableUser -> Request DisableUser
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 DisableUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DisableUser)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> DisableUserResponse
DisableUserResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"userId")
            forall (f :: * -> *) a b. Applicative f => 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 DisableUser where
  hashWithSalt :: Int -> DisableUser -> Int
hashWithSalt Int
_salt DisableUser' {Maybe Text
Text
userId :: Text
clientToken :: Maybe Text
$sel:userId:DisableUser' :: DisableUser -> Text
$sel:clientToken:DisableUser' :: DisableUser -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clientToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userId

instance Prelude.NFData DisableUser where
  rnf :: DisableUser -> ()
rnf DisableUser' {Maybe Text
Text
userId :: Text
clientToken :: Maybe Text
$sel:userId:DisableUser' :: DisableUser -> Text
$sel:clientToken:DisableUser' :: DisableUser -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clientToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userId

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

instance Data.ToJSON DisableUser where
  toJSON :: DisableUser -> Value
toJSON DisableUser' {Maybe Text
Text
userId :: Text
clientToken :: Maybe Text
$sel:userId:DisableUser' :: DisableUser -> Text
$sel:clientToken:DisableUser' :: DisableUser -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"clientToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
clientToken]
      )

instance Data.ToPath DisableUser where
  toPath :: DisableUser -> ByteString
toPath DisableUser' {Maybe Text
Text
userId :: Text
clientToken :: Maybe Text
$sel:userId:DisableUser' :: DisableUser -> Text
$sel:clientToken:DisableUser' :: DisableUser -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/user/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
userId, ByteString
"/disable"]

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

-- | /See:/ 'newDisableUserResponse' smart constructor.
data DisableUserResponse = DisableUserResponse'
  { -- | The unique identifier for the disabled user account.
    DisableUserResponse -> Maybe Text
userId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DisableUserResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DisableUserResponse -> DisableUserResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisableUserResponse -> DisableUserResponse -> Bool
$c/= :: DisableUserResponse -> DisableUserResponse -> Bool
== :: DisableUserResponse -> DisableUserResponse -> Bool
$c== :: DisableUserResponse -> DisableUserResponse -> Bool
Prelude.Eq, ReadPrec [DisableUserResponse]
ReadPrec DisableUserResponse
Int -> ReadS DisableUserResponse
ReadS [DisableUserResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisableUserResponse]
$creadListPrec :: ReadPrec [DisableUserResponse]
readPrec :: ReadPrec DisableUserResponse
$creadPrec :: ReadPrec DisableUserResponse
readList :: ReadS [DisableUserResponse]
$creadList :: ReadS [DisableUserResponse]
readsPrec :: Int -> ReadS DisableUserResponse
$creadsPrec :: Int -> ReadS DisableUserResponse
Prelude.Read, Int -> DisableUserResponse -> ShowS
[DisableUserResponse] -> ShowS
DisableUserResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisableUserResponse] -> ShowS
$cshowList :: [DisableUserResponse] -> ShowS
show :: DisableUserResponse -> String
$cshow :: DisableUserResponse -> String
showsPrec :: Int -> DisableUserResponse -> ShowS
$cshowsPrec :: Int -> DisableUserResponse -> ShowS
Prelude.Show, forall x. Rep DisableUserResponse x -> DisableUserResponse
forall x. DisableUserResponse -> Rep DisableUserResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisableUserResponse x -> DisableUserResponse
$cfrom :: forall x. DisableUserResponse -> Rep DisableUserResponse x
Prelude.Generic)

-- |
-- Create a value of 'DisableUserResponse' 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:
--
-- 'userId', 'disableUserResponse_userId' - The unique identifier for the disabled user account.
--
-- 'httpStatus', 'disableUserResponse_httpStatus' - The response's http status code.
newDisableUserResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DisableUserResponse
newDisableUserResponse :: Int -> DisableUserResponse
newDisableUserResponse Int
pHttpStatus_ =
  DisableUserResponse'
    { $sel:userId:DisableUserResponse' :: Maybe Text
userId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DisableUserResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique identifier for the disabled user account.
disableUserResponse_userId :: Lens.Lens' DisableUserResponse (Prelude.Maybe Prelude.Text)
disableUserResponse_userId :: Lens' DisableUserResponse (Maybe Text)
disableUserResponse_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisableUserResponse' {Maybe Text
userId :: Maybe Text
$sel:userId:DisableUserResponse' :: DisableUserResponse -> Maybe Text
userId} -> Maybe Text
userId) (\s :: DisableUserResponse
s@DisableUserResponse' {} Maybe Text
a -> DisableUserResponse
s {$sel:userId:DisableUserResponse' :: Maybe Text
userId = Maybe Text
a} :: DisableUserResponse)

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

instance Prelude.NFData DisableUserResponse where
  rnf :: DisableUserResponse -> ()
rnf DisableUserResponse' {Int
Maybe Text
httpStatus :: Int
userId :: Maybe Text
$sel:httpStatus:DisableUserResponse' :: DisableUserResponse -> Int
$sel:userId:DisableUserResponse' :: DisableUserResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus