{-# 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.CodeGuruProfiler.RemovePermission
-- 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 permissions from a profiling group\'s resource-based policy that
-- are provided using an action group. The one supported action group that
-- can be removed is @agentPermission@ which grants @ConfigureAgent@ and
-- @PostAgent@ permissions. For more information, see
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-ug/resource-based-policies.html Resource-based policies in CodeGuru Profiler>
-- in the /Amazon CodeGuru Profiler User Guide/,
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_ConfigureAgent.html ConfigureAgent>
-- , and
-- <https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_PostAgentProfile.html PostAgentProfile>
-- .
module Amazonka.CodeGuruProfiler.RemovePermission
  ( -- * Creating a Request
    RemovePermission (..),
    newRemovePermission,

    -- * Request Lenses
    removePermission_actionGroup,
    removePermission_profilingGroupName,
    removePermission_revisionId,

    -- * Destructuring the Response
    RemovePermissionResponse (..),
    newRemovePermissionResponse,

    -- * Response Lenses
    removePermissionResponse_httpStatus,
    removePermissionResponse_policy,
    removePermissionResponse_revisionId,
  )
where

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

-- | >  The structure representing the <code>removePermissionRequest</code>.</p>
--
-- /See:/ 'newRemovePermission' smart constructor.
data RemovePermission = RemovePermission'
  { -- | Specifies an action group that contains the permissions to remove from a
    -- profiling group\'s resource-based policy. One action group is supported,
    -- @agentPermissions@, which grants @ConfigureAgent@ and @PostAgentProfile@
    -- permissions.
    RemovePermission -> ActionGroup
actionGroup :: ActionGroup,
    -- | The name of the profiling group.
    RemovePermission -> Text
profilingGroupName :: Prelude.Text,
    -- | A universally unique identifier (UUID) for the revision of the
    -- resource-based policy from which you want to remove permissions.
    RemovePermission -> Text
revisionId :: Prelude.Text
  }
  deriving (RemovePermission -> RemovePermission -> Bool
(RemovePermission -> RemovePermission -> Bool)
-> (RemovePermission -> RemovePermission -> Bool)
-> Eq RemovePermission
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemovePermission -> RemovePermission -> Bool
$c/= :: RemovePermission -> RemovePermission -> Bool
== :: RemovePermission -> RemovePermission -> Bool
$c== :: RemovePermission -> RemovePermission -> Bool
Prelude.Eq, ReadPrec [RemovePermission]
ReadPrec RemovePermission
Int -> ReadS RemovePermission
ReadS [RemovePermission]
(Int -> ReadS RemovePermission)
-> ReadS [RemovePermission]
-> ReadPrec RemovePermission
-> ReadPrec [RemovePermission]
-> Read RemovePermission
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemovePermission]
$creadListPrec :: ReadPrec [RemovePermission]
readPrec :: ReadPrec RemovePermission
$creadPrec :: ReadPrec RemovePermission
readList :: ReadS [RemovePermission]
$creadList :: ReadS [RemovePermission]
readsPrec :: Int -> ReadS RemovePermission
$creadsPrec :: Int -> ReadS RemovePermission
Prelude.Read, Int -> RemovePermission -> ShowS
[RemovePermission] -> ShowS
RemovePermission -> String
(Int -> RemovePermission -> ShowS)
-> (RemovePermission -> String)
-> ([RemovePermission] -> ShowS)
-> Show RemovePermission
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemovePermission] -> ShowS
$cshowList :: [RemovePermission] -> ShowS
show :: RemovePermission -> String
$cshow :: RemovePermission -> String
showsPrec :: Int -> RemovePermission -> ShowS
$cshowsPrec :: Int -> RemovePermission -> ShowS
Prelude.Show, (forall x. RemovePermission -> Rep RemovePermission x)
-> (forall x. Rep RemovePermission x -> RemovePermission)
-> Generic RemovePermission
forall x. Rep RemovePermission x -> RemovePermission
forall x. RemovePermission -> Rep RemovePermission x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemovePermission x -> RemovePermission
$cfrom :: forall x. RemovePermission -> Rep RemovePermission x
Prelude.Generic)

