{-# 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.PurgeQueue
-- 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 the messages in a queue specified by the @QueueURL@ parameter.
--
-- When you use the @PurgeQueue@ action, you can\'t retrieve any messages
-- deleted from a queue.
--
-- The message deletion process takes up to 60 seconds. We recommend
-- waiting for 60 seconds regardless of your queue\'s size.
--
-- Messages sent to the queue /before/ you call @PurgeQueue@ might be
-- received but are deleted within the next minute.
--
-- Messages sent to the queue /after/ you call @PurgeQueue@ might be
-- deleted while the queue is being purged.
module Amazonka.SQS.PurgeQueue
  ( -- * Creating a Request
    PurgeQueue (..),
    newPurgeQueue,

    -- * Request Lenses
    purgeQueue_queueUrl,

    -- * Destructuring the Response
    PurgeQueueResponse (..),
    newPurgeQueueResponse,
  )
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.SQS.Types

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

-- |
-- Create a value of 'PurgeQueue' 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', 'purgeQueue_queueUrl' - The URL of the queue from which the @PurgeQueue@ action deletes
-- messages.
--
-- Queue URLs and names are case-sensitive.
newPurgeQueue ::
  -- | 'queueUrl'
  Prelude.Text ->
  PurgeQueue
newPurgeQueue :: Text -> PurgeQueue
newPurgeQueue Text
pQueueUrl_ =
  PurgeQueue' :: Text -> PurgeQueue
PurgeQueue' {$sel:queueUrl:PurgeQueue' :: Text
queueUrl = Text
pQueueUrl_}

-- | The URL of the queue from which the @PurgeQueue@ action deletes
-- messages.
--
-- Queue URLs and names are case-sensitive.
purgeQueue_queueUrl :: Lens.Lens' PurgeQueue Prelude.Text
purgeQueue_queueUrl :: (Text -> f Text) -> PurgeQueue -> f PurgeQueue
purgeQueue_queueUrl = (PurgeQueue -> Text)
-> (PurgeQueue -> Text -> PurgeQueue)
-> Lens PurgeQueue PurgeQueue Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PurgeQueue' {Text
queueUrl :: Text
$sel:queueUrl:PurgeQueue' :: PurgeQueue -> Text
queueUrl} -> Text
queueUrl) (\s :: PurgeQueue
s@PurgeQueue' {} Text
a -> PurgeQueue
s {$sel:queueUrl:PurgeQueue' :: Text
queueUrl = Text
a} :: PurgeQueue)

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

instance Prelude.Hashable PurgeQueue

instance Prelude.NFData PurgeQueue

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

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

instance Core.ToQuery PurgeQueue where
  toQuery :: PurgeQueue -> QueryString
toQuery PurgeQueue' {Text
queueUrl :: Text
$sel:queueUrl:PurgeQueue' :: PurgeQueue -> 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
"PurgeQueue" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-11-05" :: Prelude.ByteString),
        ByteString
"QueueUrl" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
queueUrl
      ]

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

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

instance Prelude.NFData PurgeQueueResponse