{-# 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.WorkDocs.RemoveResourcePermission
-- 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 the permission for the specified principal from the specified
-- resource.
module Amazonka.WorkDocs.RemoveResourcePermission
  ( -- * Creating a Request
    RemoveResourcePermission (..),
    newRemoveResourcePermission,

    -- * Request Lenses
    removeResourcePermission_principalType,
    removeResourcePermission_authenticationToken,
    removeResourcePermission_resourceId,
    removeResourcePermission_principalId,

    -- * Destructuring the Response
    RemoveResourcePermissionResponse (..),
    newRemoveResourcePermissionResponse,
  )
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.WorkDocs.Types

-- | /See:/ 'newRemoveResourcePermission' smart constructor.
data RemoveResourcePermission = RemoveResourcePermission'
  { -- | The principal type of the resource.
    RemoveResourcePermission -> Maybe PrincipalType
principalType :: Prelude.Maybe PrincipalType,
    -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    RemoveResourcePermission -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The ID of the resource.
    RemoveResourcePermission -> Text
resourceId :: Prelude.Text,
    -- | The principal ID of the resource.
    RemoveResourcePermission -> Text
principalId :: Prelude.Text
  }
  deriving (RemoveResourcePermission -> RemoveResourcePermission -> Bool
(RemoveResourcePermission -> RemoveResourcePermission -> Bool)
-> (RemoveResourcePermission -> RemoveResourcePermission -> Bool)
-> Eq RemoveResourcePermission
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveResourcePermission -> RemoveResourcePermission -> Bool
$c/= :: RemoveResourcePermission -> RemoveResourcePermission -> Bool
== :: RemoveResourcePermission -> RemoveResourcePermission -> Bool
$c== :: RemoveResourcePermission -> RemoveResourcePermission -> Bool
Prelude.Eq, Int -> RemoveResourcePermission -> ShowS
[RemoveResourcePermission] -> ShowS
RemoveResourcePermission -> String
(Int -> RemoveResourcePermission -> ShowS)
-> (RemoveResourcePermission -> String)
-> ([RemoveResourcePermission] -> ShowS)
-> Show RemoveResourcePermission
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveResourcePermission] -> ShowS
$cshowList :: [RemoveResourcePermission] -> ShowS
show :: RemoveResourcePermission -> String
$cshow :: RemoveResourcePermission -> String
showsPrec :: Int -> RemoveResourcePermission -> ShowS
$cshowsPrec :: Int -> RemoveResourcePermission -> ShowS
Prelude.Show, (forall x.
 RemoveResourcePermission -> Rep RemoveResourcePermission x)
-> (forall x.
    Rep RemoveResourcePermission x -> RemoveResourcePermission)
-> Generic RemoveResourcePermission
forall x.
Rep RemoveResourcePermission x -> RemoveResourcePermission
forall x.
RemoveResourcePermission -> Rep RemoveResourcePermission x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemoveResourcePermission x -> RemoveResourcePermission
$cfrom :: forall x.
RemoveResourcePermission -> Rep RemoveResourcePermission x
Prelude.Generic)

-- |
-- Create a value of 'RemoveResourcePermission' 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:
--
-- 'principalType', 'removeResourcePermission_principalType' - The principal type of the resource.
--
-- 'authenticationToken', 'removeResourcePermission_authenticationToken' - Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
--
-- 'resourceId', 'removeResourcePermission_resourceId' - The ID of the resource.
--
-- 'principalId', 'removeResourcePermission_principalId' - The principal ID of the resource.
newRemoveResourcePermission ::
  -- | 'resourceId'
  Prelude.Text ->
  -- | 'principalId'
  Prelude.Text ->
  RemoveResourcePermission
newRemoveResourcePermission :: Text -> Text -> RemoveResourcePermission
newRemoveResourcePermission
  Text
pResourceId_
  Text
pPrincipalId_ =
    RemoveResourcePermission' :: Maybe PrincipalType
-> Maybe (Sensitive Text)
-> Text
-> Text
-> RemoveResourcePermission
RemoveResourcePermission'
      { $sel:principalType:RemoveResourcePermission' :: Maybe PrincipalType
principalType =
          Maybe PrincipalType
forall a. Maybe a
Prelude.Nothing,
        $sel:authenticationToken:RemoveResourcePermission' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:resourceId:RemoveResourcePermission' :: Text
resourceId = Text
pResourceId_,
        $sel:principalId:RemoveResourcePermission' :: Text
principalId = Text
pPrincipalId_
      }

