{-# 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.IoT.RejectCertificateTransfer
-- 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)
--
-- Rejects a pending certificate transfer. After IoT rejects a certificate
-- transfer, the certificate status changes from __PENDING_TRANSFER__ to
-- __INACTIVE__.
--
-- To check for pending certificate transfers, call ListCertificates to
-- enumerate your certificates.
--
-- This operation can only be called by the transfer destination. After it
-- is called, the certificate will be returned to the source\'s account in
-- the INACTIVE state.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions RejectCertificateTransfer>
-- action.
module Amazonka.IoT.RejectCertificateTransfer
  ( -- * Creating a Request
    RejectCertificateTransfer (..),
    newRejectCertificateTransfer,

    -- * Request Lenses
    rejectCertificateTransfer_rejectReason,
    rejectCertificateTransfer_certificateId,

    -- * Destructuring the Response
    RejectCertificateTransferResponse (..),
    newRejectCertificateTransferResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types
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 input for the RejectCertificateTransfer operation.
--
-- /See:/ 'newRejectCertificateTransfer' smart constructor.
data RejectCertificateTransfer = RejectCertificateTransfer'
  { -- | The reason the certificate transfer was rejected.
    RejectCertificateTransfer -> Maybe Text
rejectReason :: Prelude.Maybe Prelude.Text,
    -- | The ID of the certificate. (The last part of the certificate ARN
    -- contains the certificate ID.)
    RejectCertificateTransfer -> Text
certificateId :: Prelude.Text
  }
  deriving (RejectCertificateTransfer -> RejectCertificateTransfer -> Bool
(RejectCertificateTransfer -> RejectCertificateTransfer -> Bool)
-> (RejectCertificateTransfer -> RejectCertificateTransfer -> Bool)
-> Eq RejectCertificateTransfer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RejectCertificateTransfer -> RejectCertificateTransfer -> Bool
$c/= :: RejectCertificateTransfer -> RejectCertificateTransfer -> Bool
== :: RejectCertificateTransfer -> RejectCertificateTransfer -> Bool
$c== :: RejectCertificateTransfer -> RejectCertificateTransfer -> Bool
Prelude.Eq, ReadPrec [RejectCertificateTransfer]
ReadPrec RejectCertificateTransfer
Int -> ReadS RejectCertificateTransfer
ReadS [RejectCertificateTransfer]
(Int -> ReadS RejectCertificateTransfer)
-> ReadS [RejectCertificateTransfer]
-> ReadPrec RejectCertificateTransfer
-> ReadPrec [RejectCertificateTransfer]
-> Read RejectCertificateTransfer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RejectCertificateTransfer]
$creadListPrec :: ReadPrec [RejectCertificateTransfer]
readPrec :: ReadPrec RejectCertificateTransfer
$creadPrec :: ReadPrec RejectCertificateTransfer
readList :: ReadS [RejectCertificateTransfer]
$creadList :: ReadS [RejectCertificateTransfer]
readsPrec :: Int -> ReadS RejectCertificateTransfer
$creadsPrec :: Int -> ReadS RejectCertificateTransfer
Prelude.Read, Int -> RejectCertificateTransfer -> ShowS
[RejectCertificateTransfer] -> ShowS
RejectCertificateTransfer -> String
(Int -> RejectCertificateTransfer -> ShowS)
-> (RejectCertificateTransfer -> String)
-> ([RejectCertificateTransfer] -> ShowS)
-> Show RejectCertificateTransfer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RejectCertificateTransfer] -> ShowS
$cshowList :: [RejectCertificateTransfer] -> ShowS
show :: RejectCertificateTransfer -> String
$cshow :: RejectCertificateTransfer -> String
showsPrec :: Int -> RejectCertificateTransfer -> ShowS
$cshowsPrec :: Int -> RejectCertificateTransfer -> ShowS
Prelude.Show, (forall x.
 RejectCertificateTransfer -> Rep RejectCertificateTransfer x)
-> (forall x.
    Rep RejectCertificateTransfer x -> RejectCertificateTransfer)
-> Generic RejectCertificateTransfer
forall x.
Rep RejectCertificateTransfer x -> RejectCertificateTransfer
forall x.
RejectCertificateTransfer -> Rep RejectCertificateTransfer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RejectCertificateTransfer x -> RejectCertificateTransfer
$cfrom :: forall x.
RejectCertificateTransfer -> Rep RejectCertificateTransfer x
Prelude.Generic)

