{-# 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.RevokeSignature
-- 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)
--
-- Changes the state of a signing job to REVOKED. This indicates that the
-- signature is no longer valid.
module Amazonka.Signer.RevokeSignature
  ( -- * Creating a Request
    RevokeSignature (..),
    newRevokeSignature,

    -- * Request Lenses
    revokeSignature_jobOwner,
    revokeSignature_reason,
    revokeSignature_jobId,

    -- * Destructuring the Response
    RevokeSignatureResponse (..),
    newRevokeSignatureResponse,
  )
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.Signer.Types

-- | /See:/ 'newRevokeSignature' smart constructor.
data RevokeSignature = RevokeSignature'
  { -- | AWS account ID of the job owner.
    RevokeSignature -> Maybe Text
jobOwner :: Prelude.Maybe Prelude.Text,
    -- | The reason for revoking the signing job.
    RevokeSignature -> Text
reason :: Prelude.Text,
    -- | ID of the signing job to be revoked.
    RevokeSignature -> Text
jobId :: Prelude.Text
  }
  deriving (RevokeSignature -> RevokeSignature -> Bool
(RevokeSignature -> RevokeSignature -> Bool)
-> (RevokeSignature -> RevokeSignature -> Bool)
-> Eq RevokeSignature
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RevokeSignature -> RevokeSignature -> Bool
$c/= :: RevokeSignature -> RevokeSignature -> Bool
== :: RevokeSignature -> RevokeSignature -> Bool
$c== :: RevokeSignature -> RevokeSignature -> Bool
Prelude.Eq, ReadPrec [RevokeSignature]
ReadPrec RevokeSignature
Int -> ReadS RevokeSignature
ReadS [RevokeSignature]
(Int -> ReadS RevokeSignature)
-> ReadS [RevokeSignature]
-> ReadPrec RevokeSignature
-> ReadPrec [RevokeSignature]
-> Read RevokeSignature
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RevokeSignature]
$creadListPrec :: ReadPrec [RevokeSignature]
readPrec :: ReadPrec RevokeSignature
$creadPrec :: ReadPrec RevokeSignature
readList :: ReadS [RevokeSignature]
$creadList :: ReadS [RevokeSignature]
readsPrec :: Int -> ReadS RevokeSignature
$creadsPrec :: Int -> ReadS RevokeSignature
Prelude.Read, Int -> RevokeSignature -> ShowS
[RevokeSignature] -> ShowS
RevokeSignature -> String
(Int -> RevokeSignature -> ShowS)
-> (RevokeSignature -> String)
-> ([RevokeSignature] -> ShowS)
-> Show RevokeSignature
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RevokeSignature] -> ShowS
$cshowList :: [RevokeSignature] -> ShowS
show :: RevokeSignature -> String
$cshow :: RevokeSignature -> String
showsPrec :: Int -> RevokeSignature -> ShowS
$cshowsPrec :: Int -> RevokeSignature -> ShowS
Prelude.Show, (forall x. RevokeSignature -> Rep RevokeSignature x)
-> (forall x. Rep RevokeSignature x -> RevokeSignature)
-> Generic RevokeSignature
forall x. Rep RevokeSignature x -> RevokeSignature
forall x. RevokeSignature -> Rep RevokeSignature x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RevokeSignature x -> RevokeSignature
$cfrom :: forall x. RevokeSignature -> Rep RevokeSignature x
Prelude.Generic)

-- |
-- Create a value of 'RevokeSignature' 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:
--
-- 'jobOwner', 'revokeSignature_jobOwner' - AWS account ID of the job owner.
--
-- 'reason', 'revokeSignature_reason' - The reason for revoking the signing job.
--
-- 'jobId', 'revokeSignature_jobId' - ID of the signing job to be revoked.
newRevokeSignature ::
  -- | 'reason'
  Prelude.Text ->
  -- | 'jobId'
  Prelude.Text ->
  RevokeSignature
newRevokeSignature :: Text -> Text -> RevokeSignature
newRevokeSignature Text
pReason_ Text
pJobId_ =
  RevokeSignature' :: Maybe Text -> Text -> Text -> RevokeSignature
