module Aws.Sqs.Commands.Message
(
UserMessageAttributeCustomType
, UserMessageAttributeValue(..)
, UserMessageAttributeName
, UserMessageAttribute
, SendMessage(..)
, SendMessageResponse(..)
, DeleteMessage(..)
, DeleteMessageResponse(..)
, Message(..)
, ReceiveMessage(..)
, ReceiveMessageResponse(..)
, ChangeMessageVisibility(..)
, ChangeMessageVisibilityResponse(..)
) where
import Aws.Core
import Aws.Sqs.Core
import Control.Applicative
import Control.Monad.Trans.Resource (throwM)
import Data.Maybe
import Data.Monoid
import Text.XML.Cursor (($/), ($//), (&/), (&|))
import qualified Data.ByteString.Base64 as B64
import qualified Data.ByteString.Char8 as B
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import Data.Scientific
import qualified Network.HTTP.Types as HTTP
import Text.Read (readEither)
import qualified Text.XML.Cursor as Cu
import Prelude
type UserMessageAttributeCustomType = T.Text
data UserMessageAttributeValue
= UserMessageAttributeString (Maybe UserMessageAttributeCustomType) T.Text
| UserMessageAttributeNumber (Maybe UserMessageAttributeCustomType) Scientific
| UserMessageAttributeBinary (Maybe UserMessageAttributeCustomType) B.ByteString
deriving (Int -> UserMessageAttributeValue -> ShowS
[UserMessageAttributeValue] -> ShowS
UserMessageAttributeValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UserMessageAttributeValue] -> ShowS
$cshowList :: [UserMessageAttributeValue] -> ShowS
show :: UserMessageAttributeValue -> String
$cshow :: UserMessageAttributeValue -> String
showsPrec :: Int -> UserMessageAttributeValue -> ShowS
$cshowsPrec :: Int -> UserMessageAttributeValue -> ShowS
Show, ReadPrec [UserMessageAttributeValue]
ReadPrec UserMessageAttributeValue
Int -> ReadS UserMessageAttributeValue
ReadS [UserMessageAttributeValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UserMessageAttributeValue]
$creadListPrec :: ReadPrec [UserMessageAttributeValue]
readPrec :: ReadPrec UserMessageAttributeValue
$creadPrec :: ReadPrec UserMessageAttributeValue
readList :: ReadS [UserMessageAttributeValue]
$creadList :: ReadS [UserMessageAttributeValue]
readsPrec :: Int -> ReadS UserMessageAttributeValue
$creadsPrec :: Int -> ReadS UserMessageAttributeValue
Read, UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
$c/= :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
== :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
$c== :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
Eq, Eq UserMessageAttributeValue
UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
UserMessageAttributeValue -> UserMessageAttributeValue -> Ordering
UserMessageAttributeValue
-> UserMessageAttributeValue -> UserMessageAttributeValue
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: UserMessageAttributeValue
-> UserMessageAttributeValue -> UserMessageAttributeValue
$cmin :: UserMessageAttributeValue
-> UserMessageAttributeValue -> UserMessageAttributeValue
max :: UserMessageAttributeValue
-> UserMessageAttributeValue -> UserMessageAttributeValue
$cmax :: UserMessageAttributeValue
-> UserMessageAttributeValue -> UserMessageAttributeValue
>= :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
$c>= :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
> :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
$c> :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
<= :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
$c<= :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
< :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
$c< :: UserMessageAttributeValue -> UserMessageAttributeValue -> Bool
compare :: UserMessageAttributeValue -> UserMessageAttributeValue -> Ordering
$ccompare :: UserMessageAttributeValue -> UserMessageAttributeValue -> Ordering
Ord)
type UserMessageAttributeName = T.Text
type UserMessageAttribute = (UserMessageAttributeName, UserMessageAttributeValue)
userMessageAttributesQuery :: [UserMessageAttribute] -> HTTP.Query
userMessageAttributesQuery :: [UserMessageAttribute] -> Query
userMessageAttributesQuery = forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall {a}. Show a => a -> UserMessageAttribute -> Query
msgAttrQuery [Int
1 :: Int ..]
where
msgAttrQuery :: a -> UserMessageAttribute -> Query
msgAttrQuery a
i (Text
name, UserMessageAttributeValue
value) =
[ ( ByteString
pre forall a. Semigroup a => a -> a -> a
<> ByteString
"Name", forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Text -> ByteString
TE.encodeUtf8 Text
name )
, ( ByteString
pre forall a. Semigroup a => a -> a -> a
<> ByteString
"Value.DataType", forall a. a -> Maybe a
Just ByteString
typ )
, ( ByteString
pre forall a. Semigroup a => a -> a -> a
<> ByteString
"Value." forall a. Semigroup a => a -> a -> a
<> ByteString
valueKey, forall a. a -> Maybe a
Just ByteString
encodedValue )
]
where
pre :: ByteString
pre = ByteString
"MessageAttribute." forall a. Semigroup a => a -> a -> a
<> String -> ByteString
B.pack (forall a. Show a => a -> String
show a
i) forall a. Semigroup a => a -> a -> a
<> ByteString
"."
customType :: Maybe Text -> Text -> ByteString
customType Maybe Text
Nothing Text
t = Text -> ByteString
TE.encodeUtf8 Text
t
customType (Just Text
c) Text
t = Text -> ByteString
TE.encodeUtf8 forall a b. (a -> b) -> a -> b
$ Text
t forall a. Semigroup a => a -> a -> a
<> Text
"." forall a. Semigroup a => a -> a -> a
<> Text
c
(ByteString
typ, ByteString
valueKey, ByteString
encodedValue) = case UserMessageAttributeValue
value of
UserMessageAttributeString Maybe Text
c Text
t ->
(Maybe Text -> Text -> ByteString
customType Maybe Text
c Text
"String", ByteString
"StringValue", Text -> ByteString
TE.encodeUtf8 Text
t)
UserMessageAttributeNumber Maybe Text
c Scientific
n ->
(Maybe Text -> Text -> ByteString
customType Maybe Text
c Text
"Number", ByteString
"StringValue", String -> ByteString
B.pack forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show Scientific
n)
UserMessageAttributeBinary Maybe Text
c ByteString
b ->
(Maybe Text -> Text -> ByteString
customType Maybe Text
c Text
"Binary", ByteString
"BinaryValue", ByteString
b)
data SendMessage = SendMessage
{ SendMessage -> Text
smMessage :: !T.Text
, SendMessage -> QueueName
smQueueName :: !QueueName
, SendMessage -> [UserMessageAttribute]
smAttributes :: ![UserMessageAttribute]
, SendMessage -> Maybe Int
smDelaySeconds :: !(Maybe Int)
}
deriving (Int -> SendMessage -> ShowS
[SendMessage] -> ShowS
SendMessage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendMessage] -> ShowS
$cshowList :: [SendMessage] -> ShowS
show :: SendMessage -> String
$cshow :: SendMessage -> String
showsPrec :: Int -> SendMessage -> ShowS
$cshowsPrec :: Int -> SendMessage -> ShowS
Show, ReadPrec [SendMessage]
ReadPrec SendMessage
Int -> ReadS SendMessage
ReadS [SendMessage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendMessage]
$creadListPrec :: ReadPrec [SendMessage]
readPrec :: ReadPrec SendMessage
$creadPrec :: ReadPrec SendMessage
readList :: ReadS [SendMessage]
$creadList :: ReadS [SendMessage]
readsPrec :: Int -> ReadS SendMessage
$creadsPrec :: Int -> ReadS SendMessage
Read, SendMessage -> SendMessage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendMessage -> SendMessage -> Bool
$c/= :: SendMessage -> SendMessage -> Bool
== :: SendMessage -> SendMessage -> Bool
$c== :: SendMessage -> SendMessage -> Bool
Eq, Eq SendMessage
SendMessage -> SendMessage -> Bool
SendMessage -> SendMessage -> Ordering
SendMessage -> SendMessage -> SendMessage
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SendMessage -> SendMessage -> SendMessage
$cmin :: SendMessage -> SendMessage -> SendMessage
max :: SendMessage -> SendMessage -> SendMessage
$cmax :: SendMessage -> SendMessage -> SendMessage
>= :: SendMessage -> SendMessage -> Bool
$c>= :: SendMessage -> SendMessage -> Bool
> :: SendMessage -> SendMessage -> Bool
$c> :: SendMessage -> SendMessage -> Bool
<= :: SendMessage -> SendMessage -> Bool
$c<= :: SendMessage -> SendMessage -> Bool
< :: SendMessage -> SendMessage -> Bool
$c< :: SendMessage -> SendMessage -> Bool
compare :: SendMessage -> SendMessage -> Ordering
$ccompare :: SendMessage -> SendMessage -> Ordering
Ord)
data SendMessageResponse = SendMessageResponse
{ SendMessageResponse -> Text
smrMD5OfMessageBody :: !T.Text
, SendMessageResponse -> MessageId
smrMessageId :: !MessageId
, SendMessageResponse -> Maybe Text
smrMD5OfMessageAttributes :: !(Maybe T.Text)
}
deriving (Int -> SendMessageResponse -> ShowS
[SendMessageResponse] -> ShowS
SendMessageResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendMessageResponse] -> ShowS
$cshowList :: [SendMessageResponse] -> ShowS
show :: SendMessageResponse -> String
$cshow :: SendMessageResponse -> String
showsPrec :: Int -> SendMessageResponse -> ShowS
$cshowsPrec :: Int -> SendMessageResponse -> ShowS
Show, ReadPrec [SendMessageResponse]
ReadPrec SendMessageResponse
Int -> ReadS SendMessageResponse
ReadS [SendMessageResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendMessageResponse]
$creadListPrec :: ReadPrec [SendMessageResponse]
readPrec :: ReadPrec SendMessageResponse
$creadPrec :: ReadPrec SendMessageResponse
readList :: ReadS [SendMessageResponse]
$creadList :: ReadS [SendMessageResponse]
readsPrec :: Int -> ReadS SendMessageResponse
$creadsPrec :: Int -> ReadS SendMessageResponse
Read, SendMessageResponse -> SendMessageResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendMessageResponse -> SendMessageResponse -> Bool
$c/= :: SendMessageResponse -> SendMessageResponse -> Bool
== :: SendMessageResponse -> SendMessageResponse -> Bool
$c== :: SendMessageResponse -> SendMessageResponse -> Bool
Eq, Eq SendMessageResponse
SendMessageResponse -> SendMessageResponse -> Bool
SendMessageResponse -> SendMessageResponse -> Ordering
SendMessageResponse -> SendMessageResponse -> SendMessageResponse
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: SendMessageResponse -> SendMessageResponse -> SendMessageResponse
$cmin :: SendMessageResponse -> SendMessageResponse -> SendMessageResponse
max :: SendMessageResponse -> SendMessageResponse -> SendMessageResponse
$cmax :: SendMessageResponse -> SendMessageResponse -> SendMessageResponse
>= :: SendMessageResponse -> SendMessageResponse -> Bool
$c>= :: SendMessageResponse -> SendMessageResponse -> Bool
> :: SendMessageResponse -> SendMessageResponse -> Bool
$c> :: SendMessageResponse -> SendMessageResponse -> Bool
<= :: SendMessageResponse -> SendMessageResponse -> Bool
$c<= :: SendMessageResponse -> SendMessageResponse -> Bool
< :: SendMessageResponse -> SendMessageResponse -> Bool
$c< :: SendMessageResponse -> SendMessageResponse -> Bool
compare :: SendMessageResponse -> SendMessageResponse -> Ordering
$ccompare :: SendMessageResponse -> SendMessageResponse -> Ordering
Ord)
instance ResponseConsumer r SendMessageResponse where
type ResponseMetadata SendMessageResponse = SqsMetadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata SendMessageResponse)
-> HTTPResponseConsumer SendMessageResponse
responseConsumer Request
_ r
_ = forall a.
(Cursor -> Response SqsMetadata a)
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsXmlResponseConsumer forall {f :: * -> *}.
MonadThrow f =>
Cursor -> f SendMessageResponse
parse
where
parse :: Cursor -> f SendMessageResponse
parse Cursor
el = Text -> MessageId -> Maybe Text -> SendMessageResponse
SendMessageResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing MD5 Signature"
(Cursor
el forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"MD5OfMessageBody" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Text -> MessageId
MessageId forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Message Id")
(Cursor
el forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"MessageId" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (forall (f :: * -> *) a. Applicative f => a -> f a
pure forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> Maybe a
listToMaybe)
(Cursor
el forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"MD5OfMessageAttributes" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content)
instance SignQuery SendMessage where
type ServiceConfiguration SendMessage = SqsConfiguration
signQuery :: forall queryType.
SendMessage
-> ServiceConfiguration SendMessage queryType
-> SignatureData
-> SignedQuery
signQuery SendMessage{[UserMessageAttribute]
Maybe Int
Text
QueueName
smDelaySeconds :: Maybe Int
smAttributes :: [UserMessageAttribute]
smQueueName :: QueueName
smMessage :: Text
smDelaySeconds :: SendMessage -> Maybe Int
smAttributes :: SendMessage -> [UserMessageAttribute]
smQueueName :: SendMessage -> QueueName
smMessage :: SendMessage -> Text
..} = forall qt.
SqsQuery -> SqsConfiguration qt -> SignatureData -> SignedQuery
sqsSignQuery SqsQuery
{ sqsQueueName :: Maybe QueueName
sqsQueueName = forall a. a -> Maybe a
Just QueueName
smQueueName
, sqsQuery :: Query
sqsQuery =
[ (ByteString
"Action", forall a. a -> Maybe a
Just ByteString
"SendMessage")
, (ByteString
"MessageBody", forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Text -> ByteString
TE.encodeUtf8 Text
smMessage)
]
forall a. Semigroup a => a -> a -> a
<> [UserMessageAttribute] -> Query
userMessageAttributesQuery [UserMessageAttribute]
smAttributes
forall a. Semigroup a => a -> a -> a
<> forall a. Maybe a -> [a]
maybeToList ((ByteString
"DelaySeconds",) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ByteString
B.pack forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Int
smDelaySeconds)
}
instance Transaction SendMessage SendMessageResponse
instance AsMemoryResponse SendMessageResponse where
type MemoryResponse SendMessageResponse = SendMessageResponse
loadToMemory :: SendMessageResponse
-> ResourceT IO (MemoryResponse SendMessageResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return
data DeleteMessage = DeleteMessage
{ DeleteMessage -> ReceiptHandle
dmReceiptHandle :: !ReceiptHandle
, DeleteMessage -> QueueName
dmQueueName :: !QueueName
}
deriving (Int -> DeleteMessage -> ShowS
[DeleteMessage] -> ShowS
DeleteMessage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteMessage] -> ShowS
$cshowList :: [DeleteMessage] -> ShowS
show :: DeleteMessage -> String
$cshow :: DeleteMessage -> String
showsPrec :: Int -> DeleteMessage -> ShowS
$cshowsPrec :: Int -> DeleteMessage -> ShowS
Show, ReadPrec [DeleteMessage]
ReadPrec DeleteMessage
Int -> ReadS DeleteMessage
ReadS [DeleteMessage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteMessage]
$creadListPrec :: ReadPrec [DeleteMessage]
readPrec :: ReadPrec DeleteMessage
$creadPrec :: ReadPrec DeleteMessage
readList :: ReadS [DeleteMessage]
$creadList :: ReadS [DeleteMessage]
readsPrec :: Int -> ReadS DeleteMessage
$creadsPrec :: Int -> ReadS DeleteMessage
Read, DeleteMessage -> DeleteMessage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteMessage -> DeleteMessage -> Bool
$c/= :: DeleteMessage -> DeleteMessage -> Bool
== :: DeleteMessage -> DeleteMessage -> Bool
$c== :: DeleteMessage -> DeleteMessage -> Bool
Eq, Eq DeleteMessage
DeleteMessage -> DeleteMessage -> Bool
DeleteMessage -> DeleteMessage -> Ordering
DeleteMessage -> DeleteMessage -> DeleteMessage
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DeleteMessage -> DeleteMessage -> DeleteMessage
$cmin :: DeleteMessage -> DeleteMessage -> DeleteMessage
max :: DeleteMessage -> DeleteMessage -> DeleteMessage
$cmax :: DeleteMessage -> DeleteMessage -> DeleteMessage
>= :: DeleteMessage -> DeleteMessage -> Bool
$c>= :: DeleteMessage -> DeleteMessage -> Bool
> :: DeleteMessage -> DeleteMessage -> Bool
$c> :: DeleteMessage -> DeleteMessage -> Bool
<= :: DeleteMessage -> DeleteMessage -> Bool
$c<= :: DeleteMessage -> DeleteMessage -> Bool
< :: DeleteMessage -> DeleteMessage -> Bool
$c< :: DeleteMessage -> DeleteMessage -> Bool
compare :: DeleteMessage -> DeleteMessage -> Ordering
$ccompare :: DeleteMessage -> DeleteMessage -> Ordering
Ord)
data DeleteMessageResponse = DeleteMessageResponse {}
deriving (Int -> DeleteMessageResponse -> ShowS
[DeleteMessageResponse] -> ShowS
DeleteMessageResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteMessageResponse] -> ShowS
$cshowList :: [DeleteMessageResponse] -> ShowS
show :: DeleteMessageResponse -> String
$cshow :: DeleteMessageResponse -> String
showsPrec :: Int -> DeleteMessageResponse -> ShowS
$cshowsPrec :: Int -> DeleteMessageResponse -> ShowS
Show, ReadPrec [DeleteMessageResponse]
ReadPrec DeleteMessageResponse
Int -> ReadS DeleteMessageResponse
ReadS [DeleteMessageResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteMessageResponse]
$creadListPrec :: ReadPrec [DeleteMessageResponse]
readPrec :: ReadPrec DeleteMessageResponse
$creadPrec :: ReadPrec DeleteMessageResponse
readList :: ReadS [DeleteMessageResponse]
$creadList :: ReadS [DeleteMessageResponse]
readsPrec :: Int -> ReadS DeleteMessageResponse
$creadsPrec :: Int -> ReadS DeleteMessageResponse
Read, DeleteMessageResponse -> DeleteMessageResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
$c/= :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
== :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
$c== :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
Eq, Eq DeleteMessageResponse
DeleteMessageResponse -> DeleteMessageResponse -> Bool
DeleteMessageResponse -> DeleteMessageResponse -> Ordering
DeleteMessageResponse
-> DeleteMessageResponse -> DeleteMessageResponse
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: DeleteMessageResponse
-> DeleteMessageResponse -> DeleteMessageResponse
$cmin :: DeleteMessageResponse
-> DeleteMessageResponse -> DeleteMessageResponse
max :: DeleteMessageResponse
-> DeleteMessageResponse -> DeleteMessageResponse
$cmax :: DeleteMessageResponse
-> DeleteMessageResponse -> DeleteMessageResponse
>= :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
$c>= :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
> :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
$c> :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
<= :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
$c<= :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
< :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
$c< :: DeleteMessageResponse -> DeleteMessageResponse -> Bool
compare :: DeleteMessageResponse -> DeleteMessageResponse -> Ordering
$ccompare :: DeleteMessageResponse -> DeleteMessageResponse -> Ordering
Ord)
instance ResponseConsumer r DeleteMessageResponse where
type ResponseMetadata DeleteMessageResponse = SqsMetadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata DeleteMessageResponse)
-> HTTPResponseConsumer DeleteMessageResponse
responseConsumer Request
_ r
_ = forall a.
(Cursor -> Response SqsMetadata a)
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsXmlResponseConsumer forall {m :: * -> *} {p}. Monad m => p -> m DeleteMessageResponse
parse
where
parse :: p -> m DeleteMessageResponse
parse p
_ = forall (m :: * -> *) a. Monad m => a -> m a
return DeleteMessageResponse {}
instance SignQuery DeleteMessage where
type ServiceConfiguration DeleteMessage = SqsConfiguration
signQuery :: forall queryType.
DeleteMessage
-> ServiceConfiguration DeleteMessage queryType
-> SignatureData
-> SignedQuery
signQuery DeleteMessage{ReceiptHandle
QueueName
dmQueueName :: QueueName
dmReceiptHandle :: ReceiptHandle
dmQueueName :: DeleteMessage -> QueueName
dmReceiptHandle :: DeleteMessage -> ReceiptHandle
..} = forall qt.
SqsQuery -> SqsConfiguration qt -> SignatureData -> SignedQuery
sqsSignQuery SqsQuery
{ sqsQueueName :: Maybe QueueName
sqsQueueName = forall a. a -> Maybe a
Just QueueName
dmQueueName
, sqsQuery :: Query
sqsQuery =
[ (ByteString
"Action", forall a. a -> Maybe a
Just ByteString
"DeleteMessage")
, (ByteString
"ReceiptHandle", forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Text -> ByteString
TE.encodeUtf8 forall a b. (a -> b) -> a -> b
$ ReceiptHandle -> Text
printReceiptHandle ReceiptHandle
dmReceiptHandle)
]
}
instance Transaction DeleteMessage DeleteMessageResponse
instance AsMemoryResponse DeleteMessageResponse where
type MemoryResponse DeleteMessageResponse = DeleteMessageResponse
loadToMemory :: DeleteMessageResponse
-> ResourceT IO (MemoryResponse DeleteMessageResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return
data ReceiveMessage = ReceiveMessage
{ ReceiveMessage -> Maybe Int
rmVisibilityTimeout :: !(Maybe Int)
, ReceiveMessage -> [MessageAttribute]
rmAttributes :: ![MessageAttribute]
, ReceiveMessage -> Maybe Int
rmMaxNumberOfMessages :: !(Maybe Int)
, ReceiveMessage -> [Text]
rmUserMessageAttributes :: ![UserMessageAttributeName]
, ReceiveMessage -> QueueName
rmQueueName :: !QueueName
, ReceiveMessage -> Maybe Int
rmWaitTimeSeconds :: !(Maybe Int)
}
deriving (Int -> ReceiveMessage -> ShowS
[ReceiveMessage] -> ShowS
ReceiveMessage -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReceiveMessage] -> ShowS
$cshowList :: [ReceiveMessage] -> ShowS
show :: ReceiveMessage -> String
$cshow :: ReceiveMessage -> String
showsPrec :: Int -> ReceiveMessage -> ShowS
$cshowsPrec :: Int -> ReceiveMessage -> ShowS
Show, ReadPrec [ReceiveMessage]
ReadPrec ReceiveMessage
Int -> ReadS ReceiveMessage
ReadS [ReceiveMessage]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReceiveMessage]
$creadListPrec :: ReadPrec [ReceiveMessage]
readPrec :: ReadPrec ReceiveMessage
$creadPrec :: ReadPrec ReceiveMessage
readList :: ReadS [ReceiveMessage]
$creadList :: ReadS [ReceiveMessage]
readsPrec :: Int -> ReadS ReceiveMessage
$creadsPrec :: Int -> ReadS ReceiveMessage
Read, ReceiveMessage -> ReceiveMessage -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReceiveMessage -> ReceiveMessage -> Bool
$c/= :: ReceiveMessage -> ReceiveMessage -> Bool
== :: ReceiveMessage -> ReceiveMessage -> Bool
$c== :: ReceiveMessage -> ReceiveMessage -> Bool
Eq, Eq ReceiveMessage
ReceiveMessage -> ReceiveMessage -> Bool
ReceiveMessage -> ReceiveMessage -> Ordering
ReceiveMessage -> ReceiveMessage -> ReceiveMessage
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ReceiveMessage -> ReceiveMessage -> ReceiveMessage
$cmin :: ReceiveMessage -> ReceiveMessage -> ReceiveMessage
max :: ReceiveMessage -> ReceiveMessage -> ReceiveMessage
$cmax :: ReceiveMessage -> ReceiveMessage -> ReceiveMessage
>= :: ReceiveMessage -> ReceiveMessage -> Bool
$c>= :: ReceiveMessage -> ReceiveMessage -> Bool
> :: ReceiveMessage -> ReceiveMessage -> Bool
$c> :: ReceiveMessage -> ReceiveMessage -> Bool
<= :: ReceiveMessage -> ReceiveMessage -> Bool
$c<= :: ReceiveMessage -> ReceiveMessage -> Bool
< :: ReceiveMessage -> ReceiveMessage -> Bool
$c< :: ReceiveMessage -> ReceiveMessage -> Bool
compare :: ReceiveMessage -> ReceiveMessage -> Ordering
$ccompare :: ReceiveMessage -> ReceiveMessage -> Ordering
Ord)
data Message = Message
{ Message -> Text
mMessageId :: !T.Text
, Message -> ReceiptHandle
mReceiptHandle :: !ReceiptHandle
, Message -> Text
mMD5OfBody :: !T.Text
, Message -> Text
mBody :: T.Text
, Message -> [(MessageAttribute, Text)]
mAttributes :: ![(MessageAttribute,T.Text)]
, Message -> Maybe Text
mMD5OfMessageAttributes :: !(Maybe T.Text)
, Message -> [UserMessageAttribute]
mUserMessageAttributes :: ![UserMessageAttribute]
}
deriving(Int -> Message -> ShowS
[Message] -> ShowS
Message -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Message] -> ShowS
$cshowList :: [Message] -> ShowS
show :: Message -> String
$cshow :: Message -> String
showsPrec :: Int -> Message -> ShowS
$cshowsPrec :: Int -> Message -> ShowS
Show, ReadPrec [Message]
ReadPrec Message
Int -> ReadS Message
ReadS [Message]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Message]
$creadListPrec :: ReadPrec [Message]
readPrec :: ReadPrec Message
$creadPrec :: ReadPrec Message
readList :: ReadS [Message]
$creadList :: ReadS [Message]
readsPrec :: Int -> ReadS Message
$creadsPrec :: Int -> ReadS Message
Read, Message -> Message -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Message -> Message -> Bool
$c/= :: Message -> Message -> Bool
== :: Message -> Message -> Bool
$c== :: Message -> Message -> Bool
Eq, Eq Message
Message -> Message -> Bool
Message -> Message -> Ordering
Message -> Message -> Message
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Message -> Message -> Message
$cmin :: Message -> Message -> Message
max :: Message -> Message -> Message
$cmax :: Message -> Message -> Message
>= :: Message -> Message -> Bool
$c>= :: Message -> Message -> Bool
> :: Message -> Message -> Bool
$c> :: Message -> Message -> Bool
<= :: Message -> Message -> Bool
$c<= :: Message -> Message -> Bool
< :: Message -> Message -> Bool
$c< :: Message -> Message -> Bool
compare :: Message -> Message -> Ordering
$ccompare :: Message -> Message -> Ordering
Ord)
data ReceiveMessageResponse = ReceiveMessageResponse
{ ReceiveMessageResponse -> [Message]
rmrMessages :: ![Message]
}
deriving (Int -> ReceiveMessageResponse -> ShowS
[ReceiveMessageResponse] -> ShowS
ReceiveMessageResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReceiveMessageResponse] -> ShowS
$cshowList :: [ReceiveMessageResponse] -> ShowS
show :: ReceiveMessageResponse -> String
$cshow :: ReceiveMessageResponse -> String
showsPrec :: Int -> ReceiveMessageResponse -> ShowS
$cshowsPrec :: Int -> ReceiveMessageResponse -> ShowS
Show, ReadPrec [ReceiveMessageResponse]
ReadPrec ReceiveMessageResponse
Int -> ReadS ReceiveMessageResponse
ReadS [ReceiveMessageResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReceiveMessageResponse]
$creadListPrec :: ReadPrec [ReceiveMessageResponse]
readPrec :: ReadPrec ReceiveMessageResponse
$creadPrec :: ReadPrec ReceiveMessageResponse
readList :: ReadS [ReceiveMessageResponse]
$creadList :: ReadS [ReceiveMessageResponse]
readsPrec :: Int -> ReadS ReceiveMessageResponse
$creadsPrec :: Int -> ReadS ReceiveMessageResponse
Read, ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
$c/= :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
== :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
$c== :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
Eq, Eq ReceiveMessageResponse
ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
ReceiveMessageResponse -> ReceiveMessageResponse -> Ordering
ReceiveMessageResponse
-> ReceiveMessageResponse -> ReceiveMessageResponse
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ReceiveMessageResponse
-> ReceiveMessageResponse -> ReceiveMessageResponse
$cmin :: ReceiveMessageResponse
-> ReceiveMessageResponse -> ReceiveMessageResponse
max :: ReceiveMessageResponse
-> ReceiveMessageResponse -> ReceiveMessageResponse
$cmax :: ReceiveMessageResponse
-> ReceiveMessageResponse -> ReceiveMessageResponse
>= :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
$c>= :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
> :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
$c> :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
<= :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
$c<= :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
< :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
$c< :: ReceiveMessageResponse -> ReceiveMessageResponse -> Bool
compare :: ReceiveMessageResponse -> ReceiveMessageResponse -> Ordering
$ccompare :: ReceiveMessageResponse -> ReceiveMessageResponse -> Ordering
Ord)
readMessageAttribute
:: Cu.Cursor
-> Response SqsMetadata (MessageAttribute,T.Text)
readMessageAttribute :: Cursor -> Response SqsMetadata (MessageAttribute, Text)
readMessageAttribute Cursor
cursor = do
Text
name <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Name" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Text -> Axis
Cu.laxElement Text
"Name" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
Text
value <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Value" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Text -> Axis
Cu.laxElement Text
"Value" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
MessageAttribute
parsedName <- forall (m :: * -> *). MonadThrow m => Text -> m MessageAttribute
parseMessageAttribute Text
name
forall (m :: * -> *) a. Monad m => a -> m a
return (MessageAttribute
parsedName, Text
value)
readUserMessageAttribute
:: Cu.Cursor
-> Response SqsMetadata UserMessageAttribute
readUserMessageAttribute :: Cursor -> Response SqsMetadata UserMessageAttribute
readUserMessageAttribute Cursor
cursor = (,)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Name" (Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Text -> Axis
Cu.laxElement Text
"Name" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Cursor -> Response SqsMetadata UserMessageAttributeValue
readUserMessageAttributeValue Cursor
cursor
readUserMessageAttributeValue
:: Cu.Cursor
-> Response SqsMetadata UserMessageAttributeValue
readUserMessageAttributeValue :: Cursor -> Response SqsMetadata UserMessageAttributeValue
readUserMessageAttributeValue Cursor
cursor = do
Text
typStr <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing DataType"
forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"DataType" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
case Text -> (Text, Maybe Text)
parseType Text
typStr of
(Text
"String", Maybe Text
c) -> do
Text
val <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing StringValue"
forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"StringValue" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Maybe Text -> Text -> UserMessageAttributeValue
UserMessageAttributeString Maybe Text
c Text
val
(Text
"Number", Maybe Text
c) -> do
Text
valStr <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing StringValue"
forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"StringValue" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
Scientific
val <- forall {a}. Either String a -> Response SqsMetadata a
tryXml forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Read a => String -> Either String a
readEither forall a b. (a -> b) -> a -> b
$ Text -> String
T.unpack Text
valStr
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Maybe Text -> Scientific -> UserMessageAttributeValue
UserMessageAttributeNumber Maybe Text
c Scientific
val
(Text
"Binary", Maybe Text
c) -> do
Text
val64 <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing BinaryValue"
forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"BinaryValue" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
ByteString
val <- forall {a}. Either String a -> Response SqsMetadata a
tryXml forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Either String ByteString
B64.decode forall a b. (a -> b) -> a -> b
$ Text -> ByteString
TE.encodeUtf8 Text
val64
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ Maybe Text -> ByteString -> UserMessageAttributeValue
UserMessageAttributeBinary Maybe Text
c ByteString
val
(Text
x, Maybe Text
_) -> forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> XmlException
XmlException
forall a b. (a -> b) -> a -> b
$ String
"unkown data type for MessageAttributeValue: " forall a. Semigroup a => a -> a -> a
<> Text -> String
T.unpack Text
x
where
parseType :: Text -> (Text, Maybe Text)
parseType Text
s = case (Char -> Bool) -> Text -> (Text, Text)
T.break (forall a. Eq a => a -> a -> Bool
== Char
'.') Text
s of
(Text
a, Text
"") -> (Text
a, forall a. Maybe a
Nothing)
(Text
a, Text
x) -> (Text
a, forall a. a -> Maybe a
Just (Text -> Text
T.tail Text
x))
tryXml :: Either String a -> Response SqsMetadata a
tryXml = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> XmlException
XmlException) forall (m :: * -> *) a. Monad m => a -> m a
return
readMessage :: Cu.Cursor -> Response SqsMetadata Message
readMessage :: Cursor -> Response SqsMetadata Message
readMessage Cursor
cursor = do
Text
mid <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Message Id"
forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"MessageId" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
Text
rh <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Reciept Handle"
forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"ReceiptHandle" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
Text
md5 <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing MD5 Signature"
forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"MD5OfBody" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
Text
body <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Body"
forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"Body" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
[(MessageAttribute, Text)]
attributes <- forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence
forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"Attribute" forall node a b.
(Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b]
&| Cursor -> Response SqsMetadata (MessageAttribute, Text)
readMessageAttribute
[UserMessageAttribute]
userAttributes <- forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence
forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"MessageAttribute" forall node a b.
(Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b]
&| Cursor -> Response SqsMetadata UserMessageAttribute
readUserMessageAttribute
let md5OfMessageAttributes :: Maybe Text
md5OfMessageAttributes = forall a. [a] -> Maybe a
listToMaybe
forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"MD5OfMessageAttributes" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
Cu.content
forall (m :: * -> *) a. Monad m => a -> m a
return Message
{ mMessageId :: Text
mMessageId = Text
mid
, mReceiptHandle :: ReceiptHandle
mReceiptHandle = Text -> ReceiptHandle
ReceiptHandle Text
rh
, mMD5OfBody :: Text
mMD5OfBody = Text
md5
, mBody :: Text
mBody = Text
body
, mAttributes :: [(MessageAttribute, Text)]
mAttributes = [(MessageAttribute, Text)]
attributes
, mMD5OfMessageAttributes :: Maybe Text
mMD5OfMessageAttributes = Maybe Text
md5OfMessageAttributes
, mUserMessageAttributes :: [UserMessageAttribute]
mUserMessageAttributes = [UserMessageAttribute]
userAttributes
}
formatMAttributes :: [MessageAttribute] -> HTTP.Query
formatMAttributes :: [MessageAttribute] -> Query
formatMAttributes [MessageAttribute]
attrs = case [MessageAttribute]
attrs of
[MessageAttribute
attr] -> [(ByteString
"AttributeName", MessageAttribute -> Maybe ByteString
encodeAttr MessageAttribute
attr)]
[MessageAttribute]
_ -> forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall {a}. Show a => a -> MessageAttribute -> QueryItem
f [Int
1 :: Int ..] [MessageAttribute]
attrs
where
f :: a -> MessageAttribute -> QueryItem
f a
x MessageAttribute
y = (ByteString
"AttributeName." forall a. Semigroup a => a -> a -> a
<> String -> ByteString
B.pack (forall a. Show a => a -> String
show a
x), MessageAttribute -> Maybe ByteString
encodeAttr MessageAttribute
y)
encodeAttr :: MessageAttribute -> Maybe ByteString
encodeAttr = forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
TE.encodeUtf8 forall b c a. (b -> c) -> (a -> b) -> a -> c
. MessageAttribute -> Text
printMessageAttribute
formatUserMessageAttributes :: [UserMessageAttributeName] -> HTTP.Query
formatUserMessageAttributes :: [Text] -> Query
formatUserMessageAttributes [Text]
attrs = case [Text]
attrs of
[Text
attr] -> [(ByteString
"MessageAttributeName", Text -> Maybe ByteString
encodeAttr Text
attr)]
[Text]
_ -> forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith forall {a}. Show a => a -> Text -> QueryItem
f [Int
1 :: Int ..] [Text]
attrs
where
f :: a -> Text -> QueryItem
f a
x Text
y = (ByteString
"MessageAttributeName." forall a. Semigroup a => a -> a -> a
<> String -> ByteString
B.pack (forall a. Show a => a -> String
show a
x), Text -> Maybe ByteString
encodeAttr Text
y)
encodeAttr :: Text -> Maybe ByteString
encodeAttr = forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
TE.encodeUtf8
instance ResponseConsumer r ReceiveMessageResponse where
type ResponseMetadata ReceiveMessageResponse = SqsMetadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata ReceiveMessageResponse)
-> HTTPResponseConsumer ReceiveMessageResponse
responseConsumer Request
_ r
_ = forall a.
(Cursor -> Response SqsMetadata a)
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsXmlResponseConsumer Cursor -> Response SqsMetadata ReceiveMessageResponse
parse
where
parse :: Cursor -> Response SqsMetadata ReceiveMessageResponse
parse Cursor
el = do
Cursor
result <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing ReceiveMessageResult"
forall a b. (a -> b) -> a -> b
$ Cursor
el forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"ReceiveMessageResult"
[Message]
messages <- forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence
forall a b. (a -> b) -> a -> b
$ Cursor
result forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
Cu.laxElement Text
"Message" forall node a b.
(Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b]
&| Cursor -> Response SqsMetadata Message
readMessage
forall (m :: * -> *) a. Monad m => a -> m a
return ReceiveMessageResponse{ rmrMessages :: [Message]
rmrMessages = [Message]
messages }
instance SignQuery ReceiveMessage where
type ServiceConfiguration ReceiveMessage = SqsConfiguration
signQuery :: forall queryType.
ReceiveMessage
-> ServiceConfiguration ReceiveMessage queryType
-> SignatureData
-> SignedQuery
signQuery ReceiveMessage{[Text]
[MessageAttribute]
Maybe Int
QueueName
rmWaitTimeSeconds :: Maybe Int
rmQueueName :: QueueName
rmUserMessageAttributes :: [Text]
rmMaxNumberOfMessages :: Maybe Int
rmAttributes :: [MessageAttribute]
rmVisibilityTimeout :: Maybe Int
rmWaitTimeSeconds :: ReceiveMessage -> Maybe Int
rmQueueName :: ReceiveMessage -> QueueName
rmUserMessageAttributes :: ReceiveMessage -> [Text]
rmMaxNumberOfMessages :: ReceiveMessage -> Maybe Int
rmAttributes :: ReceiveMessage -> [MessageAttribute]
rmVisibilityTimeout :: ReceiveMessage -> Maybe Int
..} = forall qt.
SqsQuery -> SqsConfiguration qt -> SignatureData -> SignedQuery
sqsSignQuery SqsQuery
{ sqsQueueName :: Maybe QueueName
sqsQueueName = forall a. a -> Maybe a
Just QueueName
rmQueueName
, sqsQuery :: Query
sqsQuery = [ (ByteString
"Action", forall a. a -> Maybe a
Just ByteString
"ReceiveMessage") ]
forall a. Semigroup a => a -> a -> a
<> forall a. [Maybe a] -> [a]
catMaybes
[ (ByteString
"VisibilityTimeout",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case Maybe Int
rmVisibilityTimeout of
Just Int
x -> forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ String -> ByteString
B.pack forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show Int
x
Maybe Int
Nothing -> forall a. Maybe a
Nothing
, (ByteString
"MaxNumberOfMessages",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case Maybe Int
rmMaxNumberOfMessages of
Just Int
x -> forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ String -> ByteString
B.pack forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show Int
x
Maybe Int
Nothing -> forall a. Maybe a
Nothing
, (ByteString
"WaitTimeSeconds",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case Maybe Int
rmWaitTimeSeconds of
Just Int
x -> forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ String -> ByteString
B.pack forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show Int
x
Maybe Int
Nothing -> forall a. Maybe a
Nothing
]
forall a. Semigroup a => a -> a -> a
<> [MessageAttribute] -> Query
formatMAttributes [MessageAttribute]
rmAttributes
forall a. Semigroup a => a -> a -> a
<> [Text] -> Query
formatUserMessageAttributes [Text]
rmUserMessageAttributes
}
instance Transaction ReceiveMessage ReceiveMessageResponse
instance AsMemoryResponse ReceiveMessageResponse where
type MemoryResponse ReceiveMessageResponse = ReceiveMessageResponse
loadToMemory :: ReceiveMessageResponse
-> ResourceT IO (MemoryResponse ReceiveMessageResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return
data ChangeMessageVisibility = ChangeMessageVisibility
{ ChangeMessageVisibility -> ReceiptHandle
cmvReceiptHandle :: !ReceiptHandle
, ChangeMessageVisibility -> Int
cmvVisibilityTimeout :: !Int
, ChangeMessageVisibility -> QueueName
cmvQueueName :: !QueueName
}
deriving (Int -> ChangeMessageVisibility -> ShowS
[ChangeMessageVisibility] -> ShowS
ChangeMessageVisibility -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChangeMessageVisibility] -> ShowS
$cshowList :: [ChangeMessageVisibility] -> ShowS
show :: ChangeMessageVisibility -> String
$cshow :: ChangeMessageVisibility -> String
showsPrec :: Int -> ChangeMessageVisibility -> ShowS
$cshowsPrec :: Int -> ChangeMessageVisibility -> ShowS
Show, ReadPrec [ChangeMessageVisibility]
ReadPrec ChangeMessageVisibility
Int -> ReadS ChangeMessageVisibility
ReadS [ChangeMessageVisibility]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChangeMessageVisibility]
$creadListPrec :: ReadPrec [ChangeMessageVisibility]
readPrec :: ReadPrec ChangeMessageVisibility
$creadPrec :: ReadPrec ChangeMessageVisibility
readList :: ReadS [ChangeMessageVisibility]
$creadList :: ReadS [ChangeMessageVisibility]
readsPrec :: Int -> ReadS ChangeMessageVisibility
$creadsPrec :: Int -> ReadS ChangeMessageVisibility
Read, ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
$c/= :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
== :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
$c== :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
Eq, Eq ChangeMessageVisibility
ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
ChangeMessageVisibility -> ChangeMessageVisibility -> Ordering
ChangeMessageVisibility
-> ChangeMessageVisibility -> ChangeMessageVisibility
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ChangeMessageVisibility
-> ChangeMessageVisibility -> ChangeMessageVisibility
$cmin :: ChangeMessageVisibility
-> ChangeMessageVisibility -> ChangeMessageVisibility
max :: ChangeMessageVisibility
-> ChangeMessageVisibility -> ChangeMessageVisibility
$cmax :: ChangeMessageVisibility
-> ChangeMessageVisibility -> ChangeMessageVisibility
>= :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
$c>= :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
> :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
$c> :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
<= :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
$c<= :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
< :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
$c< :: ChangeMessageVisibility -> ChangeMessageVisibility -> Bool
compare :: ChangeMessageVisibility -> ChangeMessageVisibility -> Ordering
$ccompare :: ChangeMessageVisibility -> ChangeMessageVisibility -> Ordering
Ord)
data ChangeMessageVisibilityResponse = ChangeMessageVisibilityResponse {}
deriving (Int -> ChangeMessageVisibilityResponse -> ShowS
[ChangeMessageVisibilityResponse] -> ShowS
ChangeMessageVisibilityResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChangeMessageVisibilityResponse] -> ShowS
$cshowList :: [ChangeMessageVisibilityResponse] -> ShowS
show :: ChangeMessageVisibilityResponse -> String
$cshow :: ChangeMessageVisibilityResponse -> String
showsPrec :: Int -> ChangeMessageVisibilityResponse -> ShowS
$cshowsPrec :: Int -> ChangeMessageVisibilityResponse -> ShowS
Show, ReadPrec [ChangeMessageVisibilityResponse]
ReadPrec ChangeMessageVisibilityResponse
Int -> ReadS ChangeMessageVisibilityResponse
ReadS [ChangeMessageVisibilityResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChangeMessageVisibilityResponse]
$creadListPrec :: ReadPrec [ChangeMessageVisibilityResponse]
readPrec :: ReadPrec ChangeMessageVisibilityResponse
$creadPrec :: ReadPrec ChangeMessageVisibilityResponse
readList :: ReadS [ChangeMessageVisibilityResponse]
$creadList :: ReadS [ChangeMessageVisibilityResponse]
readsPrec :: Int -> ReadS ChangeMessageVisibilityResponse
$creadsPrec :: Int -> ReadS ChangeMessageVisibilityResponse
Read, ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
$c/= :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
== :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
$c== :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
Eq, Eq ChangeMessageVisibilityResponse
ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Ordering
ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse
$cmin :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse
max :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse
$cmax :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse
>= :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
$c>= :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
> :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
$c> :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
<= :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
$c<= :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
< :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
$c< :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Bool
compare :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Ordering
$ccompare :: ChangeMessageVisibilityResponse
-> ChangeMessageVisibilityResponse -> Ordering
Ord)
instance ResponseConsumer r ChangeMessageVisibilityResponse where
type ResponseMetadata ChangeMessageVisibilityResponse = SqsMetadata
responseConsumer :: Request
-> r
-> IORef (ResponseMetadata ChangeMessageVisibilityResponse)
-> HTTPResponseConsumer ChangeMessageVisibilityResponse
responseConsumer Request
_ r
_ = forall a.
(Cursor -> Response SqsMetadata a)
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsXmlResponseConsumer forall {m :: * -> *} {p}.
Monad m =>
p -> m ChangeMessageVisibilityResponse
parse
where
parse :: p -> m ChangeMessageVisibilityResponse
parse p
_ = forall (m :: * -> *) a. Monad m => a -> m a
return ChangeMessageVisibilityResponse {}
instance SignQuery ChangeMessageVisibility where
type ServiceConfiguration ChangeMessageVisibility = SqsConfiguration
signQuery :: forall queryType.
ChangeMessageVisibility
-> ServiceConfiguration ChangeMessageVisibility queryType
-> SignatureData
-> SignedQuery
signQuery ChangeMessageVisibility {Int
ReceiptHandle
QueueName
cmvQueueName :: QueueName
cmvVisibilityTimeout :: Int
cmvReceiptHandle :: ReceiptHandle
cmvQueueName :: ChangeMessageVisibility -> QueueName
cmvVisibilityTimeout :: ChangeMessageVisibility -> Int
cmvReceiptHandle :: ChangeMessageVisibility -> ReceiptHandle
..} = forall qt.
SqsQuery -> SqsConfiguration qt -> SignatureData -> SignedQuery
sqsSignQuery SqsQuery
{ sqsQueueName :: Maybe QueueName
sqsQueueName = forall a. a -> Maybe a
Just QueueName
cmvQueueName
, sqsQuery :: Query
sqsQuery =
[ (ByteString
"Action", forall a. a -> Maybe a
Just ByteString
"ChangeMessageVisibility")
, (ByteString
"ReceiptHandle", forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ByteString
TE.encodeUtf8 forall a b. (a -> b) -> a -> b
$ ReceiptHandle -> Text
printReceiptHandle ReceiptHandle
cmvReceiptHandle)
, (ByteString
"VisibilityTimeout", forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ByteString
B.pack forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show Int
cmvVisibilityTimeout)
]
}
instance Transaction ChangeMessageVisibility ChangeMessageVisibilityResponse
instance AsMemoryResponse ChangeMessageVisibilityResponse where
type MemoryResponse ChangeMessageVisibilityResponse = ChangeMessageVisibilityResponse
loadToMemory :: ChangeMessageVisibilityResponse
-> ResourceT IO (MemoryResponse ChangeMessageVisibilityResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return