{-# 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.AlexaBusiness.DeleteUser
-- 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 specified user by user ARN and enrollment ARN.
module Amazonka.AlexaBusiness.DeleteUser
  ( -- * Creating a Request
    DeleteUser (..),
    newDeleteUser,

    -- * Request Lenses
    deleteUser_userArn,
    deleteUser_enrollmentId,

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

    -- * Response Lenses
    deleteUserResponse_httpStatus,
  )
where

import Amazonka.AlexaBusiness.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

-- | /See:/ 'newDeleteUser' smart constructor.
data DeleteUser = DeleteUser'
  { -- | The ARN of the user to delete in the organization. Required.
    DeleteUser -> Maybe Text
userArn :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the user\'s enrollment in the organization. Required.
    DeleteUser -> Text
enrollmentId :: Prelude.Text
  }
  deriving (DeleteUser -> DeleteUser -> Bool
(DeleteUser -> DeleteUser -> Bool)
-> (DeleteUser -> DeleteUser -> Bool) -> Eq DeleteUser
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]
(Int -> ReadS DeleteUser)
-> ReadS [DeleteUser]
-> ReadPrec DeleteUser
-> ReadPrec [DeleteUser]
-> Read 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
(Int -> DeleteUser -> ShowS)
-> (DeleteUser -> String)
-> ([DeleteUser] -> ShowS)
-> Show DeleteUser
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. DeleteUser -> Rep DeleteUser x)
-> (forall x. Rep DeleteUser x -> DeleteUser) -> Generic DeleteUser
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:
--
-- 'userArn', 'deleteUser_userArn' - The ARN of the user to delete in the organization. Required.
--
-- 'enrollmentId', 'deleteUser_enrollmentId' - The ARN of the user\'s enrollment in the organization. Required.
newDeleteUser ::
  -- | 'enrollmentId'
  Prelude.Text ->
  DeleteUser
newDeleteUser :: Text -> DeleteUser
newDeleteUser Text
pEnrollmentId_ =
  DeleteUser' :: Maybe Text -> Text -> DeleteUser
DeleteUser'
    { $sel:userArn:DeleteUser' :: Maybe Text
userArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:enrollmentId:DeleteUser' :: Text
enrollmentId = Text
pEnrollmentId_
    }

-- | The ARN of the user to delete in the organization. Required.
deleteUser_userArn :: Lens.Lens' DeleteUser (Prelude.Maybe Prelude.Text)
deleteUser_userArn :: (Maybe Text -> f (Maybe Text)) -> DeleteUser -> f DeleteUser
deleteUser_userArn = (DeleteUser -> Maybe Text)
-> (DeleteUser -> Maybe Text -> DeleteUser)
-> Lens DeleteUser DeleteUser (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUser' {Maybe Text
userArn :: Maybe Text
$sel:userArn:DeleteUser' :: DeleteUser -> Maybe Text
userArn} -> Maybe Text
userArn) (\s :: DeleteUser
s@DeleteUser' {} Maybe Text
a -> DeleteUser
s {$sel:userArn:DeleteUser' :: Maybe Text
userArn = Maybe Text
a} :: DeleteUser)

-- | The ARN of the user\'s enrollment in the organization. Required.
deleteUser_enrollmentId :: Lens.Lens' DeleteUser Prelude.Text
deleteUser_enrollmentId :: (Text -> f Text) -> DeleteUser -> f DeleteUser
deleteUser_enrollmentId = (DeleteUser -> Text)
-> (DeleteUser -> Text -> DeleteUser)
-> Lens DeleteUser DeleteUser Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUser' {Text
enrollmentId :: Text
$sel:enrollmentId:DeleteUser' :: DeleteUser -> Text
enrollmentId} -> Text
enrollmentId) (\s :: DeleteUser
s@DeleteUser' {} Text
a -> DeleteUser
s {$sel:enrollmentId:DeleteUser' :: Text
enrollmentId = Text
a} :: DeleteUser)

instance Core.AWSRequest DeleteUser where
  type AWSResponse DeleteUser = DeleteUserResponse
  request :: DeleteUser -> Request DeleteUser
request = Service -> DeleteUser -> Request DeleteUser
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteUser)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse DeleteUser))
-> Logger
-> Service
-> Proxy DeleteUser
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteUser)))
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 -> DeleteUserResponse
DeleteUserResponse'
            (Int -> DeleteUserResponse)
-> Either String Int -> Either String DeleteUserResponse
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 DeleteUser

instance Prelude.NFData DeleteUser

instance Core.ToHeaders DeleteUser where
  toHeaders :: DeleteUser -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteUser -> 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
"AlexaForBusiness.DeleteUser" ::
                          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 DeleteUser where
  toJSON :: DeleteUser -> Value
toJSON DeleteUser' {Maybe Text
Text
enrollmentId :: Text
userArn :: Maybe Text
$sel:enrollmentId:DeleteUser' :: DeleteUser -> Text
$sel:userArn:DeleteUser' :: DeleteUser -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"UserArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
userArn,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EnrollmentId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
enrollmentId)
          ]
      )

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

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

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