{-# 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.DisassociateDelegateFromResource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes a member from the resource\'s set of delegates.
module Amazonka.WorkMail.DisassociateDelegateFromResource
  ( -- * Creating a Request
    DisassociateDelegateFromResource (..),
    newDisassociateDelegateFromResource,

    -- * Request Lenses
    disassociateDelegateFromResource_organizationId,
    disassociateDelegateFromResource_resourceId,
    disassociateDelegateFromResource_entityId,

    -- * Destructuring the Response
    DisassociateDelegateFromResourceResponse (..),
    newDisassociateDelegateFromResourceResponse,

    -- * Response Lenses
    disassociateDelegateFromResourceResponse_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:/ 'newDisassociateDelegateFromResource' smart constructor.
data DisassociateDelegateFromResource = DisassociateDelegateFromResource'
  { -- | The identifier for the organization under which the resource exists.
    DisassociateDelegateFromResource -> Text
organizationId :: Prelude.Text,
    -- | The identifier of the resource from which delegates\' set members are
    -- removed.
    DisassociateDelegateFromResource -> Text
resourceId :: Prelude.Text,
    -- | The identifier for the member (user, group) to be removed from the
    -- resource\'s delegates.
    DisassociateDelegateFromResource -> Text
entityId :: Prelude.Text
  }
  deriving (DisassociateDelegateFromResource
-> DisassociateDelegateFromResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateDelegateFromResource
-> DisassociateDelegateFromResource -> Bool
$c/= :: DisassociateDelegateFromResource
-> DisassociateDelegateFromResource -> Bool
== :: DisassociateDelegateFromResource
-> DisassociateDelegateFromResource -> Bool
$c== :: DisassociateDelegateFromResource
-> DisassociateDelegateFromResource -> Bool
Prelude.Eq, ReadPrec [DisassociateDelegateFromResource]
ReadPrec DisassociateDelegateFromResource
Int -> ReadS DisassociateDelegateFromResource
ReadS [DisassociateDelegateFromResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateDelegateFromResource]
$creadListPrec :: ReadPrec [DisassociateDelegateFromResource]
readPrec :: ReadPrec DisassociateDelegateFromResource
$creadPrec :: ReadPrec DisassociateDelegateFromResource
readList :: ReadS [DisassociateDelegateFromResource]
$creadList :: ReadS [DisassociateDelegateFromResource]
readsPrec :: Int -> ReadS DisassociateDelegateFromResource
$creadsPrec :: Int -> ReadS DisassociateDelegateFromResource
Prelude.Read, Int -> DisassociateDelegateFromResource -> ShowS
[DisassociateDelegateFromResource] -> ShowS
DisassociateDelegateFromResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateDelegateFromResource] -> ShowS
$cshowList :: [DisassociateDelegateFromResource] -> ShowS
show :: DisassociateDelegateFromResource -> String
$cshow :: DisassociateDelegateFromResource -> String
showsPrec :: Int -> DisassociateDelegateFromResource -> ShowS
$cshowsPrec :: Int -> DisassociateDelegateFromResource -> ShowS
Prelude.Show, forall x.
Rep DisassociateDelegateFromResource x
-> DisassociateDelegateFromResource
forall x.
DisassociateDelegateFromResource
-> Rep DisassociateDelegateFromResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DisassociateDelegateFromResource x
-> DisassociateDelegateFromResource
$cfrom :: forall x.
DisassociateDelegateFromResource
-> Rep DisassociateDelegateFromResource x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateDelegateFromResource' 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', 'disassociateDelegateFromResource_organizationId' - The identifier for the organization under which the resource exists.
--
-- 'resourceId', 'disassociateDelegateFromResource_resourceId' - The identifier of the resource from which delegates\' set members are
-- removed.
--
-- 'entityId', 'disassociateDelegateFromResource_entityId' - The identifier for the member (user, group) to be removed from the
-- resource\'s delegates.
newDisassociateDelegateFromResource ::
  -- | 'organizationId'
  Prelude.Text ->
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'entityId'
  Prelude.Text ->
  DisassociateDelegateFromResource
newDisassociateDelegateFromResource :: Text -> Text -> Text -> DisassociateDelegateFromResource
newDisassociateDelegateFromResource
  Text
pOrganizationId_
  Text
pResourceId_
  Text
pEntityId_ =
    DisassociateDelegateFromResource'
      { $sel:organizationId:DisassociateDelegateFromResource' :: Text
organizationId =
          Text
pOrganizationId_,
        $sel:resourceId:DisassociateDelegateFromResource' :: Text
resourceId = Text
pResourceId_,
        $sel:entityId:DisassociateDelegateFromResource' :: Text
entityId = Text
pEntityId_
      }

-- | The identifier for the organization under which the resource exists.
disassociateDelegateFromResource_organizationId :: Lens.Lens' DisassociateDelegateFromResource Prelude.Text
disassociateDelegateFromResource_organizationId :: Lens' DisassociateDelegateFromResource Text
disassociateDelegateFromResource_organizationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateDelegateFromResource' {Text
organizationId :: Text
$sel:organizationId:DisassociateDelegateFromResource' :: DisassociateDelegateFromResource -> Text
organizationId} -> Text
organizationId) (\s :: DisassociateDelegateFromResource
s@DisassociateDelegateFromResource' {} Text
a -> DisassociateDelegateFromResource
s {$sel:organizationId:DisassociateDelegateFromResource' :: Text
organizationId = Text
a} :: DisassociateDelegateFromResource)

