{-# 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.DeleteMailboxPermissions
-- 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 permissions granted to a member (user or group).
module Amazonka.WorkMail.DeleteMailboxPermissions
  ( -- * Creating a Request
    DeleteMailboxPermissions (..),
    newDeleteMailboxPermissions,

    -- * Request Lenses
    deleteMailboxPermissions_organizationId,
    deleteMailboxPermissions_entityId,
    deleteMailboxPermissions_granteeId,

    -- * Destructuring the Response
    DeleteMailboxPermissionsResponse (..),
    newDeleteMailboxPermissionsResponse,

    -- * Response Lenses
    deleteMailboxPermissionsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteMailboxPermissions' smart constructor.
data DeleteMailboxPermissions = DeleteMailboxPermissions'
  { -- | The identifier of the organization under which the member (user or
    -- group) exists.
    DeleteMailboxPermissions -> Text
organizationId :: Prelude.Text,
    -- | The identifier of the member (user or group) that owns the mailbox.
    DeleteMailboxPermissions -> Text
entityId :: Prelude.Text,
    -- | The identifier of the member (user or group) for which to delete granted
    -- permissions.
    DeleteMailboxPermissions -> Text
granteeId :: Prelude.Text
  }
  deriving (DeleteMailboxPermissions -> DeleteMailboxPermissions -> Bool
(DeleteMailboxPermissions -> DeleteMailboxPermissions -> Bool)
-> (DeleteMailboxPermissions -> DeleteMailboxPermissions -> Bool)
-> Eq DeleteMailboxPermissions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteMailboxPermissions -> DeleteMailboxPermissions -> Bool
$c/= :: DeleteMailboxPermissions -> DeleteMailboxPermissions -> Bool
== :: DeleteMailboxPermissions -> DeleteMailboxPermissions -> Bool
$c== :: DeleteMailboxPermissions -> DeleteMailboxPermissions -> Bool
Prelude.Eq, ReadPrec [DeleteMailboxPermissions]
ReadPrec DeleteMailboxPermissions
Int -> ReadS DeleteMailboxPermissions
ReadS [DeleteMailboxPermissions]
(Int -> ReadS DeleteMailboxPermissions)
-> ReadS [DeleteMailboxPermissions]
-> ReadPrec DeleteMailboxPermissions
-> ReadPrec [DeleteMailboxPermissions]
-> Read DeleteMailboxPermissions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteMailboxPermissions]
$creadListPrec :: ReadPrec [DeleteMailboxPermissions]
readPrec :: ReadPrec DeleteMailboxPermissions
$creadPrec :: ReadPrec DeleteMailboxPermissions
readList :: ReadS [DeleteMailboxPermissions]
$creadList :: ReadS [DeleteMailboxPermissions]
readsPrec :: Int -> ReadS DeleteMailboxPermissions
$creadsPrec :: Int -> ReadS DeleteMailboxPermissions
Prelude.Read, Int -> DeleteMailboxPermissions -> ShowS
[DeleteMailboxPermissions] -> ShowS
DeleteMailboxPermissions -> String
(Int -> DeleteMailboxPermissions -> ShowS)
-> (DeleteMailboxPermissions -> String)
-> ([DeleteMailboxPermissions] -> ShowS)
-> Show DeleteMailboxPermissions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteMailboxPermissions] -> ShowS
$cshowList :: [DeleteMailboxPermissions] -> ShowS
show :: DeleteMailboxPermissions -> String
$cshow :: DeleteMailboxPermissions -> String
showsPrec :: Int -> DeleteMailboxPermissions -> ShowS
$cshowsPrec :: Int -> DeleteMailboxPermissions -> ShowS
Prelude.Show, (forall x.
 DeleteMailboxPermissions -> Rep DeleteMailboxPermissions x)
-> (forall x.
    Rep DeleteMailboxPermissions x -> DeleteMailboxPermissions)
-> Generic DeleteMailboxPermissions
forall x.
Rep DeleteMailboxPermissions x -> DeleteMailboxPermissions
forall x.
DeleteMailboxPermissions -> Rep DeleteMailboxPermissions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteMailboxPermissions x -> DeleteMailboxPermissions
$cfrom :: forall x.
DeleteMailboxPermissions -> Rep DeleteMailboxPermissions x
Prelude.Generic)

-- |
-- Create a value of 'DeleteMailboxPermissions' 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', 'deleteMailboxPermissions_organizationId' - The identifier of the organization under which the member (user or
-- group) exists.
--
-- 'entityId', 'deleteMailboxPermissions_entityId' - The identifier of the member (user or group) that owns the mailbox.
--
-- 'granteeId', 'deleteMailboxPermissions_granteeId' - The identifier of the member (user or group) for which to delete granted
-- permissions.
newDeleteMailboxPermissions ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'entityId'
  Prelude.Text ->
  -- | 'granteeId'
  Prelude.Text ->
  DeleteMailboxPermissions
