{-# LANGUAGE CPP #-}
module Aws.Sqs.Core where

import           Aws.Core
import           Aws.S3.Core                    (LocationConstraint, locationUsClassic, locationUsWest, locationUsWest2, locationApSouthEast, locationApSouthEast2, locationApNorthEast, locationEu, locationEuWest2)
import qualified Blaze.ByteString.Builder       as Blaze
import qualified Blaze.ByteString.Builder.Char8 as Blaze8
import qualified Control.Exception              as C
import           Control.Monad
import           Control.Monad.IO.Class
import           Control.Monad.Trans.Resource   (MonadThrow, throwM)
import qualified Data.ByteString                as B
import qualified Data.ByteString.Char8          as BC
import qualified Data.Conduit
import           Data.Conduit                   ((.|))
import           Data.IORef
import           Data.List
import           Data.Maybe
import           Data.Monoid
import qualified Data.Semigroup                 as Sem
import           Data.Ord
import qualified Data.Text                      as T
import qualified Data.Text.Encoding             as T
import qualified Data.Text.Encoding             as TE
import           Data.Time
import           Data.Typeable
import           Prelude
import qualified Network.HTTP.Conduit           as HTTP
import qualified Network.HTTP.Types             as HTTP
#if !MIN_VERSION_time(1,5,0)
import           System.Locale
#endif
import qualified Text.XML                       as XML
import           Text.XML.Cursor                (($/))
import qualified Text.XML.Cursor                as Cu

type ErrorCode = T.Text

data SqsError
    = SqsError {
        SqsError -> Status
sqsStatusCode :: HTTP.Status
      , SqsError -> Text
sqsErrorCode :: ErrorCode
      , SqsError -> Text
sqsErrorType :: T.Text
      , SqsError -> Text
sqsErrorMessage :: T.Text
      , SqsError -> Maybe Text
sqsErrorDetail :: Maybe T.Text
      , SqsError -> Maybe SqsMetadata
sqsErrorMetadata :: Maybe SqsMetadata
      }
    | SqsXmlError { 
        SqsError -> Text
sqsXmlErrorMessage :: T.Text
      , SqsError -> Maybe SqsMetadata
sqsXmlErrorMetadata :: Maybe SqsMetadata
      }
    deriving (Int -> SqsError -> ShowS
[SqsError] -> ShowS
SqsError -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SqsError] -> ShowS
$cshowList :: [SqsError] -> ShowS
show :: SqsError -> String
$cshow :: SqsError -> String
showsPrec :: Int -> SqsError -> ShowS
$cshowsPrec :: Int -> SqsError -> ShowS
Show, Typeable)

instance C.Exception SqsError

data SqsMetadata
    = SqsMetadata {
        SqsMetadata -> Maybe Text
sqsMAmzId2 :: Maybe T.Text
      , SqsMetadata -> Maybe Text
sqsMRequestId :: Maybe T.Text
      }
    deriving (Int -> SqsMetadata -> ShowS
[SqsMetadata] -> ShowS
SqsMetadata -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SqsMetadata] -> ShowS
$cshowList :: [SqsMetadata] -> ShowS
show :: SqsMetadata -> String
$cshow :: SqsMetadata -> String
showsPrec :: Int -> SqsMetadata -> ShowS
$cshowsPrec :: Int -> SqsMetadata -> ShowS
Show)

instance Loggable SqsMetadata where
    toLogText :: SqsMetadata -> Text
toLogText (SqsMetadata Maybe Text
id2 Maybe Text
rid) = Text
"SQS: request ID=" forall a. Monoid a => a -> a -> a
`mappend`
                                      forall a. a -> Maybe a -> a
fromMaybe Text
"<none>" Maybe Text
rid forall a. Monoid a => a -> a -> a
`mappend`
                                      Text
", x-amz-id-2=" forall a. Monoid a => a -> a -> a
`mappend`
                                      forall a. a -> Maybe a -> a
fromMaybe Text
"<none>" Maybe Text
id2

instance Sem.Semigroup SqsMetadata where
    SqsMetadata Maybe Text
