{-# 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.SNS.DeleteTopic
-- 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)
--
-- Deletes a topic and all its subscriptions. Deleting a topic might
-- prevent some messages previously sent to the topic from being delivered
-- to subscribers. This action is idempotent, so deleting a topic that does
-- not exist does not result in an error.
module Amazonka.SNS.DeleteTopic
  ( -- * Creating a Request
    DeleteTopic (..),
    newDeleteTopic,

    -- * Request Lenses
    deleteTopic_topicArn,

    -- * Destructuring the Response
    DeleteTopicResponse (..),
    newDeleteTopicResponse,
  )
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.SNS.Types

-- | /See:/ 'newDeleteTopic' smart constructor.
data DeleteTopic = DeleteTopic'
  { -- | The ARN of the topic you want to delete.
    DeleteTopic -> Text
topicArn :: Prelude.Text
  }
  deriving (DeleteTopic -> DeleteTopic -> Bool
(DeleteTopic -> DeleteTopic -> Bool)
-> (DeleteTopic -> DeleteTopic -> Bool) -> Eq DeleteTopic
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteTopic -> DeleteTopic -> Bool
$c/= :: DeleteTopic -> DeleteTopic -> Bool
== :: DeleteTopic -> DeleteTopic -> Bool
$c== :: DeleteTopic -> DeleteTopic -> Bool
Prelude.Eq, ReadPrec [DeleteTopic]
ReadPrec DeleteTopic
Int -> ReadS DeleteTopic
ReadS [DeleteTopic]
(Int -> ReadS DeleteTopic)
-> ReadS [DeleteTopic]
-> ReadPrec DeleteTopic
-> ReadPrec [DeleteTopic]
-> Read DeleteTopic
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteTopic]
$creadListPrec :: ReadPrec [DeleteTopic]
readPrec :: ReadPrec DeleteTopic
$creadPrec :: ReadPrec DeleteTopic
readList :: ReadS [DeleteTopic]
$creadList :: ReadS [DeleteTopic]
readsPrec :: Int -> ReadS DeleteTopic
$creadsPrec :: Int -> ReadS DeleteTopic
Prelude.Read, Int -> DeleteTopic -> ShowS
[DeleteTopic] -> ShowS
DeleteTopic -> String
(Int -> DeleteTopic -> ShowS)
-> (DeleteTopic -> String)
-> ([DeleteTopic] -> ShowS)
-> Show DeleteTopic
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteTopic] -> ShowS
$cshowList :: [DeleteTopic] -> ShowS
show :: DeleteTopic -> String
$cshow :: DeleteTopic -> String
showsPrec :: Int -> DeleteTopic -> ShowS
$cshowsPrec :: Int -> DeleteTopic -> ShowS
Prelude.Show, (forall x. DeleteTopic -> Rep DeleteTopic x)
-> (forall x. Rep DeleteTopic x -> DeleteTopic)
-> Generic DeleteTopic
forall x. Rep DeleteTopic x -> DeleteTopic
forall x. DeleteTopic -> Rep DeleteTopic x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteTopic x -> DeleteTopic
$cfrom :: forall x. DeleteTopic -> Rep DeleteTopic x
Prelude.Generic)

-- |
-- Create a value of 'DeleteTopic' 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:
--
-- 'topicArn', 'deleteTopic_topicArn' - The ARN of the topic you want to delete.
newDeleteTopic ::
  -- | 'topicArn'
  Prelude.Text ->
  DeleteTopic
newDeleteTopic :: Text -> DeleteTopic
newDeleteTopic Text
pTopicArn_ =
  DeleteTopic' :: Text -> DeleteTopic
DeleteTopic' {$sel:topicArn:DeleteTopic' :: Text
topicArn = Text
pTopicArn_}

-- | The ARN of the topic you want to delete.
deleteTopic_topicArn :: Lens.Lens' DeleteTopic Prelude.Text
deleteTopic_topicArn :: (Text -> f Text) -> DeleteTopic -> f DeleteTopic
deleteTopic_topicArn = (DeleteTopic -> Text)
-> (DeleteTopic -> Text -> DeleteTopic)
-> Lens DeleteTopic DeleteTopic Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteTopic' {Text
topicArn :: Text
$sel:topicArn:DeleteTopic' :: DeleteTopic -> Text
topicArn} -> Text
topicArn) (\s :: DeleteTopic
s@DeleteTopic' {} Text
a -> DeleteTopic
s {$sel:topicArn:DeleteTopic' :: Text
topicArn = Text
a} :: DeleteTopic)

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

instance Prelude.Hashable DeleteTopic

instance Prelude.NFData DeleteTopic

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

instance Core.ToPath DeleteTopic where
  toPath :: DeleteTopic -> ByteString
toPath = ByteString -> DeleteTopic -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DeleteTopic where
  toQuery :: DeleteTopic -> QueryString
toQuery DeleteTopic' {Text
topicArn :: Text
$sel:topicArn:DeleteTopic' :: DeleteTopic -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DeleteTopic" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
        ByteString
"TopicArn" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
topicArn
      ]

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

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

instance Prelude.NFData DeleteTopicResponse