-- | The principal type of the resource.
removeResourcePermission_principalType :: Lens.Lens' RemoveResourcePermission (Prelude.Maybe PrincipalType)
removeResourcePermission_principalType :: (Maybe PrincipalType -> f (Maybe PrincipalType))
-> RemoveResourcePermission -> f RemoveResourcePermission
removeResourcePermission_principalType = (RemoveResourcePermission -> Maybe PrincipalType)
-> (RemoveResourcePermission
    -> Maybe PrincipalType -> RemoveResourcePermission)
-> Lens
     RemoveResourcePermission
     RemoveResourcePermission
     (Maybe PrincipalType)
     (Maybe PrincipalType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveResourcePermission' {Maybe PrincipalType
principalType :: Maybe PrincipalType
$sel:principalType:RemoveResourcePermission' :: RemoveResourcePermission -> Maybe PrincipalType
principalType} -> Maybe PrincipalType
principalType) (\s :: RemoveResourcePermission
s@RemoveResourcePermission' {} Maybe PrincipalType
a -> RemoveResourcePermission
s {$sel:principalType:RemoveResourcePermission' :: Maybe PrincipalType
principalType = Maybe PrincipalType
a} :: RemoveResourcePermission)

-- | Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
removeResourcePermission_authenticationToken :: Lens.Lens' RemoveResourcePermission (Prelude.Maybe Prelude.Text)
removeResourcePermission_authenticationToken :: (Maybe Text -> f (Maybe Text))
-> RemoveResourcePermission -> f RemoveResourcePermission
removeResourcePermission_authenticationToken = (RemoveResourcePermission -> Maybe (Sensitive Text))
-> (RemoveResourcePermission
    -> Maybe (Sensitive Text) -> RemoveResourcePermission)
-> Lens
     RemoveResourcePermission
     RemoveResourcePermission
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveResourcePermission' {Maybe (Sensitive Text)
authenticationToken :: Maybe (Sensitive Text)
$sel:authenticationToken:RemoveResourcePermission' :: RemoveResourcePermission -> Maybe (Sensitive Text)
authenticationToken} -> Maybe (Sensitive Text)
authenticationToken) (\s :: RemoveResourcePermission
s@RemoveResourcePermission' {} Maybe (Sensitive Text)
a -> RemoveResourcePermission
s {$sel:authenticationToken:RemoveResourcePermission' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
a} :: RemoveResourcePermission) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> RemoveResourcePermission -> f RemoveResourcePermission)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> RemoveResourcePermission
-> f RemoveResourcePermission
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The ID of the resource.
removeResourcePermission_resourceId :: Lens.Lens' RemoveResourcePermission Prelude.Text
removeResourcePermission_resourceId :: (Text -> f Text)
-> RemoveResourcePermission -> f RemoveResourcePermission
removeResourcePermission_resourceId = (RemoveResourcePermission -> Text)
-> (RemoveResourcePermission -> Text -> RemoveResourcePermission)
-> Lens RemoveResourcePermission RemoveResourcePermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveResourcePermission' {Text
resourceId :: Text
$sel:resourceId:RemoveResourcePermission' :: RemoveResourcePermission -> Text
resourceId} -> Text
resourceId) (\s :: RemoveResourcePermission
s@RemoveResourcePermission' {} Text
a -> RemoveResourcePermission
s {$sel:resourceId:RemoveResourcePermission' :: Text
resourceId = Text
a} :: RemoveResourcePermission)

-- | The principal ID of the resource.
removeResourcePermission_principalId :: Lens.Lens' RemoveResourcePermission Prelude.Text
removeResourcePermission_principalId :: (Text -> f Text)
-> RemoveResourcePermission -> f RemoveResourcePermission
removeResourcePermission_principalId = (RemoveResourcePermission -> Text)
-> (RemoveResourcePermission -> Text -> RemoveResourcePermission)
-> Lens RemoveResourcePermission RemoveResourcePermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveResourcePermission' {Text
principalId :: Text
$sel:principalId:RemoveResourcePermission' :: RemoveResourcePermission -> Text
principalId} -> Text
principalId) (\s :: RemoveResourcePermission
s@RemoveResourcePermission' {} Text
a -> RemoveResourcePermission
s {$sel:principalId:RemoveResourcePermission' :: Text
principalId = Text
a} :: RemoveResourcePermission)