newDeleteMailboxPermissions :: Text -> Text -> Text -> DeleteMailboxPermissions
newDeleteMailboxPermissions
  Text
pOrganizationId_
  Text
pEntityId_
  Text
pGranteeId_ =
    DeleteMailboxPermissions' :: Text -> Text -> Text -> DeleteMailboxPermissions
DeleteMailboxPermissions'
      { $sel:organizationId:DeleteMailboxPermissions' :: Text
organizationId =
          Text
pOrganizationId_,
        $sel:entityId:DeleteMailboxPermissions' :: Text
entityId = Text
pEntityId_,
        $sel:granteeId:DeleteMailboxPermissions' :: Text
granteeId = Text
pGranteeId_
      }

-- | The identifier of the organization under which the member (user or
-- group) exists.
deleteMailboxPermissions_organizationId :: Lens.Lens' DeleteMailboxPermissions Prelude.Text
deleteMailboxPermissions_organizationId :: (Text -> f Text)
-> DeleteMailboxPermissions -> f DeleteMailboxPermissions
deleteMailboxPermissions_organizationId = (DeleteMailboxPermissions -> Text)
-> (DeleteMailboxPermissions -> Text -> DeleteMailboxPermissions)
-> Lens DeleteMailboxPermissions DeleteMailboxPermissions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMailboxPermissions' {Text
organizationId :: Text
$sel:organizationId:DeleteMailboxPermissions' :: DeleteMailboxPermissions -> Text
organizationId} -> Text
organizationId) (\s :: DeleteMailboxPermissions
s@DeleteMailboxPermissions' {} Text
a -> DeleteMailboxPermissions
s {$sel:organizationId:DeleteMailboxPermissions' :: Text
organizationId = Text
a} :: DeleteMailboxPermissions)

-- | The identifier of the member (user or group) that owns the mailbox.
deleteMailboxPermissions_entityId :: Lens.Lens' DeleteMailboxPermissions Prelude.Text
deleteMailboxPermissions_entityId :: (Text -> f Text)
-> DeleteMailboxPermissions -> f DeleteMailboxPermissions
deleteMailboxPermissions_entityId = (DeleteMailboxPermissions -> Text)
-> (DeleteMailboxPermissions -> Text -> DeleteMailboxPermissions)
-> Lens DeleteMailboxPermissions DeleteMailboxPermissions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMailboxPermissions' {Text
entityId :: Text
$sel:entityId:DeleteMailboxPermissions' :: DeleteMailboxPermissions -> Text
entityId} -> Text
entityId) (\s :: DeleteMailboxPermissions
s@DeleteMailboxPermissions' {} Text
a -> DeleteMailboxPermissions
s {$sel:entityId:DeleteMailboxPermissions' :: Text
entityId = Text
a} :: DeleteMailboxPermissions)

-- | The identifier of the member (user or group) for which to delete granted
-- permissions.
deleteMailboxPermissions_granteeId :: Lens.Lens' DeleteMailboxPermissions Prelude.Text
deleteMailboxPermissions_granteeId :: (Text -> f Text)
-> DeleteMailboxPermissions -> f DeleteMailboxPermissions
deleteMailboxPermissions_granteeId = (DeleteMailboxPermissions -> Text)
-> (DeleteMailboxPermissions -> Text -> DeleteMailboxPermissions)
-> Lens DeleteMailboxPermissions DeleteMailboxPermissions Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMailboxPermissions' {Text
granteeId :: Text
$sel:granteeId:DeleteMailboxPermissions' :: DeleteMailboxPermissions -> Text
granteeId} -> Text
granteeId) (\s :: DeleteMailboxPermissions
s@DeleteMailboxPermissions' {} Text
a -> DeleteMailboxPermissions
s {$sel:granteeId:DeleteMailboxPermissions' :: Text
granteeId = Text
a} :: DeleteMailboxPermissions)

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

instance Prelude.NFData DeleteMailboxPermissions

instance Core.ToHeaders DeleteMailboxPermissions where
  toHeaders :: DeleteMailboxPermissions -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteMailboxPermissions -> 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
"WorkMailService.DeleteMailboxPermissions" ::
                          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 DeleteMailboxPermissions where
  toJSON :: DeleteMailboxPermissions -> Value
toJSON DeleteMailboxPermissions' {Text
granteeId :: Text
entityId :: Text
organizationId :: Text
$sel:granteeId:DeleteMailboxPermissions' :: DeleteMailboxPermissions -> Text
$sel:entityId:DeleteMailboxPermissions' :: DeleteMailboxPermissions -> Text
$sel:organizationId:DeleteMailboxPermissions' :: DeleteMailboxPermissions -> 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
"OrganizationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
organizationId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EntityId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
entityId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GranteeId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
granteeId)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    DeleteMailboxPermissionsResponse