-- |
-- Create a value of 'RemovePermission' 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:
--
-- 'actionGroup', 'removePermission_actionGroup' - Specifies an action group that contains the permissions to remove from a
-- profiling group\'s resource-based policy. One action group is supported,
-- @agentPermissions@, which grants @ConfigureAgent@ and @PostAgentProfile@
-- permissions.
--
-- 'profilingGroupName', 'removePermission_profilingGroupName' - The name of the profiling group.
--
-- 'revisionId', 'removePermission_revisionId' - A universally unique identifier (UUID) for the revision of the
-- resource-based policy from which you want to remove permissions.
newRemovePermission ::
  -- | 'actionGroup'
  ActionGroup ->
  -- | 'profilingGroupName'
  Prelude.Text ->
  -- | 'revisionId'
  Prelude.Text ->
  RemovePermission
newRemovePermission :: ActionGroup -> Text -> Text -> RemovePermission
newRemovePermission
  ActionGroup
pActionGroup_
  Text
pProfilingGroupName_
  Text
pRevisionId_ =
    RemovePermission' :: ActionGroup -> Text -> Text -> RemovePermission
RemovePermission'
      { $sel:actionGroup:RemovePermission' :: ActionGroup
actionGroup = ActionGroup
pActionGroup_,
        $sel:profilingGroupName:RemovePermission' :: Text
profilingGroupName = Text
pProfilingGroupName_,
        $sel:revisionId:RemovePermission' :: Text
revisionId = Text
pRevisionId_
      }

-- | Specifies an action group that contains the permissions to remove from a
-- profiling group\'s resource-based policy. One action group is supported,
-- @agentPermissions@, which grants @ConfigureAgent@ and @PostAgentProfile@
-- permissions.
removePermission_actionGroup :: Lens.Lens' RemovePermission ActionGroup
removePermission_actionGroup :: (ActionGroup -> f ActionGroup)
-> RemovePermission -> f RemovePermission
removePermission_actionGroup = (RemovePermission -> ActionGroup)
-> (RemovePermission -> ActionGroup -> RemovePermission)
-> Lens RemovePermission RemovePermission ActionGroup ActionGroup
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemovePermission' {ActionGroup
actionGroup :: ActionGroup
$sel:actionGroup:RemovePermission' :: RemovePermission -> ActionGroup
actionGroup} -> ActionGroup
actionGroup) (\s :: RemovePermission
s@RemovePermission' {} ActionGroup
a -> RemovePermission
s {$sel:actionGroup:RemovePermission' :: ActionGroup
actionGroup = ActionGroup
a} :: RemovePermission)

-- | The name of the profiling group.
removePermission_profilingGroupName :: Lens.Lens' RemovePermission Prelude.Text
removePermission_profilingGroupName :: (Text -> f Text) -> RemovePermission -> f RemovePermission
removePermission_profilingGroupName = (RemovePermission -> Text)
-> (RemovePermission -> Text -> RemovePermission)
-> Lens RemovePermission RemovePermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemovePermission' {Text
profilingGroupName :: Text
$sel:profilingGroupName:RemovePermission' :: RemovePermission -> Text
profilingGroupName} -> Text
profilingGroupName) (\s :: RemovePermission
s@RemovePermission' {} Text
a -> RemovePermission
s {$sel:profilingGroupName:RemovePermission' :: Text
profilingGroupName = Text
a} :: RemovePermission)

-- | A universally unique identifier (UUID) for the revision of the
-- resource-based policy from which you want to remove permissions.
removePermission_revisionId :: Lens.Lens' RemovePermission Prelude.Text
removePermission_revisionId :: (Text -> f Text) -> RemovePermission -> f RemovePermission
removePermission_revisionId = (RemovePermission -> Text)
-> (RemovePermission -> Text -> RemovePermission)
-> Lens RemovePermission RemovePermission Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemovePermission' {Text
revisionId :: Text
$sel:revisionId:RemovePermission' :: RemovePermission -> Text
revisionId} -> Text
revisionId) (\s :: RemovePermission
s@RemovePermission' {} Text
a -> RemovePermission
s {$sel:revisionId:RemovePermission' :: Text
revisionId = Text
a} :: RemovePermission)

instance Core.AWSRequest RemovePermission where
  type
    AWSResponse RemovePermission =
      RemovePermissionResponse
  request :: RemovePermission -> Request RemovePermission
request = Service -> RemovePermission -> Request RemovePermission
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy RemovePermission
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RemovePermission)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse RemovePermission))
-> Logger
-> Service
-> Proxy RemovePermission
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RemovePermission)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> Text -> RemovePermissionResponse
RemovePermissionResponse'
            (Int -> Text -> Text -> RemovePermissionResponse)
