{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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

-- | >  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
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]
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
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. 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'
      { $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 :: Lens' RemovePermission ActionGroup
removePermission_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 :: Lens' RemovePermission Text
removePermission_profilingGroupName = 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 :: Lens' RemovePermission Text
removePermission_revisionId = 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 :: (Service -> Service)
-> RemovePermission -> Request RemovePermission
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RemovePermission
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RemovePermission)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> Text -> RemovePermissionResponse
RemovePermissionResponse'
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"policy")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"revisionId")
      )

instance Prelude.Hashable RemovePermission where
  hashWithSalt :: Int -> RemovePermission -> Int
hashWithSalt Int
_salt RemovePermission' {Text
ActionGroup
revisionId :: Text
profilingGroupName :: Text
actionGroup :: ActionGroup
$sel:revisionId:RemovePermission' :: RemovePermission -> Text
$sel:profilingGroupName:RemovePermission' :: RemovePermission -> Text
$sel:actionGroup:RemovePermission' :: RemovePermission -> ActionGroup
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ActionGroup
actionGroup
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
profilingGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
revisionId

instance Prelude.NFData RemovePermission where
  rnf :: RemovePermission -> ()
rnf RemovePermission' {Text
ActionGroup
revisionId :: Text
profilingGroupName :: Text
actionGroup :: ActionGroup
$sel:revisionId:RemovePermission' :: RemovePermission -> Text
$sel:profilingGroupName:RemovePermission' :: RemovePermission -> Text
$sel:actionGroup:RemovePermission' :: RemovePermission -> ActionGroup
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ActionGroup
actionGroup
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
profilingGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
revisionId

instance Data.ToHeaders RemovePermission where
  toHeaders :: RemovePermission -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/profilingGroups/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
profilingGroupName,
        ByteString
"/policy/",
        forall a. ToByteString a => a -> ByteString
Data.toBS ActionGroup
actionGroup
      ]

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"revisionId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: 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
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]
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
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.
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'
      { $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 :: Lens' RemovePermissionResponse Int
removePermissionResponse_httpStatus = 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 :: Lens' RemovePermissionResponse Text
removePermissionResponse_policy = 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 :: Lens' RemovePermissionResponse Text
removePermissionResponse_revisionId = 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 where
  rnf :: RemovePermissionResponse -> ()
rnf RemovePermissionResponse' {Int
Text
revisionId :: Text
policy :: Text
httpStatus :: Int
$sel:revisionId:RemovePermissionResponse' :: RemovePermissionResponse -> Text
$sel:policy:RemovePermissionResponse' :: RemovePermissionResponse -> Text
$sel:httpStatus:RemovePermissionResponse' :: RemovePermissionResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
policy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
revisionId