instance Core.AWSRequest RemoveResourcePermission where
  type
    AWSResponse RemoveResourcePermission =
      RemoveResourcePermissionResponse
  request :: RemoveResourcePermission -> Request RemoveResourcePermission
request = Service
-> RemoveResourcePermission -> Request RemoveResourcePermission
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy RemoveResourcePermission
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveResourcePermission)))
response =
    AWSResponse RemoveResourcePermission
-> Logger
-> Service
-> Proxy RemoveResourcePermission
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveResourcePermission)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse RemoveResourcePermission
RemoveResourcePermissionResponse
RemoveResourcePermissionResponse'

instance Prelude.Hashable RemoveResourcePermission

instance Prelude.NFData RemoveResourcePermission

instance Core.ToHeaders RemoveResourcePermission where
  toHeaders :: RemoveResourcePermission -> [Header]
toHeaders RemoveResourcePermission' {Maybe (Sensitive Text)
Maybe PrincipalType
Text
principalId :: Text
resourceId :: Text
authenticationToken :: Maybe (Sensitive Text)
principalType :: Maybe PrincipalType
$sel:principalId:RemoveResourcePermission' :: RemoveResourcePermission -> Text
$sel:resourceId:RemoveResourcePermission' :: RemoveResourcePermission -> Text
$sel:authenticationToken:RemoveResourcePermission' :: RemoveResourcePermission -> Maybe (Sensitive Text)
$sel:principalType:RemoveResourcePermission' :: RemoveResourcePermission -> Maybe PrincipalType
..} =
    [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"Authentication" HeaderName -> Maybe (Sensitive Text) -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe (Sensitive Text)
authenticationToken,
        HeaderName
"Content-Type"
          HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Core.ToPath RemoveResourcePermission where
  toPath :: RemoveResourcePermission -> ByteString
toPath RemoveResourcePermission' {Maybe (Sensitive Text)
Maybe PrincipalType
Text
principalId :: Text
resourceId :: Text
authenticationToken :: Maybe (Sensitive Text)
principalType :: Maybe PrincipalType
$sel:principalId:RemoveResourcePermission' :: RemoveResourcePermission -> Text
$sel:resourceId:RemoveResourcePermission' :: RemoveResourcePermission -> Text
$sel:authenticationToken:RemoveResourcePermission' :: RemoveResourcePermission -> Maybe (Sensitive Text)
$sel:principalType:RemoveResourcePermission' :: RemoveResourcePermission -> Maybe PrincipalType
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/api/v1/resources/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
resourceId,
        ByteString
"/permissions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
principalId
      ]

instance Core.ToQuery RemoveResourcePermission where
  toQuery :: RemoveResourcePermission -> QueryString
toQuery RemoveResourcePermission' {Maybe (Sensitive Text)
Maybe PrincipalType
Text
principalId :: Text
resourceId :: Text
authenticationToken :: Maybe (Sensitive Text)
principalType :: Maybe PrincipalType
$sel:principalId:RemoveResourcePermission' :: RemoveResourcePermission -> Text
$sel:resourceId:RemoveResourcePermission' :: RemoveResourcePermission -> Text
$sel:authenticationToken:RemoveResourcePermission' :: RemoveResourcePermission -> Maybe (Sensitive Text)
$sel:principalType:RemoveResourcePermission' :: RemoveResourcePermission -> Maybe PrincipalType
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"type" ByteString -> Maybe PrincipalType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe PrincipalType
principalType]

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

-- |
-- Create a value of 'RemoveResourcePermissionResponse' 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.
newRemoveResourcePermissionResponse ::
  RemoveResourcePermissionResponse
newRemoveResourcePermissionResponse :: RemoveResourcePermissionResponse
newRemoveResourcePermissionResponse =
  RemoveResourcePermissionResponse
RemoveResourcePermissionResponse'

instance
  Prelude.NFData
    RemoveResourcePermissionResponse