-> Either String Int
-> Either String (Text -> Text -> RemovePermissionResponse)
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))
            Either String (Text -> Text -> RemovePermissionResponse)
-> Either String Text
-> Either String (Text -> RemovePermissionResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"policy")
            Either String (Text -> RemovePermissionResponse)
-> Either String Text -> Either String RemovePermissionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"revisionId")
      )

instance Prelude.Hashable RemovePermission

instance Prelude.NFData RemovePermission

instance Core.ToHeaders RemovePermission where
  toHeaders :: RemovePermission -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RemovePermission -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath RemovePermission where
  toPath :: RemovePermission -> ByteString
toPath RemovePermission' {Text
ActionGroup
revisionId :: Text
profilingGroupName :: Text
actionGroup :: ActionGroup
$sel:revisionId:RemovePermission' :: RemovePermission -> Text
$sel:profilingGroupName:RemovePermission' :: RemovePermission -> Text
$sel:actionGroup:RemovePermission' :: RemovePermission -> ActionGroup
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/profilingGroups/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
profilingGroupName,
        ByteString
"/policy/",
        ActionGroup -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS ActionGroup
actionGroup
      ]

instance Core.ToQuery RemovePermission where
  toQuery :: RemovePermission -> QueryString
toQuery RemovePermission' {Text
ActionGroup
revisionId :: Text
profilingGroupName :: Text
actionGroup :: ActionGroup
$sel:revisionId:RemovePermission' :: RemovePermission -> Text
$sel:profilingGroupName:RemovePermission' :: RemovePermission -> Text
$sel:actionGroup:RemovePermission' :: RemovePermission -> ActionGroup
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"revisionId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
revisionId]

-- | The structure representing the @removePermissionResponse@.
--
-- /See:/ 'newRemovePermissionResponse' smart constructor.
data RemovePermissionResponse = RemovePermissionResponse'
  { -- | The response's http status code.
    RemovePermissionResponse -> Int
httpStatus :: Prelude.Int,
    -- | The JSON-formatted resource-based policy on the profiling group after
    -- the specified permissions were removed.
    RemovePermissionResponse -> Text
policy :: Prelude.Text,
    -- | A universally unique identifier (UUID) for the revision of the
    -- resource-based policy after the specified permissions were removed. The
    -- updated JSON-formatted policy is in the @policy@ element of the
    -- response.
    RemovePermissionResponse -> Text
revisionId :: Prelude.Text
  }
  deriving (RemovePermissionResponse -> RemovePermissionResponse -> Bool
(RemovePermissionResponse -> RemovePermissionResponse -> Bool)
-> (RemovePermissionResponse -> RemovePermissionResponse -> Bool)
-> Eq RemovePermissionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemovePermissionResponse -> RemovePermissionResponse -> Bool
$c/= :: RemovePermissionResponse -> RemovePermissionResponse -> Bool
== :: RemovePermissionResponse -> RemovePermissionResponse -> Bool
$c== :: RemovePermissionResponse -> RemovePermissionResponse -> Bool
Prelude.Eq, ReadPrec [RemovePermissionResponse]
ReadPrec RemovePermissionResponse
Int -> ReadS RemovePermissionResponse
ReadS [RemovePermissionResponse]
(Int -> ReadS RemovePermissionResponse)
-> ReadS [RemovePermissionResponse]
-> ReadPrec RemovePermissionResponse
-> ReadPrec [RemovePermissionResponse]
-> Read RemovePermissionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemovePermissionResponse]
$creadListPrec :: ReadPrec [RemovePermissionResponse]
readPrec :: ReadPrec RemovePermissionResponse
$creadPrec :: ReadPrec RemovePermissionResponse
readList :: ReadS [RemovePermissionResponse]
$creadList :: ReadS [RemovePermissionResponse]
readsPrec :: Int -> ReadS RemovePermissionResponse
$creadsPrec :: Int -> ReadS RemovePermissionResponse
Prelude.Read, Int -> RemovePermissionResponse -> ShowS
[RemovePermissionResponse] -> ShowS
RemovePermissionResponse -> String
(Int -> RemovePermissionResponse -> ShowS)
-> (RemovePermissionResponse -> String)
-> ([RemovePermissionResponse] -> ShowS)
-> Show RemovePermissionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemovePermissionResponse] -> ShowS
$cshowList :: [RemovePermissionResponse] -> ShowS
show :: RemovePermissionResponse -> String
$cshow :: RemovePermissionResponse -> String
showsPrec :: Int -> RemovePermissionResponse -> ShowS
$cshowsPrec :: Int -> RemovePermissionResponse -> ShowS
Prelude.Show, (forall x.
 RemovePermissionResponse -> Rep RemovePermissionResponse x)
