{-# 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.Signer.RemoveProfilePermission
-- 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 cross-account permissions from a signing profile.
module Amazonka.Signer.RemoveProfilePermission
  ( -- * Creating a Request
    RemoveProfilePermission (..),
    newRemoveProfilePermission,

    -- * Request Lenses
    removeProfilePermission_revisionId,
    removeProfilePermission_profileName,
    removeProfilePermission_statementId,

    -- * Destructuring the Response
    RemoveProfilePermissionResponse (..),
    newRemoveProfilePermissionResponse,

    -- * Response Lenses
    removeProfilePermissionResponse_revisionId,
    removeProfilePermissionResponse_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.Signer.Types

-- | /See:/ 'newRemoveProfilePermission' smart constructor.
data RemoveProfilePermission = RemoveProfilePermission'
  { -- | An identifier for the current revision of the signing profile
    -- permissions.
    RemoveProfilePermission -> Text
revisionId :: Prelude.Text,
    -- | A human-readable name for the signing profile with permissions to be
    -- removed.
    RemoveProfilePermission -> Text
profileName :: Prelude.Text,
    -- | A unique identifier for the cross-account permissions statement.
    RemoveProfilePermission -> Text
statementId :: Prelude.Text
  }
  deriving (RemoveProfilePermission -> RemoveProfilePermission -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveProfilePermission -> RemoveProfilePermission -> Bool
$c/= :: RemoveProfilePermission -> RemoveProfilePermission -> Bool
== :: RemoveProfilePermission -> RemoveProfilePermission -> Bool
$c== :: RemoveProfilePermission -> RemoveProfilePermission -> Bool
Prelude.Eq, ReadPrec [RemoveProfilePermission]
ReadPrec RemoveProfilePermission
Int -> ReadS RemoveProfilePermission
ReadS [RemoveProfilePermission]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveProfilePermission]
$creadListPrec :: ReadPrec [RemoveProfilePermission]
readPrec :: ReadPrec RemoveProfilePermission
$creadPrec :: ReadPrec RemoveProfilePermission
readList :: ReadS [RemoveProfilePermission]
$creadList :: ReadS [RemoveProfilePermission]
readsPrec :: Int -> ReadS RemoveProfilePermission
$creadsPrec :: Int -> ReadS RemoveProfilePermission
Prelude.Read, Int -> RemoveProfilePermission -> ShowS
[RemoveProfilePermission] -> ShowS
RemoveProfilePermission -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveProfilePermission] -> ShowS
$cshowList :: [RemoveProfilePermission] -> ShowS
show :: RemoveProfilePermission -> String
$cshow :: RemoveProfilePermission -> String
showsPrec :: Int -> RemoveProfilePermission -> ShowS
$cshowsPrec :: Int -> RemoveProfilePermission -> ShowS
Prelude.Show, forall x. Rep RemoveProfilePermission x -> RemoveProfilePermission
forall x. RemoveProfilePermission -> Rep RemoveProfilePermission x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemoveProfilePermission x -> RemoveProfilePermission
$cfrom :: forall x. RemoveProfilePermission -> Rep RemoveProfilePermission x
Prelude.Generic)

-- |
-- Create a value of 'RemoveProfilePermission' 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:
--
-- 'revisionId', 'removeProfilePermission_revisionId' - An identifier for the current revision of the signing profile
-- permissions.
--
-- 'profileName', 'removeProfilePermission_profileName' - A human-readable name for the signing profile with permissions to be
-- removed.
--
-- 'statementId', 'removeProfilePermission_statementId' - A unique identifier for the cross-account permissions statement.
newRemoveProfilePermission ::
  -- | 'revisionId'
  Prelude.Text ->
  -- | 'profileName'
  Prelude.Text ->
  -- | 'statementId'
  Prelude.Text ->
  RemoveProfilePermission
newRemoveProfilePermission :: Text -> Text -> Text -> RemoveProfilePermission
newRemoveProfilePermission
  Text
pRevisionId_
  Text
pProfileName_
  Text
pStatementId_ =
    RemoveProfilePermission'
      { $sel:revisionId:RemoveProfilePermission' :: Text
revisionId = Text
pRevisionId_,
        $sel:profileName:RemoveProfilePermission' :: Text
profileName = Text
pProfileName_,
        $sel:statementId:RemoveProfilePermission' :: Text
statementId = Text
pStatementId_
      }

