{-# 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.ConfirmTopicRuleDestination
-- 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)
--
-- Confirms a topic rule destination. When you create a rule requiring a
-- destination, IoT sends a confirmation message to the endpoint or base
-- address you specify. The message includes a token which you pass back
-- when calling @ConfirmTopicRuleDestination@ to confirm that you own or
-- have access to the endpoint.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions ConfirmTopicRuleDestination>
-- action.
module Amazonka.IoT.ConfirmTopicRuleDestination
  ( -- * Creating a Request
    ConfirmTopicRuleDestination (..),
    newConfirmTopicRuleDestination,

    -- * Request Lenses
    confirmTopicRuleDestination_confirmationToken,

    -- * Destructuring the Response
    ConfirmTopicRuleDestinationResponse (..),
    newConfirmTopicRuleDestinationResponse,

    -- * Response Lenses
    confirmTopicRuleDestinationResponse_httpStatus,
  )
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

-- | /See:/ 'newConfirmTopicRuleDestination' smart constructor.
data ConfirmTopicRuleDestination = ConfirmTopicRuleDestination'
  { -- | The token used to confirm ownership or access to the topic rule
    -- confirmation URL.
    ConfirmTopicRuleDestination -> Text
confirmationToken :: Prelude.Text
  }
  deriving (ConfirmTopicRuleDestination -> ConfirmTopicRuleDestination -> Bool
(ConfirmTopicRuleDestination
 -> ConfirmTopicRuleDestination -> Bool)
-> (ConfirmTopicRuleDestination
    -> ConfirmTopicRuleDestination -> Bool)
-> Eq ConfirmTopicRuleDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConfirmTopicRuleDestination -> ConfirmTopicRuleDestination -> Bool
$c/= :: ConfirmTopicRuleDestination -> ConfirmTopicRuleDestination -> Bool
== :: ConfirmTopicRuleDestination -> ConfirmTopicRuleDestination -> Bool
$c== :: ConfirmTopicRuleDestination -> ConfirmTopicRuleDestination -> Bool
Prelude.Eq, ReadPrec [ConfirmTopicRuleDestination]
ReadPrec ConfirmTopicRuleDestination
Int -> ReadS ConfirmTopicRuleDestination
ReadS [ConfirmTopicRuleDestination]
(Int -> ReadS ConfirmTopicRuleDestination)
-> ReadS [ConfirmTopicRuleDestination]
-> ReadPrec ConfirmTopicRuleDestination
-> ReadPrec [ConfirmTopicRuleDestination]
-> Read ConfirmTopicRuleDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConfirmTopicRuleDestination]
$creadListPrec :: ReadPrec [ConfirmTopicRuleDestination]
readPrec :: ReadPrec ConfirmTopicRuleDestination
$creadPrec :: ReadPrec ConfirmTopicRuleDestination
readList :: ReadS [ConfirmTopicRuleDestination]
$creadList :: ReadS [ConfirmTopicRuleDestination]
readsPrec :: Int -> ReadS ConfirmTopicRuleDestination
$creadsPrec :: Int -> ReadS ConfirmTopicRuleDestination
Prelude.Read, Int -> ConfirmTopicRuleDestination -> ShowS
[ConfirmTopicRuleDestination] -> ShowS
ConfirmTopicRuleDestination -> String
(Int -> ConfirmTopicRuleDestination -> ShowS)
-> (ConfirmTopicRuleDestination -> String)
-> ([ConfirmTopicRuleDestination] -> ShowS)
-> Show ConfirmTopicRuleDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConfirmTopicRuleDestination] -> ShowS
$cshowList :: [ConfirmTopicRuleDestination] -> ShowS
show :: ConfirmTopicRuleDestination -> String
$cshow :: ConfirmTopicRuleDestination -> String
showsPrec :: Int -> ConfirmTopicRuleDestination -> ShowS
$cshowsPrec :: Int -> ConfirmTopicRuleDestination -> ShowS
Prelude.Show, (forall x.
 ConfirmTopicRuleDestination -> Rep ConfirmTopicRuleDestination x)
-> (forall x.
    Rep ConfirmTopicRuleDestination x -> ConfirmTopicRuleDestination)
-> Generic ConfirmTopicRuleDestination
forall x.
Rep ConfirmTopicRuleDestination x -> ConfirmTopicRuleDestination
forall x.
ConfirmTopicRuleDestination -> Rep ConfirmTopicRuleDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ConfirmTopicRuleDestination x -> ConfirmTopicRuleDestination
$cfrom :: forall x.
ConfirmTopicRuleDestination -> Rep ConfirmTopicRuleDestination x
Prelude.Generic)

