{-# 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.CancelCertificateTransfer
-- 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)
--
-- Cancels a pending transfer for the specified certificate.
--
-- __Note__ Only the transfer source account can use this operation to
-- cancel a transfer. (Transfer destinations can use
-- RejectCertificateTransfer instead.) After transfer, IoT returns the
-- certificate to the source account in the INACTIVE state. After the
-- destination account has accepted the transfer, the transfer cannot be
-- cancelled.
--
-- After a certificate transfer is cancelled, the status of the certificate
-- changes from PENDING_TRANSFER to INACTIVE.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions CancelCertificateTransfer>
-- action.
module Amazonka.IoT.CancelCertificateTransfer
  ( -- * Creating a Request
    CancelCertificateTransfer (..),
    newCancelCertificateTransfer,

    -- * Request Lenses
    cancelCertificateTransfer_certificateId,

    -- * Destructuring the Response
    CancelCertificateTransferResponse (..),
    newCancelCertificateTransferResponse,
  )
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 CancelCertificateTransfer operation.
--
-- /See:/ 'newCancelCertificateTransfer' smart constructor.
data CancelCertificateTransfer = CancelCertificateTransfer'
  { -- | The ID of the certificate. (The last part of the certificate ARN
    -- contains the certificate ID.)
    CancelCertificateTransfer -> Text
certificateId :: Prelude.Text
  }
  deriving (CancelCertificateTransfer -> CancelCertificateTransfer -> Bool
(CancelCertificateTransfer -> CancelCertificateTransfer -> Bool)
-> (CancelCertificateTransfer -> CancelCertificateTransfer -> Bool)
-> Eq CancelCertificateTransfer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelCertificateTransfer -> CancelCertificateTransfer -> Bool
$c/= :: CancelCertificateTransfer -> CancelCertificateTransfer -> Bool
== :: CancelCertificateTransfer -> CancelCertificateTransfer -> Bool
$c== :: CancelCertificateTransfer -> CancelCertificateTransfer -> Bool
Prelude.Eq, ReadPrec [CancelCertificateTransfer]
ReadPrec CancelCertificateTransfer
Int -> ReadS CancelCertificateTransfer
ReadS [CancelCertificateTransfer]
(Int -> ReadS CancelCertificateTransfer)
-> ReadS [CancelCertificateTransfer]
-> ReadPrec CancelCertificateTransfer
-> ReadPrec [CancelCertificateTransfer]
-> Read CancelCertificateTransfer
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelCertificateTransfer]
$creadListPrec :: ReadPrec [CancelCertificateTransfer]
readPrec :: ReadPrec CancelCertificateTransfer
$creadPrec :: ReadPrec CancelCertificateTransfer
readList :: ReadS [CancelCertificateTransfer]
$creadList :: ReadS [CancelCertificateTransfer]
readsPrec :: Int -> ReadS CancelCertificateTransfer
$creadsPrec :: Int -> ReadS CancelCertificateTransfer
Prelude.Read, Int -> CancelCertificateTransfer -> ShowS
[CancelCertificateTransfer] -> ShowS
CancelCertificateTransfer -> String
(Int -> CancelCertificateTransfer -> ShowS)
-> (CancelCertificateTransfer -> String)
-> ([CancelCertificateTransfer] -> ShowS)
-> Show CancelCertificateTransfer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelCertificateTransfer] -> ShowS
$cshowList :: [CancelCertificateTransfer] -> ShowS
show :: CancelCertificateTransfer -> String
$cshow :: CancelCertificateTransfer -> String
showsPrec :: Int -> CancelCertificateTransfer -> ShowS
$cshowsPrec :: Int -> CancelCertificateTransfer -> ShowS
Prelude.Show, (forall x.
 CancelCertificateTransfer -> Rep CancelCertificateTransfer x)
-> (forall x.
    Rep CancelCertificateTransfer x -> CancelCertificateTransfer)
-> Generic CancelCertificateTransfer
forall x.
Rep CancelCertificateTransfer x -> CancelCertificateTransfer
forall x.
CancelCertificateTransfer -> Rep CancelCertificateTransfer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelCertificateTransfer x -> CancelCertificateTransfer
$cfrom :: forall x.
CancelCertificateTransfer -> Rep CancelCertificateTransfer x
Prelude.Generic)

-- |
-- Create a value of 'CancelCertificateTransfer' 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:
--
-- 'certificateId', 'cancelCertificateTransfer_certificateId' - The ID of the certificate. (The last part of the certificate ARN
-- contains the certificate ID.)
newCancelCertificateTransfer ::
  -- | 'certificateId'
  Prelude.Text ->
  CancelCertificateTransfer
newCancelCertificateTransfer :: Text -> CancelCertificateTransfer
newCancelCertificateTransfer Text
pCertificateId_ =
  CancelCertificateTransfer' :: Text -> CancelCertificateTransfer
CancelCertificateTransfer'
    { $sel:certificateId:CancelCertificateTransfer' :: Text
certificateId =
        Text
pCertificateId_
    }

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

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

instance Prelude.Hashable CancelCertificateTransfer

instance Prelude.NFData CancelCertificateTransfer

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

instance Core.ToJSON CancelCertificateTransfer where
  toJSON :: CancelCertificateTransfer -> Value
toJSON = Value -> CancelCertificateTransfer -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

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

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

instance
  Prelude.NFData
    CancelCertificateTransferResponse