RevokeSignature'
    { $sel:jobOwner:RevokeSignature' :: Maybe Text
jobOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reason:RevokeSignature' :: Text
reason = Text
pReason_,
      $sel:jobId:RevokeSignature' :: Text
jobId = Text
pJobId_
    }

-- | AWS account ID of the job owner.
revokeSignature_jobOwner :: Lens.Lens' RevokeSignature (Prelude.Maybe Prelude.Text)
revokeSignature_jobOwner :: (Maybe Text -> f (Maybe Text))
-> RevokeSignature -> f RevokeSignature
revokeSignature_jobOwner = (RevokeSignature -> Maybe Text)
-> (RevokeSignature -> Maybe Text -> RevokeSignature)
-> Lens RevokeSignature RevokeSignature (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevokeSignature' {Maybe Text
jobOwner :: Maybe Text
$sel:jobOwner:RevokeSignature' :: RevokeSignature -> Maybe Text
jobOwner} -> Maybe Text
jobOwner) (\s :: RevokeSignature
s@RevokeSignature' {} Maybe Text
a -> RevokeSignature
s {$sel:jobOwner:RevokeSignature' :: Maybe Text
jobOwner = Maybe Text
a} :: RevokeSignature)

-- | The reason for revoking the signing job.
revokeSignature_reason :: Lens.Lens' RevokeSignature Prelude.Text
revokeSignature_reason :: (Text -> f Text) -> RevokeSignature -> f RevokeSignature
revokeSignature_reason = (RevokeSignature -> Text)
-> (RevokeSignature -> Text -> RevokeSignature)
-> Lens RevokeSignature RevokeSignature Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevokeSignature' {Text
reason :: Text
$sel:reason:RevokeSignature' :: RevokeSignature -> Text
reason} -> Text
reason) (\s :: RevokeSignature
s@RevokeSignature' {} Text
a -> RevokeSignature
s {$sel:reason:RevokeSignature' :: Text
reason = Text
a} :: RevokeSignature)

-- | ID of the signing job to be revoked.
revokeSignature_jobId :: Lens.Lens' RevokeSignature Prelude.Text
revokeSignature_jobId :: (Text -> f Text) -> RevokeSignature -> f RevokeSignature
revokeSignature_jobId = (RevokeSignature -> Text)
-> (RevokeSignature -> Text -> RevokeSignature)
-> Lens RevokeSignature RevokeSignature Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevokeSignature' {Text
jobId :: Text
$sel:jobId:RevokeSignature' :: RevokeSignature -> Text
jobId} -> Text
jobId) (\s :: RevokeSignature
s@RevokeSignature' {} Text
a -> RevokeSignature
s {$sel:jobId:RevokeSignature' :: Text
jobId = Text
a} :: RevokeSignature)

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

instance Prelude.Hashable RevokeSignature

instance Prelude.NFData RevokeSignature

instance Core.ToHeaders RevokeSignature where
  toHeaders :: RevokeSignature -> [Header]
toHeaders =
    [Header] -> RevokeSignature -> [Header]
forall a b. a -> b -> a
Prelude.const
      ( [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToJSON RevokeSignature where
  toJSON :: RevokeSignature -> Value
toJSON RevokeSignature' {Maybe Text
Text
jobId :: Text
reason :: Text
jobOwner :: Maybe Text
$sel:jobId:RevokeSignature' :: RevokeSignature -> Text
$sel:reason:RevokeSignature' :: RevokeSignature -> Text
$sel:jobOwner:RevokeSignature' :: RevokeSignature -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"jobOwner" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
jobOwner,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"reason" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
reason)
          ]
      )

instance Core.ToPath RevokeSignature where
  toPath :: RevokeSignature -> ByteString
toPath RevokeSignature' {Maybe Text
Text
jobId :: Text
reason :: Text
jobOwner :: Maybe Text
$sel:jobId:RevokeSignature' :: RevokeSignature -> Text
$sel:reason:RevokeSignature' :: RevokeSignature -> Text
$sel:jobOwner:RevokeSignature' :: RevokeSignature -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/signing-jobs/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
jobId, ByteString
"/revoke"]

instance Core.ToQuery RevokeSignature where
  toQuery :: RevokeSignature -> QueryString
toQuery = QueryString -> RevokeSignature -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

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

instance Prelude.NFData RevokeSignatureResponse