-> (forall x.
    Rep RemovePermissionResponse x -> RemovePermissionResponse)
-> Generic RemovePermissionResponse
forall x.
Rep RemovePermissionResponse x -> RemovePermissionResponse
forall x.
RemovePermissionResponse -> Rep RemovePermissionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemovePermissionResponse x -> RemovePermissionResponse
$cfrom :: forall x.
RemovePermissionResponse -> Rep RemovePermissionResponse x
Prelude.Generic)

-- |
-- Create a value of 'RemovePermissionResponse' 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', 'removePermissionResponse_httpStatus' - The response's http status code.
--
-- 'policy', 'removePermissionResponse_policy' - The JSON-formatted resource-based policy on the profiling group after
-- the specified permissions were removed.
--
-- 'revisionId', 'removePermissionResponse_revisionId' - A universally unique identifier (UUID) for the revision of the
-- resource-based policy after the specified permissions were removed. The
-- updated JSON-formatted policy is in the @policy@ element of the
-- response.
newRemovePermissionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'policy'
  Prelude.Text ->
  -- | 'revisionId'
  Prelude.Text ->
  RemovePermissionResponse
newRemovePermissionResponse :: Int -> Text -> Text -> RemovePermissionResponse
newRemovePermissionResponse
  Int
pHttpStatus_
  Text
pPolicy_
  Text
pRevisionId_ =
    RemovePermissionResponse' :: Int -> Text -> Text -> RemovePermissionResponse
RemovePermissionResponse'
      { $sel:httpStatus:RemovePermissionResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:policy:RemovePermissionResponse' :: Text
policy = Text
pPolicy_,
        $sel:revisionId:RemovePermissionResponse' :: Text
revisionId = Text
pRevisionId_
      }

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

-- | The JSON-formatted resource-based policy on the profiling group after
-- the specified permissions were removed.
removePermissionResponse_policy :: Lens.Lens' RemovePermissionResponse Prelude.Text
removePermissionResponse_policy :: (Text -> f Text)
-> RemovePermissionResponse -> f RemovePermissionResponse
removePermissionResponse_policy = (RemovePermissionResponse -> Text)
-> (RemovePermissionResponse -> Text -> RemovePermissionResponse)
-> Lens RemovePermissionResponse RemovePermissionResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemovePermissionResponse' {Text
policy :: Text
$sel:policy:RemovePermissionResponse' :: RemovePermissionResponse -> Text
policy} -> Text
policy) (\s :: RemovePermissionResponse
s@RemovePermissionResponse' {} Text
a -> RemovePermissionResponse
s {$sel:policy:RemovePermissionResponse' :: Text
policy = Text
a} :: RemovePermissionResponse)

-- | A universally unique identifier (UUID) for the revision of the
-- resource-based policy after the specified permissions were removed. The
-- updated JSON-formatted policy is in the @policy@ element of the
-- response.
removePermissionResponse_revisionId :: Lens.Lens' RemovePermissionResponse Prelude.Text
removePermissionResponse_revisionId :: (Text -> f Text)
-> RemovePermissionResponse -> f RemovePermissionResponse
removePermissionResponse_revisionId = (RemovePermissionResponse -> Text)
-> (RemovePermissionResponse -> Text -> RemovePermissionResponse)
-> Lens RemovePermissionResponse RemovePermissionResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemovePermissionResponse' {Text
revisionId :: Text
$sel:revisionId:RemovePermissionResponse' :: RemovePermissionResponse -> Text
revisionId} -> Text
revisionId) (\s :: RemovePermissionResponse
s@RemovePermissionResponse' {} Text
a -> RemovePermissionResponse
s {$sel:revisionId:RemovePermissionResponse' :: Text
revisionId = Text
a} :: RemovePermissionResponse)

instance Prelude.NFData RemovePermissionResponse