module Aws.Sqs.Commands.Queue where
import Aws.Core
import Aws.Sqs.Core
import Control.Applicative
import Data.Maybe
import Prelude
import Text.XML.Cursor (($//), (&/))
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import qualified Text.XML.Cursor as Cu
import qualified Data.ByteString.Char8 as B
data CreateQueue = CreateQueue {
CreateQueue -> Maybe Int
cqDefaultVisibilityTimeout :: Maybe Int,
CreateQueue -> Text
cqQueueName :: T.Text
} deriving (Int -> CreateQueue -> ShowS
[CreateQueue] -> ShowS
CreateQueue -> String
(Int -> CreateQueue -> ShowS)
-> (CreateQueue -> String)
-> ([CreateQueue] -> ShowS)
-> Show CreateQueue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateQueue] -> ShowS
$cshowList :: [CreateQueue] -> ShowS
show :: CreateQueue -> String
$cshow :: CreateQueue -> String
showsPrec :: Int -> CreateQueue -> ShowS
$cshowsPrec :: Int -> CreateQueue -> ShowS
Show)
data CreateQueueResponse = CreateQueueResponse {
CreateQueueResponse -> Text
cqrQueueUrl :: T.Text
} deriving (Int -> CreateQueueResponse -> ShowS
[CreateQueueResponse] -> ShowS
CreateQueueResponse -> String
(Int -> CreateQueueResponse -> ShowS)
-> (CreateQueueResponse -> String)
-> ([CreateQueueResponse] -> ShowS)
-> Show CreateQueueResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateQueueResponse] -> ShowS
$cshowList :: [CreateQueueResponse] -> ShowS
show :: CreateQueueResponse -> String
$cshow :: CreateQueueResponse -> String
showsPrec :: Int -> CreateQueueResponse -> ShowS
$cshowsPrec :: Int -> CreateQueueResponse -> ShowS
Show)
instance ResponseConsumer r CreateQueueResponse where
type ResponseMetadata CreateQueueResponse = SqsMetadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata CreateQueueResponse)
-> HTTPResponseConsumer CreateQueueResponse
responseConsumer Request
_ r
_ = (Cursor -> Response SqsMetadata CreateQueueResponse)
-> IORef SqsMetadata -> HTTPResponseConsumer CreateQueueResponse
forall a.
(Cursor -> Response SqsMetadata a)
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsXmlResponseConsumer Cursor -> Response SqsMetadata CreateQueueResponse
forall (m :: * -> *).
MonadThrow m =>
Cursor -> m CreateQueueResponse
parse
where
parse :: Cursor -> m CreateQueueResponse
parse Cursor
el = do
Text
url <- String -> [Text] -> m Text
forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Queue Url" ([Text] -> m Text) -> [Text] -> m Text
forall a b. (a -> b) -> a -> b
$ Cursor
el Cursor -> (Cursor -> [Text]) -> [Text]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"QueueUrl" Axis -> (Cursor -> [Text]) -> Cursor -> [Text]
forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
CreateQueueResponse -> m CreateQueueResponse
forall (m :: * -> *) a. Monad m => a -> m a
return CreateQueueResponse :: Text -> CreateQueueResponse
CreateQueueResponse{ cqrQueueUrl :: Text
cqrQueueUrl = Text
url}
instance SignQuery CreateQueue where
type ServiceConfiguration CreateQueue = SqsConfiguration
signQuery :: CreateQueue
-> ServiceConfiguration CreateQueue queryType
-> SignatureData
-> SignedQuery
signQuery CreateQueue {Maybe Int
Text
cqQueueName :: Text
cqDefaultVisibilityTimeout :: Maybe Int
cqQueueName :: CreateQueue -> Text
cqDefaultVisibilityTimeout :: CreateQueue -> Maybe Int
..} = SqsQuery
-> SqsConfiguration queryType -> SignatureData -> SignedQuery
forall qt.
SqsQuery -> SqsConfiguration qt -> SignatureData -> SignedQuery
sqsSignQuery SqsQuery :: Maybe QueueName -> Query -> SqsQuery
SqsQuery {
sqsQueueName :: Maybe QueueName
sqsQueueName = Maybe QueueName
forall a. Maybe a
Nothing,
sqsQuery :: Query
sqsQuery = [(ByteString
"Action", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
"CreateQueue"),
(ByteString
"QueueName", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (ByteString -> Maybe ByteString) -> ByteString -> Maybe ByteString
forall a b. (a -> b) -> a -> b
$ Text -> ByteString
TE.encodeUtf8 Text
cqQueueName)] Query -> Query -> Query
forall a. [a] -> [a] -> [a]
++
[Maybe (ByteString, Maybe ByteString)] -> Query
forall a. [Maybe a] -> [a]
catMaybes [(ByteString
"DefaultVisibilityTimeout",) (Maybe ByteString -> (ByteString, Maybe ByteString))
-> Maybe (Maybe ByteString) -> Maybe (ByteString, Maybe ByteString)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case Maybe Int
cqDefaultVisibilityTimeout of
Just Int
x -> Maybe ByteString -> Maybe (Maybe ByteString)
forall a. a -> Maybe a
Just (Maybe ByteString -> Maybe (Maybe ByteString))
-> Maybe ByteString -> Maybe (Maybe ByteString)
forall a b. (a -> b) -> a -> b
$ ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (ByteString -> Maybe ByteString) -> ByteString -> Maybe ByteString
forall a b. (a -> b) -> a -> b
$ String -> ByteString
B.pack (String -> ByteString) -> String -> ByteString
forall a b. (a -> b) -> a -> b
$ Int -> String
forall a. Show a => a -> String
show Int
x
Maybe Int
Nothing -> Maybe (Maybe ByteString)
forall a. Maybe a
Nothing]}
instance Transaction CreateQueue CreateQueueResponse
instance AsMemoryResponse CreateQueueResponse where
type MemoryResponse CreateQueueResponse = CreateQueueResponse
loadToMemory :: CreateQueueResponse
-> ResourceT IO (MemoryResponse CreateQueueResponse)
loadToMemory = CreateQueueResponse
-> ResourceT IO (MemoryResponse CreateQueueResponse)
forall (m :: * -> *) a. Monad m => a -> m a
return
data DeleteQueue = DeleteQueue {
DeleteQueue -> QueueName
dqQueueName :: QueueName
} deriving (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
showList :: [DeleteQueue] -> ShowS
$cshowList :: [DeleteQueue] -> ShowS
show :: DeleteQueue -> String
$cshow :: DeleteQueue -> String
showsPrec :: Int -> DeleteQueue -> ShowS
$cshowsPrec :: Int -> DeleteQueue -> ShowS
Show)
data DeleteQueueResponse = DeleteQueueResponse
deriving (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
showList :: [DeleteQueueResponse] -> ShowS
$cshowList :: [DeleteQueueResponse] -> ShowS
show :: DeleteQueueResponse -> String
$cshow :: DeleteQueueResponse -> String
showsPrec :: Int -> DeleteQueueResponse -> ShowS
$cshowsPrec :: Int -> DeleteQueueResponse -> ShowS
Show)
instance ResponseConsumer r DeleteQueueResponse where
type ResponseMetadata DeleteQueueResponse = SqsMetadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata DeleteQueueResponse)
-> HTTPResponseConsumer DeleteQueueResponse
responseConsumer Request
_ r
_ = (Cursor -> Response SqsMetadata DeleteQueueResponse)
-> IORef SqsMetadata -> HTTPResponseConsumer DeleteQueueResponse
forall a.
(Cursor -> Response SqsMetadata a)
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsXmlResponseConsumer Cursor -> Response SqsMetadata DeleteQueueResponse
forall (m :: * -> *) p. Monad m => p -> m DeleteQueueResponse
parse
where
parse :: p -> m DeleteQueueResponse
parse p
_ = do DeleteQueueResponse -> m DeleteQueueResponse
forall (m :: * -> *) a. Monad m => a -> m a
return DeleteQueueResponse :: DeleteQueueResponse
DeleteQueueResponse{}
instance SignQuery DeleteQueue where
type ServiceConfiguration DeleteQueue = SqsConfiguration
signQuery :: DeleteQueue
-> ServiceConfiguration DeleteQueue queryType
-> SignatureData
-> SignedQuery
signQuery DeleteQueue {QueueName
dqQueueName :: QueueName
dqQueueName :: DeleteQueue -> QueueName
..} = SqsQuery
-> SqsConfiguration queryType -> SignatureData -> SignedQuery
forall qt.
SqsQuery -> SqsConfiguration qt -> SignatureData -> SignedQuery
sqsSignQuery SqsQuery :: Maybe QueueName -> Query -> SqsQuery
SqsQuery {
sqsQueueName :: Maybe QueueName
sqsQueueName = QueueName -> Maybe QueueName
forall a. a -> Maybe a
Just QueueName
dqQueueName,
sqsQuery :: Query
sqsQuery = [(ByteString
"Action", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
"DeleteQueue")]}
instance Transaction DeleteQueue DeleteQueueResponse
instance AsMemoryResponse DeleteQueueResponse where
type MemoryResponse DeleteQueueResponse = DeleteQueueResponse
loadToMemory :: DeleteQueueResponse
-> ResourceT IO (MemoryResponse DeleteQueueResponse)
loadToMemory = DeleteQueueResponse
-> ResourceT IO (MemoryResponse DeleteQueueResponse)
forall (m :: * -> *) a. Monad m => a -> m a
return
data ListQueues = ListQueues {
ListQueues -> Maybe Text
lqQueueNamePrefix :: Maybe T.Text
} deriving (Int -> ListQueues -> ShowS
[ListQueues] -> ShowS
ListQueues -> String
(Int -> ListQueues -> ShowS)
-> (ListQueues -> String)
-> ([ListQueues] -> ShowS)
-> Show ListQueues
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListQueues] -> ShowS
$cshowList :: [ListQueues] -> ShowS
show :: ListQueues -> String
$cshow :: ListQueues -> String
showsPrec :: Int -> ListQueues -> ShowS
$cshowsPrec :: Int -> ListQueues -> ShowS
Show)
data ListQueuesResponse = ListQueuesResponse {
ListQueuesResponse -> [Text]
lqrQueueUrls :: [T.Text]
} deriving (Int -> ListQueuesResponse -> ShowS
[ListQueuesResponse] -> ShowS
ListQueuesResponse -> String
(Int -> ListQueuesResponse -> ShowS)
-> (ListQueuesResponse -> String)
-> ([ListQueuesResponse] -> ShowS)
-> Show ListQueuesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListQueuesResponse] -> ShowS
$cshowList :: [ListQueuesResponse] -> ShowS
show :: ListQueuesResponse -> String
$cshow :: ListQueuesResponse -> String
showsPrec :: Int -> ListQueuesResponse -> ShowS
$cshowsPrec :: Int -> ListQueuesResponse -> ShowS
Show)
instance ResponseConsumer r ListQueuesResponse where
type ResponseMetadata ListQueuesResponse = SqsMetadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata ListQueuesResponse)
-> HTTPResponseConsumer ListQueuesResponse
responseConsumer Request
_ r
_ = (Cursor -> Response SqsMetadata ListQueuesResponse)
-> IORef SqsMetadata -> HTTPResponseConsumer ListQueuesResponse
forall a.
(Cursor -> Response SqsMetadata a)
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsXmlResponseConsumer Cursor -> Response SqsMetadata ListQueuesResponse
forall (m :: * -> *). Monad m => Cursor -> m ListQueuesResponse
parse
where
parse :: Cursor -> m ListQueuesResponse
parse Cursor
el = do
let queues :: [Text]
queues = Cursor
el Cursor -> (Cursor -> [Text]) -> [Text]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"QueueUrl" Axis -> (Cursor -> [Text]) -> Cursor -> [Text]
forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
ListQueuesResponse -> m ListQueuesResponse
forall (m :: * -> *) a. Monad m => a -> m a
return ListQueuesResponse :: [Text] -> ListQueuesResponse
ListQueuesResponse { lqrQueueUrls :: [Text]
lqrQueueUrls = [Text]
queues }
instance SignQuery ListQueues where
type ServiceConfiguration ListQueues = SqsConfiguration
signQuery :: ListQueues
-> ServiceConfiguration ListQueues queryType
-> SignatureData
-> SignedQuery
signQuery ListQueues{Maybe Text
lqQueueNamePrefix :: Maybe Text
lqQueueNamePrefix :: ListQueues -> Maybe Text
..} = SqsQuery
-> SqsConfiguration queryType -> SignatureData -> SignedQuery
forall qt.
SqsQuery -> SqsConfiguration qt -> SignatureData -> SignedQuery
sqsSignQuery SqsQuery :: Maybe QueueName -> Query -> SqsQuery
SqsQuery {
sqsQueueName :: Maybe QueueName
sqsQueueName = Maybe QueueName
forall a. Maybe a
Nothing,
sqsQuery :: Query
sqsQuery = [(ByteString
"Action", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
"ListQueues")] Query -> Query -> Query
forall a. [a] -> [a] -> [a]
++ [Maybe (ByteString, Maybe ByteString)] -> Query
forall a. [Maybe a] -> [a]
catMaybes [
(ByteString
"QueueNamePrefix",) (Maybe ByteString -> (ByteString, Maybe ByteString))
-> Maybe (Maybe ByteString) -> Maybe (ByteString, Maybe ByteString)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case Maybe Text
lqQueueNamePrefix of
Just Text
x -> Maybe ByteString -> Maybe (Maybe ByteString)
forall a. a -> Maybe a
Just (Maybe ByteString -> Maybe (Maybe ByteString))
-> Maybe ByteString -> Maybe (Maybe ByteString)
forall a b. (a -> b) -> a -> b
$ ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (ByteString -> Maybe ByteString) -> ByteString -> Maybe ByteString
forall a b. (a -> b) -> a -> b
$ Text -> ByteString
TE.encodeUtf8 Text
x
Maybe Text
Nothing -> Maybe (Maybe ByteString)
forall a. Maybe a
Nothing]}
instance Transaction ListQueues ListQueuesResponse
instance AsMemoryResponse ListQueuesResponse where
type MemoryResponse ListQueuesResponse = ListQueuesResponse
loadToMemory :: ListQueuesResponse
-> ResourceT IO (MemoryResponse ListQueuesResponse)
loadToMemory = ListQueuesResponse
-> ResourceT IO (MemoryResponse ListQueuesResponse)
forall (m :: * -> *) a. Monad m => a -> m a
return