a1 Maybe Text
r1 <> :: SqsMetadata -> SqsMetadata -> SqsMetadata
<> SqsMetadata Maybe Text
a2 Maybe Text
r2 = Maybe Text -> Maybe Text -> SqsMetadata
SqsMetadata (Maybe Text
a1 forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` Maybe Text
a2) (Maybe Text
r1 forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
`mplus` Maybe Text
r2)

instance Monoid SqsMetadata where
    mempty :: SqsMetadata
mempty = Maybe Text -> Maybe Text -> SqsMetadata
SqsMetadata forall a. Maybe a
Nothing forall a. Maybe a
Nothing
    mappend :: SqsMetadata -> SqsMetadata -> SqsMetadata
mappend = forall a. Semigroup a => a -> a -> a
(Sem.<>)

data SqsAuthorization 
    = SqsAuthorizationHeader 
    | SqsAuthorizationQuery
    deriving (Int -> SqsAuthorization -> ShowS
[SqsAuthorization] -> ShowS
SqsAuthorization -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SqsAuthorization] -> ShowS
$cshowList :: [SqsAuthorization] -> ShowS
show :: SqsAuthorization -> String
$cshow :: SqsAuthorization -> String
showsPrec :: Int -> SqsAuthorization -> ShowS
$cshowsPrec :: Int -> SqsAuthorization -> ShowS
Show)

data Endpoint
    = Endpoint {
        Endpoint -> ByteString
endpointHost :: B.ByteString
      , Endpoint -> Text
endpointDefaultLocationConstraint :: LocationConstraint
      , Endpoint -> [Text]
endpointAllowedLocationConstraints :: [LocationConstraint]
      }
    deriving (Int -> Endpoint -> ShowS
[Endpoint] -> ShowS
Endpoint -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Endpoint] -> ShowS
$cshowList :: [Endpoint] -> ShowS
show :: Endpoint -> String
$cshow :: Endpoint -> String
showsPrec :: Int -> Endpoint -> ShowS
$cshowsPrec :: Int -> Endpoint -> ShowS
Show)

data SqsConfiguration qt
    = SqsConfiguration {
        forall qt. SqsConfiguration qt -> Protocol
sqsProtocol :: Protocol
      , forall qt. SqsConfiguration qt -> Endpoint
sqsEndpoint :: Endpoint
      , forall qt. SqsConfiguration qt -> Int
sqsPort :: Int
      , forall qt. SqsConfiguration qt -> Bool
sqsUseUri :: Bool
      , forall qt. SqsConfiguration qt -> NominalDiffTime
sqsDefaultExpiry :: NominalDiffTime
      }
    deriving (Int -> SqsConfiguration qt -> ShowS
forall qt. Int -> SqsConfiguration qt -> ShowS
forall qt. [SqsConfiguration qt] -> ShowS
forall qt. SqsConfiguration qt -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SqsConfiguration qt] -> ShowS
$cshowList :: forall qt. [SqsConfiguration qt] -> ShowS
show :: SqsConfiguration qt -> String
$cshow :: forall qt. SqsConfiguration qt -> String
showsPrec :: Int -> SqsConfiguration qt -> ShowS
$cshowsPrec :: forall qt. Int -> SqsConfiguration qt -> ShowS
Show)

instance DefaultServiceConfiguration (SqsConfiguration NormalQuery) where
    defServiceConfig :: SqsConfiguration NormalQuery
defServiceConfig = forall qt. Protocol -> Endpoint -> Bool -> SqsConfiguration qt
sqs Protocol
HTTPS Endpoint
sqsEndpointUsClassic Bool
False
    debugServiceConfig :: SqsConfiguration NormalQuery
debugServiceConfig = forall qt. Protocol -> Endpoint -> Bool -> SqsConfiguration qt
sqs Protocol
HTTP Endpoint
sqsEndpointUsClassic Bool
False

instance DefaultServiceConfiguration (SqsConfiguration UriOnlyQuery) where
    defServiceConfig :: SqsConfiguration UriOnlyQuery
defServiceConfig = forall qt. Protocol -> Endpoint -> Bool -> SqsConfiguration qt
sqs Protocol
HTTPS Endpoint
sqsEndpointUsClassic Bool
True
    debugServiceConfig :: SqsConfiguration UriOnlyQuery
debugServiceConfig = forall qt. Protocol -> Endpoint -> Bool -> SqsConfiguration qt
sqs Protocol
HTTP Endpoint
sqsEndpointUsClassic Bool
True
  
sqsEndpointUsClassic :: Endpoint
sqsEndpointUsClassic :: Endpoint
sqsEndpointUsClassic 
    = Endpoint { 
        endpointHost :: ByteString
endpointHost = ByteString
"queue.amazonaws.com"
      , endpointDefaultLocationConstraint :: Text
endpointDefaultLocationConstraint = Text
locationUsClassic
      , endpointAllowedLocationConstraints :: [Text]
endpointAllowedLocationConstraints = [Text
locationUsClassic
                                             , Text
locationUsWest
                                             , Text
locationEu
                                             , Text
locationApSouthEast
                                             , Text
locationApNorthEast]
      }

sqsEndpointUsWest :: Endpoint
sqsEndpointUsWest :: Endpoint
sqsEndpointUsWest
    = Endpoint {
        endpointHost :: ByteString
endpointHost = ByteString
"us-west-1.queue.amazonaws.com"
      , endpointDefaultLocationConstraint :: Text
endpointDefaultLocationConstraint = Text
locationUsWest
      , endpointAllowedLocationConstraints :: [Text]
endpointAllowedLocationConstraints = [Text
locationUsWest]
      }

sqsEndpointUsWest2 :: Endpoint
sqsEndpointUsWest2 :: Endpoint
sqsEndpointUsWest2
    = Endpoint {
        endpointHost :: ByteString
endpointHost = ByteString
"us-west-2.queue.amazonaws.com"
      , endpointDefaultLocationConstraint :: Text
endpointDefaultLocationConstraint = Text
locationUsWest2
      , endpointAllowedLocationConstraints :: [Text]
endpointAllowedLocationConstraints = [Text
locationUsWest2]
      }

sqsEndpointEu :: Endpoint
sqsEndpointEu :: Endpoint
sqsEndpointEu
    = Endpoint {
        endpointHost :: ByteString
endpointHost = ByteString
"eu-west-1.queue.amazonaws.com"
      , endpointDefaultLocationConstraint :: Text
endpointDefaultLocationConstraint = Text
locationEu
      , endpointAllowedLocationConstraints :: [Text]
endpointAllowedLocationConstraints = [Text
locationEu]
      }

sqsEndpointEuWest2 :: Endpoint
sqsEndpointEuWest2 :: Endpoint
sqsEndpointEuWest2
    = Endpoint {
        endpointHost :: ByteString
endpointHost = ByteString
"eu-west-2.queue.amazonaws.com"
      , endpointDefaultLocationConstraint :: Text
endpointDefaultLocationConstraint = Text
locationEuWest2
      , endpointAllowedLocationConstraints :: [Text]
endpointAllowedLocationConstraints = [Text
locationEuWest2]
      }

sqsEndpointApSouthEast :: Endpoint
sqsEndpointApSouthEast :: Endpoint
sqsEndpointApSouthEast
    = Endpoint {
        endpointHost :: ByteString
endpointHost = ByteString
"ap-southeast-1.queue.amazonaws.com"
      , endpointDefaultLocationConstraint :: Text
endpointDefaultLocationConstraint = Text
locationApSouthEast
      , endpointAllowedLocationConstraints :: [Text]
endpointAllowedLocationConstraints = [Text
locationApSouthEast]
      }

sqsEndpointApSouthEast2 :: Endpoint
sqsEndpointApSouthEast2 :: Endpoint
sqsEndpointApSouthEast2
    = Endpoint {
        endpointHost :: ByteString
endpointHost = ByteString
"sqs.ap-southeast-2.amazonaws.com"
      , endpointDefaultLocationConstraint :: Text
endpointDefaultLocationConstraint = Text
locationApSouthEast2
      , endpointAllowedLocationConstraints :: [Text]
endpointAllowedLocationConstraints = [Text
locationApSouthEast2]
      }

sqsEndpointApNorthEast :: Endpoint
sqsEndpointApNorthEast :: Endpoint
sqsEndpointApNorthEast
    = Endpoint {
        endpointHost :: ByteString
endpointHost = ByteString
"sqs.ap-northeast-1.amazonaws.com"
      , endpointDefaultLocationConstraint :: Text
endpointDefaultLocationConstraint = Text
locationApNorthEast
      , endpointAllowedLocationConstraints :: [Text]
endpointAllowedLocationConstraints = [Text
locationApNorthEast]
      }

sqs :: Protocol -> Endpoint -> Bool -> SqsConfiguration qt
sqs :: forall qt. Protocol -> Endpoint -> Bool -> SqsConfiguration qt
sqs Protocol
protocol Endpoint
endpoint Bool
uri 
    = SqsConfiguration { 
        sqsProtocol :: Protocol
sqsProtocol = Protocol
protocol
      , sqsEndpoint :: Endpoint
sqsEndpoint = Endpoint
endpoint
      , sqsPort :: Int
sqsPort = Protocol -> Int
defaultPort Protocol
protocol
      , sqsUseUri :: Bool
sqsUseUri = Bool
uri
      , sqsDefaultExpiry :: NominalDiffTime
sqsDefaultExpiry = NominalDiffTime
15forall a. Num a => a -> a -> a
*NominalDiffTime
60
      }

data SqsQuery = SqsQuery{
  SqsQuery -> Maybe QueueName
sqsQueueName :: Maybe QueueName,
  SqsQuery -> Query
sqsQuery :: HTTP.Query
}

sqsSignQuery :: SqsQuery -> SqsConfiguration qt -> SignatureData -> SignedQuery
sqsSignQuery :: forall qt.
SqsQuery -> SqsConfiguration qt -> SignatureData -> SignedQuery
sqsSignQuery SqsQuery{Query
Maybe QueueName
sqsQuery :: Query
sqsQueueName :: Maybe QueueName
sqsQuery :: SqsQuery -> Query
sqsQueueName :: SqsQuery -> Maybe QueueName
..} SqsConfiguration{Bool
Int
NominalDiffTime
Protocol
Endpoint
sqsDefaultExpiry :: NominalDiffTime
sqsUseUri :: Bool
sqsPort :: Int
sqsEndpoint :: Endpoint
sqsProtocol :: Protocol
sqsDefaultExpiry :: forall qt. SqsConfiguration qt -> NominalDiffTime
sqsUseUri :: forall qt. SqsConfiguration qt -> Bool
sqsPort :: forall qt. SqsConfiguration qt -> Int
sqsEndpoint :: forall qt. SqsConfiguration qt -> Endpoint
sqsProtocol :: forall qt. SqsConfiguration qt -> Protocol
..} SignatureData{UTCTime
AbsoluteTimeInfo
Credentials
signatureCredentials :: SignatureData -> Credentials
signatureTime :: SignatureData -> UTCTime
signatureTimeInfo :: SignatureData -> AbsoluteTimeInfo
signatureCredentials :: Credentials
signatureTime :: UTCTime
signatureTimeInfo :: AbsoluteTimeInfo
..}
    = SignedQuery {
        sqMethod :: Method
sqMethod = Method
method
      , sqProtocol :: Protocol
sqProtocol = Protocol
sqsProtocol
      , sqHost :: ByteString
sqHost = Endpoint -> ByteString
endpointHost Endpoint
sqsEndpoint
      , sqPort :: Int
sqPort = Int
sqsPort
      , sqPath :: ByteString
sqPath = ByteString
path
      , sqQuery :: Query
sqQuery = Query
signedQuery
      , sqDate :: Maybe UTCTime
sqDate = forall a. a -> Maybe a
Just UTCTime
signatureTime
      , sqAuthorization :: Maybe (IO ByteString)
sqAuthorization = forall a. Maybe a
Nothing 
      , sqBody :: Maybe RequestBody
sqBody = forall a. Maybe a
Nothing
      , sqStringToSign :: ByteString
sqStringToSign = ByteString
stringToSign
      , sqContentType :: Maybe ByteString
sqContentType = forall a. Maybe a
Nothing
      , sqContentMd5 :: Maybe (Digest MD5)
sqContentMd5 = forall a. Maybe a
Nothing
      , sqAmzHeaders :: RequestHeaders
sqAmzHeaders = []
      , sqOtherHeaders :: RequestHeaders
sqOtherHeaders = []
      }
    where
      method :: Method
method = Method
PostQuery
      path :: ByteString
path = case Maybe QueueName
sqsQueueName of
                Just QueueName
x -> Text -> ByteString
TE.encodeUtf8 forall a b. (a -> b) -> a -> b
$ QueueName -> Text
printQueueName QueueName
x
                Maybe QueueName
Nothing -> ByteString
"/"
      expandedQuery :: Query
expandedQuery = forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (forall a b. Ord a => (b -> a) -> b -> b -> Ordering
comparing forall a b. (a, b) -> a
fst) 
                       ( Query
sqsQuery forall a. [a] -> [a] -> [a]
++ [ (ByteString
"AWSAccessKeyId", forall a. a -> Maybe a
Just(Credentials -> ByteString
accessKeyID Credentials
signatureCredentials)), 
                       (ByteString
"Expires", forall a. a -> Maybe a
Just(String -> ByteString
BC.pack String
expiresString)), 
                       (ByteString
"SignatureMethod", forall a. a -> Maybe a
Just(ByteString
"HmacSHA256")), (ByteString
"SignatureVersion",forall a. a -> Maybe a
Just(ByteString
"2")), (ByteString
"Version",forall a. a -> Maybe a
Just(ByteString
"2012-11-05"))] forall a. [a] -> [a] -> [a]
++
                       forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ByteString
tok -> [(ByteString
"SecurityToken", forall a. a -> Maybe a
Just ByteString
tok)]) (Credentials -> Maybe ByteString
iamToken Credentials
signatureCredentials))

      expires :: AbsoluteTimeInfo
expires = UTCTime -> AbsoluteTimeInfo
AbsoluteExpires forall a b. (a -> b) -> a -> b
$ NominalDiffTime
sqsDefaultExpiry NominalDiffTime -> UTCTime -> UTCTime
`addUTCTime` UTCTime
signatureTime

      expiresString :: String
expiresString = forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale String
"%FT%TZ" (AbsoluteTimeInfo -> UTCTime
fromAbsoluteTimeInfo AbsoluteTimeInfo
expires)

      sig :: ByteString
sig = Credentials -> AuthorizationHash -> ByteString -> ByteString
signature Credentials
signatureCredentials AuthorizationHash
HmacSHA256 ByteString
stringToSign
      stringToSign :: ByteString
stringToSign = Builder -> ByteString
Blaze.toByteString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Monoid a => [a] -> a
mconcat forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> [a] -> [a]
intersperse (Char -> Builder
Blaze8.fromChar Char
'\n') forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat  forall a b. (a -> b) -> a -> b
$
                       [[ByteString -> Builder
Blaze.copyByteString forall a b. (a -> b) -> a -> b
$ Method -> ByteString
httpMethod Method
method]
                       , [ByteString -> Builder
Blaze.copyByteString forall a b. (a -> b) -> a -> b
$ Endpoint -> ByteString
endpointHost Endpoint
sqsEndpoint]
                       , [ByteString -> Builder
Blaze.copyByteString ByteString
path]
                       , [ByteString -> Builder
Blaze.copyByteString forall a b. (a -> b) -> a -> b
$ Bool -> Query -> ByteString
HTTP.renderQuery Bool
False Query
expandedQuery ]]

      signedQuery :: Query
signedQuery = Query
expandedQuery forall a. [a] -> [a] -> [a]
++ (SimpleQuery -> Query
HTTP.simpleQueryToQuery forall a b. (a -> b) -> a -> b
$ SimpleQuery
makeAuthQuery)

      makeAuthQuery :: SimpleQuery
makeAuthQuery = [(ByteString
"Signature", ByteString
sig)]

sqsResponseConsumer :: HTTPResponseConsumer a
                    -> IORef SqsMetadata
                    -> HTTPResponseConsumer a
sqsResponseConsumer :: forall a.
HTTPResponseConsumer a
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsResponseConsumer HTTPResponseConsumer a
inner IORef SqsMetadata
metadata Response (ConduitM () ByteString (ResourceT IO) ())
resp = do
      let headerString :: HeaderName -> Maybe Text
headerString = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> Text
T.decodeUtf8 forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b c. (a -> b -> c) -> b -> a -> c
flip forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup (forall body. Response body -> RequestHeaders
HTTP.responseHeaders Response (ConduitM () ByteString (ResourceT IO) ())
resp)
      let amzId2 :: Maybe Text
amzId2 = HeaderName -> Maybe Text
headerString HeaderName
"x-amz-id-2"
      let requestId :: Maybe Text
requestId = HeaderName -> Maybe Text
headerString HeaderName
"x-amz-request-id"

      let m :: SqsMetadata
m = SqsMetadata { sqsMAmzId2 :: Maybe Text
sqsMAmzId2 = Maybe Text
amzId2, sqsMRequestId :: Maybe Text
sqsMRequestId = Maybe Text
requestId }
      forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall m. Monoid m => IORef m -> m -> IO ()
tellMetadataRef IORef SqsMetadata
metadata SqsMetadata
m

      if forall body. Response body -> Status
HTTP.responseStatus Response (ConduitM () ByteString (ResourceT IO) ())
resp forall a. Ord a => a -> a -> Bool
>= Status
HTTP.status400
        then forall a. HTTPResponseConsumer a
sqsErrorResponseConsumer Response (ConduitM () ByteString (ResourceT IO) ())
resp
        else HTTPResponseConsumer a
inner Response (ConduitM () ByteString (ResourceT IO) ())
resp

sqsXmlResponseConsumer :: (Cu.Cursor -> Response SqsMetadata a)
                       -> IORef SqsMetadata
                       -> HTTPResponseConsumer a
sqsXmlResponseConsumer :: forall a.
(Cursor -> Response SqsMetadata a)
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsXmlResponseConsumer Cursor -> Response SqsMetadata a
parse IORef SqsMetadata
metadataRef = forall a.
HTTPResponseConsumer a
-> IORef SqsMetadata -> HTTPResponseConsumer a
sqsResponseConsumer (forall m a.
Monoid m =>
(Cursor -> Response m a) -> IORef m -> HTTPResponseConsumer a
xmlCursorConsumer Cursor -> Response SqsMetadata a
parse IORef SqsMetadata
metadataRef) IORef SqsMetadata
metadataRef

sqsErrorResponseConsumer :: HTTPResponseConsumer a
sqsErrorResponseConsumer :: forall a. HTTPResponseConsumer a
sqsErrorResponseConsumer Response (ConduitM () ByteString (ResourceT IO) ())
resp
    = do Document
doc <- forall (m :: * -> *) r. Monad m => ConduitT () Void m r -> m r
Data.Conduit.runConduit forall a b. (a -> b) -> a -> b
$ forall body. Response body -> body
HTTP.responseBody Response (ConduitM () ByteString (ResourceT IO) ())
resp forall (m :: * -> *) a b c r.
Monad m =>
ConduitT a b m () -> ConduitT b c m r -> ConduitT a c m r
.| forall (m :: * -> *) o.
MonadThrow m =>
ParseSettings -> ConduitT ByteString o m Document
XML.sinkDoc forall a. Default a => a
XML.def
         let cursor :: Cursor
cursor = Document -> Cursor
Cu.fromDocument Document
doc
         forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ case Cursor -> Either SomeException SqsError
parseError Cursor
cursor of
           Right SqsError
err     -> forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SqsError
err
           Left SomeException
otherErr -> forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM SomeException
otherErr
    where
      parseError :: Cu.Cursor -> Either C.SomeException SqsError
      parseError :: Cursor -> Either SomeException SqsError
parseError Cursor
root = do Cursor
cursor <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Error" forall a b. (a -> b) -> a -> b
$ Cursor
root forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Text -> Axis
Cu.laxElement Text
"Error"
                           Text
code <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing error Code" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Text -> Cursor -> [Text]
elContent Text
"Code"
                           Text
message <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing error Message" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Text -> Cursor -> [Text]
elContent Text
"Message"
                           Text
errorType <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing error Type" forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Text -> Cursor -> [Text]
elContent Text
"Type"
                           let detail :: Maybe Text
detail = 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 -> Cursor -> [Text]
elContent Text
"Detail"

                           forall (m :: * -> *) a. Monad m => a -> m a
return SqsError {
                                        sqsStatusCode :: Status
sqsStatusCode = forall body. Response body -> Status
HTTP.responseStatus Response (ConduitM () ByteString (ResourceT IO) ())
resp
                                      , sqsErrorCode :: Text
sqsErrorCode = Text
code
                                      , sqsErrorMessage :: Text
sqsErrorMessage = Text
message
                                      , sqsErrorType :: Text
sqsErrorType = Text
errorType
                                      , sqsErrorDetail :: Maybe Text
sqsErrorDetail = Maybe Text
detail
                                      , sqsErrorMetadata :: Maybe SqsMetadata
sqsErrorMetadata = forall a. Maybe a
Nothing
                                      }

data QueueName = QueueName{
  QueueName -> Text
qName :: T.Text,
  QueueName -> Text
qAccountNumber :: T.Text
} deriving(Int -> QueueName -> ShowS
[QueueName] -> ShowS
QueueName -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueueName] -> ShowS
$cshowList :: [QueueName] -> ShowS
show :: QueueName -> String
$cshow :: QueueName -> String
showsPrec :: Int -> QueueName -> ShowS
$cshowsPrec :: Int -> QueueName -> ShowS
Show, ReadPrec [QueueName]
ReadPrec QueueName
Int -> ReadS QueueName
ReadS [QueueName]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QueueName]
$creadListPrec :: ReadPrec [QueueName]
readPrec :: ReadPrec QueueName
$creadPrec :: ReadPrec QueueName
readList :: ReadS [QueueName]
$creadList :: ReadS [QueueName]
readsPrec :: Int -> ReadS QueueName
$creadsPrec :: Int -> ReadS QueueName
Read, QueueName -> QueueName -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueueName -> QueueName -> Bool
$c/= :: QueueName -> QueueName -> Bool
== :: QueueName -> QueueName -> Bool
$c== :: QueueName -> QueueName -> Bool
Eq, Eq QueueName
QueueName -> QueueName -> Bool
QueueName -> QueueName -> Ordering
QueueName -> QueueName -> QueueName
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 :: QueueName -> QueueName -> QueueName
$cmin :: QueueName -> QueueName -> QueueName
max :: QueueName -> QueueName -> QueueName
$cmax :: QueueName -> QueueName -> QueueName
>= :: QueueName -> QueueName -> Bool
$c>= :: QueueName -> QueueName -> Bool
> :: QueueName -> QueueName -> Bool
$c> :: QueueName -> QueueName -> Bool
<= :: QueueName -> QueueName -> Bool
$c<= :: QueueName -> QueueName -> Bool
< :: QueueName -> QueueName -> Bool
$c< :: QueueName -> QueueName -> Bool
compare :: QueueName -> QueueName -> Ordering
$ccompare :: QueueName -> QueueName -> Ordering
Ord)

printQueueName :: QueueName -> T.Text
printQueueName :: QueueName -> Text
printQueueName QueueName
queue = [Text] -> Text
T.concat [Text
"/", (QueueName -> Text
qAccountNumber QueueName
queue), Text
"/", (QueueName -> Text
qName QueueName
queue), Text
"/"]

data QueueAttribute
    = QueueAll
    | ApproximateNumberOfMessages
    | ApproximateNumberOfMessagesNotVisible
    | VisibilityTimeout
    | CreatedTimestamp
    | LastModifiedTimestamp
    | Policy
    | MaximumMessageSize
    | MessageRetentionPeriod
    | QueueArn
    deriving(Int -> QueueAttribute -> ShowS
[QueueAttribute] -> ShowS
QueueAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QueueAttribute] -> ShowS
$cshowList :: [QueueAttribute] -> ShowS
show :: QueueAttribute -> String
$cshow :: QueueAttribute -> String
showsPrec :: Int -> QueueAttribute -> ShowS
$cshowsPrec :: Int -> QueueAttribute -> ShowS
Show, Int -> QueueAttribute
QueueAttribute -> Int
QueueAttribute -> [QueueAttribute]
QueueAttribute -> QueueAttribute
QueueAttribute -> QueueAttribute -> [QueueAttribute]
QueueAttribute
-> QueueAttribute -> QueueAttribute -> [QueueAttribute]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: QueueAttribute
-> QueueAttribute -> QueueAttribute -> [QueueAttribute]
$cenumFromThenTo :: QueueAttribute
-> QueueAttribute -> QueueAttribute -> [QueueAttribute]
enumFromTo :: QueueAttribute -> QueueAttribute -> [QueueAttribute]
$cenumFromTo :: QueueAttribute -> QueueAttribute -> [QueueAttribute]
enumFromThen :: QueueAttribute -> QueueAttribute -> [QueueAttribute]
$cenumFromThen :: QueueAttribute -> QueueAttribute -> [QueueAttribute]
enumFrom :: QueueAttribute -> [QueueAttribute]
$cenumFrom :: QueueAttribute -> [QueueAttribute]
fromEnum :: QueueAttribute -> Int
$cfromEnum :: QueueAttribute -> Int
toEnum :: Int -> QueueAttribute
$ctoEnum :: Int -> QueueAttribute
pred :: QueueAttribute -> QueueAttribute
$cpred :: QueueAttribute -> QueueAttribute
succ :: QueueAttribute -> QueueAttribute
$csucc :: QueueAttribute -> QueueAttribute
Enum, QueueAttribute -> QueueAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QueueAttribute -> QueueAttribute -> Bool
$c/= :: QueueAttribute -> QueueAttribute -> Bool
== :: QueueAttribute -> QueueAttribute -> Bool
$c== :: QueueAttribute -> QueueAttribute -> Bool
Eq)

data MessageAttribute
    = MessageAll
    -- ^ all values
    | SenderId
    -- ^ the AWS account number (or the IP address, if anonymous access is
    -- allowed) of the sender
    | SentTimestamp
    -- ^ the time when the message was sent (epoch time in milliseconds)
    | ApproximateReceiveCount
    -- ^ the number of times a message has been received but not deleted
    | ApproximateFirstReceiveTimestamp
    -- ^ the time when the message was first received (epoch time in
    -- milliseconds)
    deriving(Int -> MessageAttribute -> ShowS
[MessageAttribute] -> ShowS
MessageAttribute -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MessageAttribute] -> ShowS
$cshowList :: [MessageAttribute] -> ShowS
show :: MessageAttribute -> String
$cshow :: MessageAttribute -> String
showsPrec :: Int -> MessageAttribute -> ShowS
$cshowsPrec :: Int -> MessageAttribute -> ShowS
Show,ReadPrec [MessageAttribute]
ReadPrec MessageAttribute
Int -> ReadS MessageAttribute
ReadS [MessageAttribute]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MessageAttribute]
$creadListPrec :: ReadPrec [MessageAttribute]
readPrec :: ReadPrec MessageAttribute
$creadPrec :: ReadPrec MessageAttribute
readList :: ReadS [MessageAttribute]
$creadList :: ReadS [MessageAttribute]
readsPrec :: Int -> ReadS MessageAttribute
$creadsPrec :: Int -> ReadS MessageAttribute
Read,MessageAttribute -> MessageAttribute -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MessageAttribute -> MessageAttribute -> Bool
$c/= :: MessageAttribute -> MessageAttribute -> Bool
== :: MessageAttribute -> MessageAttribute -> Bool
$c== :: MessageAttribute -> MessageAttribute -> Bool
Eq,Eq MessageAttribute
MessageAttribute -> MessageAttribute -> Bool
MessageAttribute -> MessageAttribute -> Ordering
MessageAttribute -> MessageAttribute -> MessageAttribute
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 :: MessageAttribute -> MessageAttribute -> MessageAttribute
$cmin :: MessageAttribute -> MessageAttribute -> MessageAttribute
max :: MessageAttribute -> MessageAttribute -> MessageAttribute
$cmax :: MessageAttribute -> MessageAttribute -> MessageAttribute
>= :: MessageAttribute -> MessageAttribute -> Bool
$c>= :: MessageAttribute -> MessageAttribute -> Bool
> :: MessageAttribute -> MessageAttribute -> Bool
$c> :: MessageAttribute -> MessageAttribute -> Bool
<= :: MessageAttribute -> MessageAttribute -> Bool
$c<= :: MessageAttribute -> MessageAttribute -> Bool
< :: MessageAttribute -> MessageAttribute -> Bool
$c< :: MessageAttribute -> MessageAttribute -> Bool
compare :: MessageAttribute -> MessageAttribute -> Ordering
$ccompare :: MessageAttribute -> MessageAttribute -> Ordering
Ord,Int -> MessageAttribute
MessageAttribute -> Int
MessageAttribute -> [MessageAttribute]
MessageAttribute -> MessageAttribute
MessageAttribute -> MessageAttribute -> [MessageAttribute]
MessageAttribute
-> MessageAttribute -> MessageAttribute -> [MessageAttribute]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: MessageAttribute
-> MessageAttribute -> MessageAttribute -> [MessageAttribute]
$cenumFromThenTo :: MessageAttribute
-> MessageAttribute -> MessageAttribute -> [MessageAttribute]
enumFromTo :: MessageAttribute -> MessageAttribute -> [MessageAttribute]
$cenumFromTo :: MessageAttribute -> MessageAttribute -> [MessageAttribute]
enumFromThen :: MessageAttribute -> MessageAttribute -> [MessageAttribute]
$cenumFromThen :: MessageAttribute -> MessageAttribute -> [MessageAttribute]
enumFrom :: MessageAttribute -> [MessageAttribute]
$cenumFrom :: MessageAttribute -> [MessageAttribute]
fromEnum :: MessageAttribute -> Int
$cfromEnum :: MessageAttribute -> Int
toEnum :: Int -> MessageAttribute
$ctoEnum :: Int -> MessageAttribute
pred :: MessageAttribute -> MessageAttribute
$cpred :: MessageAttribute -> MessageAttribute
succ :: MessageAttribute -> MessageAttribute
$csucc :: MessageAttribute -> MessageAttribute
Enum,MessageAttribute
forall a. a -> a -> Bounded a
maxBound :: MessageAttribute
$cmaxBound :: MessageAttribute
minBound :: MessageAttribute
$cminBound :: MessageAttribute
Bounded)

data SqsPermission
    = PermissionAll
    | PermissionSendMessage
    | PermissionReceiveMessage
    | PermissionDeleteMessage
    | PermissionChangeMessageVisibility
    | PermissionGetQueueAttributes
    deriving (Int -> SqsPermission -> ShowS
[SqsPermission] -> ShowS
SqsPermission -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SqsPermission] -> ShowS
$cshowList :: [SqsPermission] -> ShowS
show :: SqsPermission -> String
$cshow :: SqsPermission -> String
showsPrec :: Int -> SqsPermission -> ShowS
$cshowsPrec :: Int -> SqsPermission -> ShowS
Show, Int -> SqsPermission
SqsPermission -> Int
SqsPermission -> [SqsPermission]
SqsPermission -> SqsPermission
SqsPermission -> SqsPermission -> [SqsPermission]
SqsPermission -> SqsPermission -> SqsPermission -> [SqsPermission]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: SqsPermission -> SqsPermission -> SqsPermission -> [SqsPermission]
$cenumFromThenTo :: SqsPermission -> SqsPermission -> SqsPermission -> [SqsPermission]
enumFromTo :: SqsPermission -> SqsPermission -> [SqsPermission]
$cenumFromTo :: SqsPermission -> SqsPermission -> [SqsPermission]
enumFromThen :: SqsPermission -> SqsPermission -> [SqsPermission]
$cenumFromThen :: SqsPermission -> SqsPermission -> [SqsPermission]
enumFrom :: SqsPermission -> [SqsPermission]
$cenumFrom :: SqsPermission -> [SqsPermission]
fromEnum :: SqsPermission -> Int
$cfromEnum :: SqsPermission -> Int
toEnum :: Int -> SqsPermission
$ctoEnum :: Int -> SqsPermission
pred :: SqsPermission -> SqsPermission
$cpred :: SqsPermission -> SqsPermission
succ :: SqsPermission -> SqsPermission
$csucc :: SqsPermission -> SqsPermission
Enum, SqsPermission -> SqsPermission -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SqsPermission -> SqsPermission -> Bool
$c/= :: SqsPermission -> SqsPermission -> Bool
== :: SqsPermission -> SqsPermission -> Bool
$c== :: SqsPermission -> SqsPermission -> Bool
Eq)

parseQueueAttribute :: MonadThrow m  => T.Text -> m QueueAttribute
parseQueueAttribute :: forall (m :: * -> *). MonadThrow m => Text -> m QueueAttribute
parseQueueAttribute Text
"ApproximateNumberOfMessages" = forall (m :: * -> *) a. Monad m => a -> m a
return QueueAttribute
ApproximateNumberOfMessages 
parseQueueAttribute Text
"ApproximateNumberOfMessagesNotVisible" = forall (m :: * -> *) a. Monad m => a -> m a
return QueueAttribute
ApproximateNumberOfMessagesNotVisible
parseQueueAttribute Text
"VisibilityTimeout" = forall (m :: * -> *) a. Monad m => a -> m a
return QueueAttribute
VisibilityTimeout
parseQueueAttribute Text
"CreatedTimestamp" = forall (m :: * -> *) a. Monad m => a -> m a
return QueueAttribute
CreatedTimestamp
parseQueueAttribute Text
"LastModifiedTimestamp" = forall (m :: * -> *) a. Monad m => a -> m a
return QueueAttribute
LastModifiedTimestamp
parseQueueAttribute Text
"Policy" = forall (m :: * -> *) a. Monad m => a -> m a
return QueueAttribute
Policy
parseQueueAttribute Text
"MaximumMessageSize" = forall (m :: * -> *) a. Monad m => a -> m a
return QueueAttribute
MaximumMessageSize
parseQueueAttribute Text
"MessageRetentionPeriod" = forall (m :: * -> *) a. Monad m => a -> m a
return QueueAttribute
MessageRetentionPeriod
parseQueueAttribute Text
"QueueArn" = forall (m :: * -> *) a. Monad m => a -> m a
return QueueAttribute
QueueArn
parseQueueAttribute Text
x = forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> XmlException
XmlException ( String
"Invalid Attribute Name. " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Text
x)

printQueueAttribute :: QueueAttribute -> T.Text
printQueueAttribute :: QueueAttribute -> Text
printQueueAttribute QueueAttribute
QueueAll = Text
"All"
printQueueAttribute QueueAttribute
ApproximateNumberOfMessages = Text
"ApproximateNumberOfMessages"
printQueueAttribute QueueAttribute
ApproximateNumberOfMessagesNotVisible = Text
"ApproximateNumberOfMessagesNotVisible"
printQueueAttribute QueueAttribute
VisibilityTimeout = Text
"VisibilityTimeout"
printQueueAttribute QueueAttribute
CreatedTimestamp = Text
"CreatedTimestamp"
printQueueAttribute QueueAttribute
LastModifiedTimestamp = Text
"LastModifiedTimestamp"
printQueueAttribute QueueAttribute
Policy = Text
"Policy"
printQueueAttribute QueueAttribute
MaximumMessageSize = Text
"MaximumMessageSize"
printQueueAttribute QueueAttribute
MessageRetentionPeriod = Text
"MessageRetentionPeriod"
printQueueAttribute QueueAttribute
QueueArn = Text
"QueueArn"

parseMessageAttribute :: MonadThrow m  =>  T.Text -> m MessageAttribute
parseMessageAttribute :: forall (m :: * -> *). MonadThrow m => Text -> m MessageAttribute
parseMessageAttribute Text
"SenderId" = forall (m :: * -> *) a. Monad m => a -> m a
return MessageAttribute
SenderId
parseMessageAttribute Text
"SentTimestamp" = forall (m :: * -> *) a. Monad m => a -> m a
return MessageAttribute
SentTimestamp
parseMessageAttribute Text
"ApproximateReceiveCount" = forall (m :: * -> *) a. Monad m => a -> m a
return MessageAttribute
ApproximateReceiveCount
parseMessageAttribute Text
"ApproximateFirstReceiveTimestamp" = forall (m :: * -> *) a. Monad m => a -> m a
return MessageAttribute
ApproximateFirstReceiveTimestamp
parseMessageAttribute Text
x = forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM forall a b. (a -> b) -> a -> b
$ String -> XmlException
XmlException ( String
"Invalid Attribute Name. " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show Text
x)

printMessageAttribute :: MessageAttribute -> T.Text
printMessageAttribute :: MessageAttribute -> Text
printMessageAttribute MessageAttribute
MessageAll = Text
"All"
printMessageAttribute MessageAttribute
SenderId = Text
"SenderId"
printMessageAttribute MessageAttribute
SentTimestamp = Text
"SentTimestamp"
printMessageAttribute MessageAttribute
ApproximateReceiveCount = Text
"ApproximateReceiveCount"
printMessageAttribute MessageAttribute
ApproximateFirstReceiveTimestamp = Text
"ApproximateFirstReceiveTimestamp"

printPermission :: SqsPermission -> T.Text
printPermission :: SqsPermission -> Text
printPermission SqsPermission
PermissionAll = Text
"*"
printPermission SqsPermission
PermissionSendMessage = Text
"SendMessage"
printPermission SqsPermission
PermissionReceiveMessage = Text
"ReceiveMessage"
printPermission SqsPermission
PermissionDeleteMessage = Text
"DeleteMessage"
printPermission SqsPermission
PermissionChangeMessageVisibility = Text
"ChangeMessageVisibility"
printPermission SqsPermission
PermissionGetQueueAttributes = Text
"GetQueueAttributes"

newtype ReceiptHandle = ReceiptHandle T.Text deriving(Int -> ReceiptHandle -> ShowS
[ReceiptHandle] -> ShowS
ReceiptHandle -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReceiptHandle] -> ShowS
$cshowList :: [ReceiptHandle] -> ShowS
show :: ReceiptHandle -> String
$cshow :: ReceiptHandle -> String
showsPrec :: Int -> ReceiptHandle -> ShowS
$cshowsPrec :: Int -> ReceiptHandle -> ShowS
Show, ReadPrec [ReceiptHandle]
ReadPrec ReceiptHandle
Int -> ReadS ReceiptHandle
ReadS [ReceiptHandle]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReceiptHandle]
$creadListPrec :: ReadPrec [ReceiptHandle]
readPrec :: ReadPrec ReceiptHandle
$creadPrec :: ReadPrec ReceiptHandle
readList :: ReadS [ReceiptHandle]
$creadList :: ReadS [ReceiptHandle]
readsPrec :: Int -> ReadS ReceiptHandle
$creadsPrec :: Int -> ReadS ReceiptHandle
Read, ReceiptHandle -> ReceiptHandle -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReceiptHandle -> ReceiptHandle -> Bool
$c/= :: ReceiptHandle -> ReceiptHandle -> Bool
== :: ReceiptHandle -> ReceiptHandle -> Bool
$c== :: ReceiptHandle -> ReceiptHandle -> Bool
Eq, Eq ReceiptHandle
ReceiptHandle -> ReceiptHandle -> Bool
ReceiptHandle -> ReceiptHandle -> Ordering
ReceiptHandle -> ReceiptHandle -> ReceiptHandle
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 :: ReceiptHandle -> ReceiptHandle -> ReceiptHandle
$cmin :: ReceiptHandle -> ReceiptHandle -> ReceiptHandle
max :: ReceiptHandle -> ReceiptHandle -> ReceiptHandle
$cmax :: ReceiptHandle -> ReceiptHandle -> ReceiptHandle
>= :: ReceiptHandle -> ReceiptHandle -> Bool
$c>= :: ReceiptHandle -> ReceiptHandle -> Bool
> :: ReceiptHandle -> ReceiptHandle -> Bool
$c> :: ReceiptHandle -> ReceiptHandle -> Bool
<= :: ReceiptHandle -> ReceiptHandle -> Bool
$c<= :: ReceiptHandle -> ReceiptHandle -> Bool
< :: ReceiptHandle -> ReceiptHandle -> Bool
$c< :: ReceiptHandle -> ReceiptHandle -> Bool
compare :: ReceiptHandle -> ReceiptHandle -> Ordering
$ccompare :: ReceiptHandle -> ReceiptHandle -> Ordering
Ord)
newtype MessageId = MessageId T.Text deriving(Int -> MessageId -> ShowS
[MessageId] -> ShowS
MessageId -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MessageId] -> ShowS
$cshowList :: [MessageId] -> ShowS
show :: MessageId -> String
$cshow :: MessageId -> String
showsPrec :: Int -> MessageId -> ShowS
$cshowsPrec :: Int -> MessageId -> ShowS
Show, ReadPrec [MessageId]
ReadPrec MessageId
Int -> ReadS MessageId
ReadS [MessageId]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MessageId]
$creadListPrec :: ReadPrec [MessageId]
readPrec :: ReadPrec MessageId
$creadPrec :: ReadPrec MessageId
readList :: ReadS [MessageId]
$creadList :: ReadS [MessageId]
readsPrec :: Int -> ReadS MessageId
$creadsPrec :: Int -> ReadS MessageId
Read, MessageId -> MessageId -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MessageId -> MessageId -> Bool
$c/= :: MessageId -> MessageId -> Bool
== :: MessageId -> MessageId -> Bool
$c== :: MessageId -> MessageId -> Bool
Eq, Eq MessageId
MessageId -> MessageId -> Bool
MessageId -> MessageId -> Ordering
MessageId -> MessageId -> MessageId
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 :: MessageId -> MessageId -> MessageId
$cmin :: MessageId -> MessageId -> MessageId
max :: MessageId -> MessageId -> MessageId
$cmax :: MessageId -> MessageId -> MessageId
>= :: MessageId -> MessageId -> Bool
$c>= :: MessageId -> MessageId -> Bool
> :: MessageId -> MessageId -> Bool
$c> :: MessageId -> MessageId -> Bool
<= :: MessageId -> MessageId -> Bool
$c<= :: MessageId -> MessageId -> Bool
< :: MessageId -> MessageId -> Bool
$c< :: MessageId -> MessageId -> Bool
compare :: MessageId -> MessageId -> Ordering
$ccompare :: MessageId -> MessageId -> Ordering
Ord)

printReceiptHandle :: ReceiptHandle -> T.Text
printReceiptHandle :: ReceiptHandle -> Text
printReceiptHandle (ReceiptHandle Text
handle) = Text
handle