{-# 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.WorkMail.DeleteUser
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a user from WorkMail and all subsequent systems. Before you can
-- delete a user, the user state must be @DISABLED@. Use the DescribeUser
-- action to confirm the user state.
--
-- Deleting a user is permanent and cannot be undone. WorkMail archives
-- user mailboxes for 30 days before they are permanently removed.
module Amazonka.WorkMail.DeleteUser
  ( -- * Creating a Request
    DeleteUser (..),
    newDeleteUser,

    -- * Request Lenses
    deleteUser_organizationId,
    deleteUser_userId,

    -- * Destructuring the Response
    DeleteUserResponse (..),
    newDeleteUserResponse,

    -- * Response Lenses
    deleteUserResponse_httpStatus,
  )
where

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
import Amazonka.WorkMail.Types

-- | /See:/ 'newDeleteUser' smart constructor.
data DeleteUser = DeleteUser'
  { -- | The organization that contains the user to be deleted.
    DeleteUser -> Text
organizationId :: Prelude.Text,
    -- | The identifier of the user to be deleted.
    DeleteUser -> Text
userId :: Prelude.Text
  }
  deriving (DeleteUser -> DeleteUser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteUser -> DeleteUser -> Bool
$c/= :: DeleteUser -> DeleteUser -> Bool
== :: DeleteUser -> DeleteUser -> Bool
$c== :: DeleteUser -> DeleteUser -> Bool
Prelude.Eq, ReadPrec [DeleteUser]
ReadPrec DeleteUser
Int -> ReadS DeleteUser
ReadS [DeleteUser]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteUser]
$creadListPrec :: ReadPrec [DeleteUser]
readPrec :: ReadPrec DeleteUser
$creadPrec :: ReadPrec DeleteUser
readList :: ReadS [DeleteUser]
$creadList :: ReadS [DeleteUser]
readsPrec :: Int -> ReadS DeleteUser
$creadsPrec :: Int -> ReadS DeleteUser
Prelude.Read, Int -> DeleteUser -> ShowS
[DeleteUser] -> ShowS
DeleteUser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteUser] -> ShowS
$cshowList :: [DeleteUser] -> ShowS
show :: DeleteUser -> String
$cshow :: DeleteUser -> String
showsPrec :: Int -> DeleteUser -> ShowS
$cshowsPrec :: Int -> DeleteUser -> ShowS
Prelude.Show, forall x. Rep DeleteUser x -> DeleteUser
forall x. DeleteUser -> Rep DeleteUser x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteUser x -> DeleteUser
$cfrom :: forall x. DeleteUser -> Rep DeleteUser x
Prelude.Generic)

-- |
-- Create a value of 'DeleteUser' 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:
--
-- 'organizationId', 'deleteUser_organizationId' - The organization that contains the user to be deleted.
--
-- 'userId', 'deleteUser_userId' - The identifier of the user to be deleted.
newDeleteUser ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'userId'
  Prelude.Text ->
  DeleteUser
newDeleteUser :: Text -> Text -> DeleteUser
newDeleteUser Text
pOrganizationId_ Text
pUserId_ =
  DeleteUser'
    { $sel:organizationId:DeleteUser' :: Text
organizationId = Text
pOrganizationId_,
      $sel:userId:DeleteUser' :: Text
userId = Text
pUserId_
    }

-- | The organization that contains the user to be deleted.
deleteUser_organizationId :: Lens.Lens' DeleteUser Prelude.Text
deleteUser_organizationId :: Lens' DeleteUser Text
deleteUser_organizationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUser' {Text
organizationId :: Text
$sel:organizationId:DeleteUser' :: DeleteUser -> Text
organizationId} -> Text
organizationId) (\s :: DeleteUser
s@DeleteUser' {} Text
a -> DeleteUser
s {$sel:organizationId:DeleteUser' :: Text
organizationId = Text
a} :: DeleteUser)

-- | The identifier of the user to be deleted.
deleteUser_userId :: Lens.Lens' DeleteUser Prelude.Text
deleteUser_userId :: Lens' DeleteUser Text
deleteUser_userId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUser' {Text
userId :: Text
$sel:userId:DeleteUser' :: DeleteUser -> Text
userId} -> Text
userId) (\s :: DeleteUser
s@DeleteUser' {} Text
a -> DeleteUser
s {$sel:userId:DeleteUser' :: Text
userId = Text
a} :: DeleteUser)

instance Core.AWSRequest DeleteUser where
  type AWSResponse DeleteUser = DeleteUserResponse
  request :: (Service -> Service) -> DeleteUser -> Request DeleteUser
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 DeleteUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteUser)))
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 -> DeleteUserResponse
DeleteUserResponse'
            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 DeleteUser where
  hashWithSalt :: Int -> DeleteUser -> Int
hashWithSalt Int
_salt DeleteUser' {Text
userId :: Text
organizationId :: Text
$sel:userId:DeleteUser' :: DeleteUser -> Text
$sel:organizationId:DeleteUser' :: DeleteUser -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
organizationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userId

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

instance Data.ToHeaders DeleteUser where
  toHeaders :: DeleteUser -> 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
"WorkMailService.DeleteUser" :: 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 DeleteUser where
  toJSON :: DeleteUser -> Value
toJSON DeleteUser' {Text
userId :: Text
organizationId :: Text
$sel:userId:DeleteUser' :: DeleteUser -> Text
$sel:organizationId:DeleteUser' :: DeleteUser -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"OrganizationId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
organizationId),
            forall a. a -> Maybe a
Prelude.Just (Key
"UserId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
userId)
          ]
      )

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

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

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

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

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

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