-- |
-- Create a value of 'ConfirmTopicRuleDestination' 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:
--
-- 'confirmationToken', 'confirmTopicRuleDestination_confirmationToken' - The token used to confirm ownership or access to the topic rule
-- confirmation URL.
newConfirmTopicRuleDestination ::
  -- | 'confirmationToken'
  Prelude.Text ->
  ConfirmTopicRuleDestination
newConfirmTopicRuleDestination :: Text -> ConfirmTopicRuleDestination
newConfirmTopicRuleDestination Text
pConfirmationToken_ =
  ConfirmTopicRuleDestination' :: Text -> ConfirmTopicRuleDestination
ConfirmTopicRuleDestination'
    { $sel:confirmationToken:ConfirmTopicRuleDestination' :: Text
confirmationToken =
        Text
pConfirmationToken_
    }

-- | The token used to confirm ownership or access to the topic rule
-- confirmation URL.
confirmTopicRuleDestination_confirmationToken :: Lens.Lens' ConfirmTopicRuleDestination Prelude.Text
confirmTopicRuleDestination_confirmationToken :: (Text -> f Text)
-> ConfirmTopicRuleDestination -> f ConfirmTopicRuleDestination
confirmTopicRuleDestination_confirmationToken = (ConfirmTopicRuleDestination -> Text)
-> (ConfirmTopicRuleDestination
    -> Text -> ConfirmTopicRuleDestination)
-> Lens
     ConfirmTopicRuleDestination ConfirmTopicRuleDestination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConfirmTopicRuleDestination' {Text
confirmationToken :: Text
$sel:confirmationToken:ConfirmTopicRuleDestination' :: ConfirmTopicRuleDestination -> Text
confirmationToken} -> Text
confirmationToken) (\s :: ConfirmTopicRuleDestination
s@ConfirmTopicRuleDestination' {} Text
a -> ConfirmTopicRuleDestination
s {$sel:confirmationToken:ConfirmTopicRuleDestination' :: Text
confirmationToken = Text
a} :: ConfirmTopicRuleDestination)

instance Core.AWSRequest ConfirmTopicRuleDestination where
  type
    AWSResponse ConfirmTopicRuleDestination =
      ConfirmTopicRuleDestinationResponse
  request :: ConfirmTopicRuleDestination -> Request ConfirmTopicRuleDestination
request = Service
-> ConfirmTopicRuleDestination
-> Request ConfirmTopicRuleDestination
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ConfirmTopicRuleDestination
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ConfirmTopicRuleDestination)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse ConfirmTopicRuleDestination))
-> Logger
-> Service
-> Proxy ConfirmTopicRuleDestination
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ConfirmTopicRuleDestination)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> ConfirmTopicRuleDestinationResponse
ConfirmTopicRuleDestinationResponse'
            (Int -> ConfirmTopicRuleDestinationResponse)
-> Either String Int
-> Either String ConfirmTopicRuleDestinationResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ConfirmTopicRuleDestination

instance Prelude.NFData ConfirmTopicRuleDestination

instance Core.ToHeaders ConfirmTopicRuleDestination where
  toHeaders :: ConfirmTopicRuleDestination -> ResponseHeaders
toHeaders = ResponseHeaders -> ConfirmTopicRuleDestination -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath ConfirmTopicRuleDestination where
  toPath :: ConfirmTopicRuleDestination -> ByteString
toPath ConfirmTopicRuleDestination' {Text
confirmationToken :: Text
$sel:confirmationToken:ConfirmTopicRuleDestination' :: ConfirmTopicRuleDestination -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/confirmdestination/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
confirmationToken]

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

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

-- |
-- Create a value of 'ConfirmTopicRuleDestinationResponse' 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:
--
-- 'httpStatus', 'confirmTopicRuleDestinationResponse_httpStatus' - The response's http status code.
newConfirmTopicRuleDestinationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ConfirmTopicRuleDestinationResponse
newConfirmTopicRuleDestinationResponse :: Int -> ConfirmTopicRuleDestinationResponse
newConfirmTopicRuleDestinationResponse Int
pHttpStatus_ =
  ConfirmTopicRuleDestinationResponse' :: Int -> ConfirmTopicRuleDestinationResponse
ConfirmTopicRuleDestinationResponse'
    { $sel:httpStatus:ConfirmTopicRuleDestinationResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    ConfirmTopicRuleDestinationResponse