{-# 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-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)
--
-- 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.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:/ '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
(DisassociateDelegateFromResource
 -> DisassociateDelegateFromResource -> Bool)
-> (DisassociateDelegateFromResource
    -> DisassociateDelegateFromResource -> Bool)
-> Eq DisassociateDelegateFromResource
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]
(Int -> ReadS DisassociateDelegateFromResource)
-> ReadS [DisassociateDelegateFromResource]
-> ReadPrec DisassociateDelegateFromResource
-> ReadPrec [DisassociateDelegateFromResource]
-> Read 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
(Int -> DisassociateDelegateFromResource -> ShowS)
-> (DisassociateDelegateFromResource -> String)
-> ([DisassociateDelegateFromResource] -> ShowS)
-> Show DisassociateDelegateFromResource
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.
 DisassociateDelegateFromResource
 -> Rep DisassociateDelegateFromResource x)
-> (forall x.
    Rep DisassociateDelegateFromResource x
    -> DisassociateDelegateFromResource)
-> Generic DisassociateDelegateFromResource
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' :: Text -> Text -> Text -> DisassociateDelegateFromResource
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 :: (Text -> f Text)
-> DisassociateDelegateFromResource
-> f DisassociateDelegateFromResource
disassociateDelegateFromResource_organizationId = (DisassociateDelegateFromResource -> Text)
-> (DisassociateDelegateFromResource
    -> Text -> DisassociateDelegateFromResource)
-> Lens
     DisassociateDelegateFromResource
     DisassociateDelegateFromResource
     Text
     Text
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 :: (Text -> f Text)
-> DisassociateDelegateFromResource
-> f DisassociateDelegateFromResource
disassociateDelegateFromResource_resourceId = (DisassociateDelegateFromResource -> Text)
-> (DisassociateDelegateFromResource
    -> Text -> DisassociateDelegateFromResource)
-> Lens
     DisassociateDelegateFromResource
     DisassociateDelegateFromResource
     Text
     Text
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 :: (Text -> f Text)
-> DisassociateDelegateFromResource
-> f DisassociateDelegateFromResource
disassociateDelegateFromResource_entityId = (DisassociateDelegateFromResource -> Text)
-> (DisassociateDelegateFromResource
    -> Text -> DisassociateDelegateFromResource)
-> Lens
     DisassociateDelegateFromResource
     DisassociateDelegateFromResource
     Text
     Text
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 :: DisassociateDelegateFromResource
-> Request DisassociateDelegateFromResource
request = Service
-> DisassociateDelegateFromResource
-> Request DisassociateDelegateFromResource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisassociateDelegateFromResource
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DisassociateDelegateFromResource)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DisassociateDelegateFromResource))
-> Logger
-> Service
-> Proxy DisassociateDelegateFromResource
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DisassociateDelegateFromResource)))
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 -> DisassociateDelegateFromResourceResponse
DisassociateDelegateFromResourceResponse'
            (Int -> DisassociateDelegateFromResourceResponse)
-> Either String Int
-> Either String DisassociateDelegateFromResourceResponse
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
    DisassociateDelegateFromResource

instance
  Prelude.NFData
    DisassociateDelegateFromResource

instance
  Core.ToHeaders
    DisassociateDelegateFromResource
  where
  toHeaders :: DisassociateDelegateFromResource -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> DisassociateDelegateFromResource -> 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.DisassociateDelegateFromResource" ::
                          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 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
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
"ResourceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceId),
            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)
          ]
      )

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

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

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