{-# 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.AcceptCertificateTransfer
-- 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)
--
-- Accepts a pending certificate transfer. The default state of the
-- certificate is INACTIVE.
--
-- To check for pending certificate transfers, call ListCertificates to
-- enumerate your certificates.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions AcceptCertificateTransfer>
-- action.
module Amazonka.IoT.AcceptCertificateTransfer
  ( -- * Creating a Request
    AcceptCertificateTransfer (..),
    newAcceptCertificateTransfer,

    -- * Request Lenses
    acceptCertificateTransfer_setAsActive,
    acceptCertificateTransfer_certificateId,

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

-- |
-- Create a value of 'AcceptCertificateTransfer' 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:
--
-- 'setAsActive', 'acceptCertificateTransfer_setAsActive' - Specifies whether the certificate is active.
--
-- 'certificateId', 'acceptCertificateTransfer_certificateId' - The ID of the certificate. (The last part of the certificate ARN
-- contains the certificate ID.)
newAcceptCertificateTransfer ::
  -- | 'certificateId'
  Prelude.Text ->
  AcceptCertificateTransfer
newAcceptCertificateTransfer :: Text -> AcceptCertificateTransfer
newAcceptCertificateTransfer Text
pCertificateId_ =
  AcceptCertificateTransfer' :: Maybe Bool -> Text -> AcceptCertificateTransfer
AcceptCertificateTransfer'
    { $sel:setAsActive:AcceptCertificateTransfer' :: Maybe Bool
setAsActive =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateId:AcceptCertificateTransfer' :: Text
certificateId = Text
pCertificateId_
    }

-- | Specifies whether the certificate is active.
acceptCertificateTransfer_setAsActive :: Lens.Lens' AcceptCertificateTransfer (Prelude.Maybe Prelude.Bool)
acceptCertificateTransfer_setAsActive :: (Maybe Bool -> f (Maybe Bool))
-> AcceptCertificateTransfer -> f AcceptCertificateTransfer
acceptCertificateTransfer_setAsActive = (AcceptCertificateTransfer -> Maybe Bool)
-> (AcceptCertificateTransfer
    -> Maybe Bool -> AcceptCertificateTransfer)
-> Lens
     AcceptCertificateTransfer
     AcceptCertificateTransfer
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AcceptCertificateTransfer' {Maybe Bool
setAsActive :: Maybe Bool
$sel:setAsActive:AcceptCertificateTransfer' :: AcceptCertificateTransfer -> Maybe Bool
setAsActive} -> Maybe Bool
setAsActive) (\s :: AcceptCertificateTransfer
s@AcceptCertificateTransfer' {} Maybe Bool
a -> AcceptCertificateTransfer
s {$sel:setAsActive:AcceptCertificateTransfer' :: Maybe Bool
setAsActive = Maybe Bool
a} :: AcceptCertificateTransfer)

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

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

instance Prelude.Hashable AcceptCertificateTransfer

instance Prelude.NFData AcceptCertificateTransfer

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

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

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

instance Core.ToQuery AcceptCertificateTransfer where
  toQuery :: AcceptCertificateTransfer -> QueryString
toQuery AcceptCertificateTransfer' {Maybe Bool
Text
certificateId :: Text
setAsActive :: Maybe Bool
$sel:certificateId:AcceptCertificateTransfer' :: AcceptCertificateTransfer -> Text
$sel:setAsActive:AcceptCertificateTransfer' :: AcceptCertificateTransfer -> Maybe Bool
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"setAsActive" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
setAsActive]

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

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

instance
  Prelude.NFData
    AcceptCertificateTransferResponse