{-# 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.SQS.DeleteQueue
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the queue specified by the @QueueUrl@, regardless of the
-- queue\'s contents.
--
-- Be careful with the @DeleteQueue@ action: When you delete a queue, any
-- messages in the queue are no longer available.
--
-- When you delete a queue, the deletion process takes up to 60 seconds.
-- Requests you send involving that queue during the 60 seconds might
-- succeed. For example, a @ @@SendMessage@@ @ request might succeed, but
-- after 60 seconds the queue and the message you sent no longer exist.
--
-- When you delete a queue, you must wait at least 60 seconds before
-- creating a queue with the same name.
--
-- Cross-account permissions don\'t apply to this action. For more
-- information, see
-- <https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name Grant cross-account permissions to a role and a user name>
-- in the /Amazon SQS Developer Guide/.
module Amazonka.SQS.DeleteQueue
  ( -- * Creating a Request
    DeleteQueue (..),
    newDeleteQueue,

    -- * Request Lenses
    deleteQueue_queueUrl,

    -- * Destructuring the Response
    DeleteQueueResponse (..),
    newDeleteQueueResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SQS.Types

-- |
--
-- /See:/ 'newDeleteQueue' smart constructor.
data DeleteQueue = DeleteQueue'
  { -- | The URL of the Amazon SQS queue to delete.
    --
    -- Queue URLs and names are case-sensitive.
    DeleteQueue -> Text
queueUrl :: Prelude.Text
  }
  deriving (DeleteQueue -> DeleteQueue -> Bool
(DeleteQueue -> DeleteQueue -> Bool)
-> (DeleteQueue -> DeleteQueue -> Bool) -> Eq DeleteQueue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DeleteQueue -> DeleteQueue -> Bool
== :: DeleteQueue -> DeleteQueue -> Bool
$c/= :: DeleteQueue -> DeleteQueue -> Bool
/= :: DeleteQueue -> DeleteQueue -> Bool
Prelude.Eq, ReadPrec [DeleteQueue]
ReadPrec DeleteQueue
Int -> ReadS DeleteQueue
ReadS [DeleteQueue]
(Int -> ReadS DeleteQueue)
-> ReadS [DeleteQueue]
-> ReadPrec DeleteQueue
-> ReadPrec [DeleteQueue]
-> Read DeleteQueue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS DeleteQueue
readsPrec :: Int -> ReadS DeleteQueue
$creadList :: ReadS [DeleteQueue]
readList :: ReadS [DeleteQueue]
$creadPrec :: ReadPrec DeleteQueue
readPrec :: ReadPrec DeleteQueue
$creadListPrec :: ReadPrec [DeleteQueue]
readListPrec :: ReadPrec [DeleteQueue]
Prelude.Read, Int -> DeleteQueue -> ShowS
[DeleteQueue] -> ShowS
DeleteQueue -> String
(Int -> DeleteQueue -> ShowS)
-> (DeleteQueue -> String)
-> ([DeleteQueue] -> ShowS)
-> Show DeleteQueue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DeleteQueue -> ShowS
showsPrec :: Int -> DeleteQueue -> ShowS
$cshow :: DeleteQueue -> String
show :: DeleteQueue -> String
$cshowList :: [DeleteQueue] -> ShowS
showList :: [DeleteQueue] -> ShowS
Prelude.Show, (forall x. DeleteQueue -> Rep DeleteQueue x)
-> (forall x. Rep DeleteQueue x -> DeleteQueue)
-> Generic DeleteQueue
forall x. Rep DeleteQueue x -> DeleteQueue
forall x. DeleteQueue -> Rep DeleteQueue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DeleteQueue -> Rep DeleteQueue x
from :: forall x. DeleteQueue -> Rep DeleteQueue x
$cto :: forall x. Rep DeleteQueue x -> DeleteQueue
to :: forall x. Rep DeleteQueue x -> DeleteQueue
Prelude.Generic)

-- |
-- Create a value of 'DeleteQueue' 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:
--
-- 'queueUrl', 'deleteQueue_queueUrl' - The URL of the Amazon SQS queue to delete.
--
-- Queue URLs and names are case-sensitive.
newDeleteQueue ::
  -- | 'queueUrl'
  Prelude.Text ->
  DeleteQueue
newDeleteQueue :: Text -> DeleteQueue
newDeleteQueue Text
pQueueUrl_ =
  DeleteQueue' {$sel:queueUrl:DeleteQueue' :: Text
queueUrl = Text
pQueueUrl_}

-- | The URL of the Amazon SQS queue to delete.
--
-- Queue URLs and names are case-sensitive.
deleteQueue_queueUrl :: Lens.Lens' DeleteQueue Prelude.Text
deleteQueue_queueUrl :: Lens' DeleteQueue Text
deleteQueue_queueUrl = (DeleteQueue -> Text)
-> (DeleteQueue -> Text -> DeleteQueue) -> Lens' DeleteQueue Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteQueue' {Text
$sel:queueUrl:DeleteQueue' :: DeleteQueue -> Text
queueUrl :: Text
queueUrl} -> Text
queueUrl) (\s :: DeleteQueue
s@DeleteQueue' {} Text
a -> DeleteQueue
s {queueUrl = a} :: DeleteQueue)

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

instance Prelude.Hashable DeleteQueue where
  hashWithSalt :: Int -> DeleteQueue -> Int
hashWithSalt Int
_salt DeleteQueue' {Text
$sel:queueUrl:DeleteQueue' :: DeleteQueue -> Text
queueUrl :: Text
..} =
    Int
_salt Int -> Text -> Int
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
queueUrl

instance Prelude.NFData DeleteQueue where
  rnf :: DeleteQueue -> ()
rnf DeleteQueue' {Text
$sel:queueUrl:DeleteQueue' :: DeleteQueue -> Text
queueUrl :: Text
..} = Text -> ()
forall a. NFData a => a -> ()
Prelude.rnf Text
queueUrl

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

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

instance Data.ToQuery DeleteQueue where
  toQuery :: DeleteQueue -> QueryString
toQuery DeleteQueue' {Text
$sel:queueUrl:DeleteQueue' :: DeleteQueue -> Text
queueUrl :: Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"DeleteQueue" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2012-11-05" :: Prelude.ByteString),
        ByteString
"QueueUrl" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
queueUrl
      ]

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

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

instance Prelude.NFData DeleteQueueResponse where
  rnf :: DeleteQueueResponse -> ()
rnf DeleteQueueResponse
_ = ()