-- | The identifier of the resource from which delegates\' set members are
-- removed.
disassociateDelegateFromResource_resourceId :: Lens.Lens' DisassociateDelegateFromResource Prelude.Text
disassociateDelegateFromResource_resourceId :: Lens' DisassociateDelegateFromResource Text
disassociateDelegateFromResource_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateDelegateFromResource' {Text
resourceId :: Text
$sel:resourceId:DisassociateDelegateFromResource' :: DisassociateDelegateFromResource -> Text
resourceId} -> Text
resourceId) (\s :: DisassociateDelegateFromResource
s@DisassociateDelegateFromResource' {} Text
a -> DisassociateDelegateFromResource
s {$sel:resourceId:DisassociateDelegateFromResource' :: Text
resourceId = Text
a} :: DisassociateDelegateFromResource)

-- | The identifier for the member (user, group) to be removed from the
-- resource\'s delegates.
disassociateDelegateFromResource_entityId :: Lens.Lens' DisassociateDelegateFromResource Prelude.Text
disassociateDelegateFromResource_entityId :: Lens' DisassociateDelegateFromResource Text
disassociateDelegateFromResource_entityId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateDelegateFromResource' {Text
entityId :: Text
$sel:entityId:DisassociateDelegateFromResource' :: DisassociateDelegateFromResource -> Text
entityId} -> Text
entityId) (\s :: DisassociateDelegateFromResource
s@DisassociateDelegateFromResource' {} Text
a -> DisassociateDelegateFromResource
s {$sel:entityId:DisassociateDelegateFromResource' :: Text
entityId = Text
a} :: DisassociateDelegateFromResource)

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

instance
  Prelude.NFData
    DisassociateDelegateFromResource
  where
  rnf :: DisassociateDelegateFromResource -> ()
rnf DisassociateDelegateFromResource' {Text
entityId :: Text
resourceId :: Text
organizationId :: Text
$sel:entityId:DisassociateDelegateFromResource' :: DisassociateDelegateFromResource -> Text
$sel:resourceId:DisassociateDelegateFromResource' :: DisassociateDelegateFromResource -> Text
$sel:organizationId:DisassociateDelegateFromResource' :: DisassociateDelegateFromResource -> 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
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
entityId

instance
  Data.ToHeaders
    DisassociateDelegateFromResource
  where
  toHeaders :: DisassociateDelegateFromResource -> 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.DisassociateDelegateFromResource" ::
                          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 DisassociateDelegateFromResource where
  toJSON :: DisassociateDelegateFromResource -> Value
toJSON DisassociateDelegateFromResource' {Text
entityId :: Text
resourceId :: Text
organizationId :: Text
$sel:entityId:DisassociateDelegateFromResource' :: DisassociateDelegateFromResource -> Text
$sel:resourceId:DisassociateDelegateFromResource' :: DisassociateDelegateFromResource -> Text
$sel:organizationId:DisassociateDelegateFromResource' :: DisassociateDelegateFromResource -> 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
"ResourceId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceId),
            forall a. a -> Maybe a
Prelude.Just (Key
"EntityId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
entityId)
          ]
      )

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

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

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

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

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

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