-- |
-- Create a value of 'RejectCertificateTransfer' 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:
--
-- 'rejectReason', 'rejectCertificateTransfer_rejectReason' - The reason the certificate transfer was rejected.
--
-- 'certificateId', 'rejectCertificateTransfer_certificateId' - The ID of the certificate. (The last part of the certificate ARN
-- contains the certificate ID.)
newRejectCertificateTransfer ::
  -- | 'certificateId'
  Prelude.Text ->
  RejectCertificateTransfer
newRejectCertificateTransfer :: Text -> RejectCertificateTransfer
newRejectCertificateTransfer Text
pCertificateId_ =
  RejectCertificateTransfer' :: Maybe Text -> Text -> RejectCertificateTransfer
RejectCertificateTransfer'
    { $sel:rejectReason:RejectCertificateTransfer' :: Maybe Text
rejectReason =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateId:RejectCertificateTransfer' :: Text
certificateId = Text
pCertificateId_
    }

-- | The reason the certificate transfer was rejected.
rejectCertificateTransfer_rejectReason :: Lens.Lens' RejectCertificateTransfer (Prelude.Maybe Prelude.Text)
rejectCertificateTransfer_rejectReason :: (Maybe Text -> f (Maybe Text))
-> RejectCertificateTransfer -> f RejectCertificateTransfer
rejectCertificateTransfer_rejectReason = (RejectCertificateTransfer -> Maybe Text)
-> (RejectCertificateTransfer
    -> Maybe Text -> RejectCertificateTransfer)
-> Lens
     RejectCertificateTransfer
     RejectCertificateTransfer
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RejectCertificateTransfer' {Maybe Text
rejectReason :: Maybe Text
$sel:rejectReason:RejectCertificateTransfer' :: RejectCertificateTransfer -> Maybe Text
rejectReason} -> Maybe Text
rejectReason) (\s :: RejectCertificateTransfer
s@RejectCertificateTransfer' {} Maybe Text
a -> RejectCertificateTransfer
s {$sel:rejectReason:RejectCertificateTransfer' :: Maybe Text
rejectReason = Maybe Text
a} :: RejectCertificateTransfer)

-- | The ID of the certificate. (The last part of the certificate ARN
-- contains the certificate ID.)
rejectCertificateTransfer_certificateId :: Lens.Lens' RejectCertificateTransfer Prelude.Text
rejectCertificateTransfer_certificateId :: (Text -> f Text)
-> RejectCertificateTransfer -> f RejectCertificateTransfer
rejectCertificateTransfer_certificateId = (RejectCertificateTransfer -> Text)
-> (RejectCertificateTransfer -> Text -> RejectCertificateTransfer)
-> Lens
     RejectCertificateTransfer RejectCertificateTransfer Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RejectCertificateTransfer' {Text
certificateId :: Text
$sel:certificateId:RejectCertificateTransfer' :: RejectCertificateTransfer -> Text
certificateId} -> Text
certificateId) (\s :: RejectCertificateTransfer
s@RejectCertificateTransfer' {} Text
a -> RejectCertificateTransfer
s {$sel:certificateId:RejectCertificateTransfer' :: Text
certificateId = Text
a} :: RejectCertificateTransfer)

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

instance Prelude.Hashable RejectCertificateTransfer

instance Prelude.NFData RejectCertificateTransfer

instance Core.ToHeaders RejectCertificateTransfer where
  toHeaders :: RejectCertificateTransfer -> [Header]
toHeaders = [Header] -> RejectCertificateTransfer -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON RejectCertificateTransfer where
  toJSON :: RejectCertificateTransfer -> Value
toJSON RejectCertificateTransfer' {Maybe Text
Text
certificateId :: Text
rejectReason :: Maybe Text
$sel:certificateId:RejectCertificateTransfer' :: RejectCertificateTransfer -> Text
$sel:rejectReason:RejectCertificateTransfer' :: RejectCertificateTransfer -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"rejectReason" 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
rejectReason]
      )

instance Core.ToPath RejectCertificateTransfer where
  toPath :: RejectCertificateTransfer -> ByteString
toPath RejectCertificateTransfer' {Maybe Text
Text
certificateId :: Text
rejectReason :: Maybe Text
$sel:certificateId:RejectCertificateTransfer' :: RejectCertificateTransfer -> Text
$sel:rejectReason:RejectCertificateTransfer' :: RejectCertificateTransfer -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/reject-certificate-transfer/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
certificateId
      ]

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

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

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

instance
  Prelude.NFData
    RejectCertificateTransferResponse