-- | An identifier for the current revision of the signing profile
-- permissions.
removeProfilePermission_revisionId :: Lens.Lens' RemoveProfilePermission Prelude.Text
removeProfilePermission_revisionId :: Lens' RemoveProfilePermission Text
removeProfilePermission_revisionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveProfilePermission' {Text
revisionId :: Text
$sel:revisionId:RemoveProfilePermission' :: RemoveProfilePermission -> Text
revisionId} -> Text
revisionId) (\s :: RemoveProfilePermission
s@RemoveProfilePermission' {} Text
a -> RemoveProfilePermission
s {$sel:revisionId:RemoveProfilePermission' :: Text
revisionId = Text
a} :: RemoveProfilePermission)

-- | A human-readable name for the signing profile with permissions to be
-- removed.
removeProfilePermission_profileName :: Lens.Lens' RemoveProfilePermission Prelude.Text
removeProfilePermission_profileName :: Lens' RemoveProfilePermission Text
removeProfilePermission_profileName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveProfilePermission' {Text
profileName :: Text
$sel:profileName:RemoveProfilePermission' :: RemoveProfilePermission -> Text
profileName} -> Text
profileName) (\s :: RemoveProfilePermission
s@RemoveProfilePermission' {} Text
a -> RemoveProfilePermission
s {$sel:profileName:RemoveProfilePermission' :: Text
profileName = Text
a} :: RemoveProfilePermission)

-- | A unique identifier for the cross-account permissions statement.
removeProfilePermission_statementId :: Lens.Lens' RemoveProfilePermission Prelude.Text
removeProfilePermission_statementId :: Lens' RemoveProfilePermission Text
removeProfilePermission_statementId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveProfilePermission' {Text
statementId :: Text
$sel:statementId:RemoveProfilePermission' :: RemoveProfilePermission -> Text
statementId} -> Text
statementId) (\s :: RemoveProfilePermission
s@RemoveProfilePermission' {} Text
a -> RemoveProfilePermission
s {$sel:statementId:RemoveProfilePermission' :: Text
statementId = Text
a} :: RemoveProfilePermission)

instance Core.AWSRequest RemoveProfilePermission where
  type
    AWSResponse RemoveProfilePermission =
      RemoveProfilePermissionResponse
  request :: (Service -> Service)
-> RemoveProfilePermission -> Request RemoveProfilePermission
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 RemoveProfilePermission
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveProfilePermission)))
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 ->
          Maybe Text -> Int -> RemoveProfilePermissionResponse
RemoveProfilePermissionResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"revisionId")
            forall (f :: * -> *) a b. Applicative f => 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 RemoveProfilePermission where
  hashWithSalt :: Int -> RemoveProfilePermission -> Int
hashWithSalt Int
_salt RemoveProfilePermission' {Text
statementId :: Text
profileName :: Text
revisionId :: Text
$sel:statementId:RemoveProfilePermission' :: RemoveProfilePermission -> Text
$sel:profileName:RemoveProfilePermission' :: RemoveProfilePermission -> Text
$sel:revisionId:RemoveProfilePermission' :: RemoveProfilePermission -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
revisionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
profileName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
statementId

instance Prelude.NFData RemoveProfilePermission where
  rnf :: RemoveProfilePermission -> ()
rnf RemoveProfilePermission' {Text
statementId :: Text
profileName :: Text
revisionId :: Text
$sel:statementId:RemoveProfilePermission' :: RemoveProfilePermission -> Text
$sel:profileName:RemoveProfilePermission' :: RemoveProfilePermission -> Text
$sel:revisionId:RemoveProfilePermission' :: RemoveProfilePermission -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
revisionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
profileName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
statementId

instance Data.ToHeaders RemoveProfilePermission where
  toHeaders :: RemoveProfilePermission -> 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 RemoveProfilePermission where
  toPath :: RemoveProfilePermission -> ByteString
toPath RemoveProfilePermission' {Text
statementId :: Text
profileName :: Text
revisionId :: Text
$sel:statementId:RemoveProfilePermission' :: RemoveProfilePermission -> Text
$sel:profileName:RemoveProfilePermission' :: RemoveProfilePermission -> Text
$sel:revisionId:RemoveProfilePermission' :: RemoveProfilePermission -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/signing-profiles/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
profileName,
        ByteString
"/permissions/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
statementId
      ]

instance Data.ToQuery RemoveProfilePermission where
  toQuery :: RemoveProfilePermission -> QueryString
toQuery RemoveProfilePermission' {Text
statementId :: Text
profileName :: Text
revisionId :: Text
$sel:statementId:RemoveProfilePermission' :: RemoveProfilePermission -> Text
$sel:profileName:RemoveProfilePermission' :: RemoveProfilePermission -> Text
$sel:revisionId:RemoveProfilePermission' :: RemoveProfilePermission -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"revisionId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
revisionId]

-- | /See:/ 'newRemoveProfilePermissionResponse' smart constructor.
data RemoveProfilePermissionResponse = RemoveProfilePermissionResponse'
  { -- | An identifier for the current revision of the profile permissions.
    RemoveProfilePermissionResponse -> Maybe Text
revisionId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    RemoveProfilePermissionResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RemoveProfilePermissionResponse
-> RemoveProfilePermissionResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveProfilePermissionResponse
-> RemoveProfilePermissionResponse -> Bool
$c/= :: RemoveProfilePermissionResponse
-> RemoveProfilePermissionResponse -> Bool
== :: RemoveProfilePermissionResponse
-> RemoveProfilePermissionResponse -> Bool
$c== :: RemoveProfilePermissionResponse
-> RemoveProfilePermissionResponse -> Bool
Prelude.Eq, ReadPrec [RemoveProfilePermissionResponse]
ReadPrec RemoveProfilePermissionResponse
Int -> ReadS RemoveProfilePermissionResponse
ReadS [RemoveProfilePermissionResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveProfilePermissionResponse]
$creadListPrec :: ReadPrec [RemoveProfilePermissionResponse]
readPrec :: ReadPrec RemoveProfilePermissionResponse
$creadPrec :: ReadPrec RemoveProfilePermissionResponse
readList :: ReadS [RemoveProfilePermissionResponse]
$creadList :: ReadS [RemoveProfilePermissionResponse]
readsPrec :: Int -> ReadS RemoveProfilePermissionResponse
$creadsPrec :: Int -> ReadS RemoveProfilePermissionResponse
Prelude.Read, Int -> RemoveProfilePermissionResponse -> ShowS
[RemoveProfilePermissionResponse] -> ShowS
RemoveProfilePermissionResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveProfilePermissionResponse] -> ShowS
$cshowList :: [RemoveProfilePermissionResponse] -> ShowS
show :: RemoveProfilePermissionResponse -> String
$cshow :: RemoveProfilePermissionResponse -> String
showsPrec :: Int -> RemoveProfilePermissionResponse -> ShowS
$cshowsPrec :: Int -> RemoveProfilePermissionResponse -> ShowS
Prelude.Show, forall x.
Rep RemoveProfilePermissionResponse x
-> RemoveProfilePermissionResponse
forall x.
RemoveProfilePermissionResponse
-> Rep RemoveProfilePermissionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemoveProfilePermissionResponse x
-> RemoveProfilePermissionResponse
$cfrom :: forall x.
RemoveProfilePermissionResponse
-> Rep RemoveProfilePermissionResponse x
Prelude.Generic)

-- |
-- Create a value of 'RemoveProfilePermissionResponse' 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:
--
-- 'revisionId', 'removeProfilePermissionResponse_revisionId' - An identifier for the current revision of the profile permissions.
--
-- 'httpStatus', 'removeProfilePermissionResponse_httpStatus' - The response's http status code.
newRemoveProfilePermissionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RemoveProfilePermissionResponse
newRemoveProfilePermissionResponse :: Int -> RemoveProfilePermissionResponse
newRemoveProfilePermissionResponse Int
pHttpStatus_ =
  RemoveProfilePermissionResponse'
    { $sel:revisionId:RemoveProfilePermissionResponse' :: Maybe Text
revisionId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RemoveProfilePermissionResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An identifier for the current revision of the profile permissions.
removeProfilePermissionResponse_revisionId :: Lens.Lens' RemoveProfilePermissionResponse (Prelude.Maybe Prelude.Text)
removeProfilePermissionResponse_revisionId :: Lens' RemoveProfilePermissionResponse (Maybe Text)
removeProfilePermissionResponse_revisionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveProfilePermissionResponse' {Maybe Text
revisionId :: Maybe Text
$sel:revisionId:RemoveProfilePermissionResponse' :: RemoveProfilePermissionResponse -> Maybe Text
revisionId} -> Maybe Text
revisionId) (\s :: RemoveProfilePermissionResponse
s@RemoveProfilePermissionResponse' {} Maybe Text
a -> RemoveProfilePermissionResponse
s {$sel:revisionId:RemoveProfilePermissionResponse' :: Maybe Text
revisionId = Maybe Text
a} :: RemoveProfilePermissionResponse)

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

instance
  Prelude.NFData
    RemoveProfilePermissionResponse
  where
  rnf :: RemoveProfilePermissionResponse -> ()
rnf RemoveProfilePermissionResponse' {Int
Maybe Text
httpStatus :: Int
revisionId :: Maybe Text
$sel:httpStatus:RemoveProfilePermissionResponse' :: RemoveProfilePermissionResponse -> Int
$sel:revisionId:RemoveProfilePermissionResponse' :: RemoveProfilePermissionResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
revisionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus