packages feed

antiope-messages (empty) → 5.0.1

raw patch · 8 files changed

+170/−0 lines, 8 filesdep +aesondep +amazonkadep +amazonka-coresetup-changed

Dependencies added: aeson, amazonka, amazonka-core, amazonka-s3, amazonka-sqs, antiope-messages, antiope-s3, base, generic-lens, lens, lens-aeson, monad-loops, network-uri, text, unliftio-core

Files

+ ChangeLog.md view
@@ -0,0 +1,3 @@+# Changelog for antiope-sqs++## Unreleased changes
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Arbor Networks (c) 2018++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Alexey Raga nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,1 @@+# antiope-messages
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ antiope-messages.cabal view
@@ -0,0 +1,80 @@+-- This file has been generated from package.yaml by hpack version 0.28.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: 837b7af7618d46faf587f33d9317f1cfdbe836098e2acbb97fb5b1ca9747979e++name:           antiope-messages+version:        5.0.1+description:    Please see the README on Github at <https://github.com/arbor/antiope#readme>+category:       Services+homepage:       https://github.com/arbor/antiope#readme+bug-reports:    https://github.com/arbor/antiope/issues+author:         Arbor Networks+maintainer:     mayhem@arbor.net+copyright:      Arbor Networks+license:        MIT+license-file:   LICENSE+build-type:     Simple+cabal-version:  >= 1.10+extra-source-files:+    ChangeLog.md+    README.md++source-repository head+  type: git+  location: https://github.com/arbor/antiope++library+  exposed-modules:+      Antiope.Messages+      Antiope.Messages.Types+  other-modules:+      Paths_antiope_messages+  hs-source-dirs:+      src+  default-extensions: BangPatterns GeneralizedNewtypeDeriving OverloadedStrings TupleSections+  ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -O2 -msse4.2+  build-depends:+      aeson+    , amazonka+    , amazonka-core+    , amazonka-s3+    , amazonka-sqs+    , antiope-s3+    , base >=4.7 && <5+    , generic-lens+    , lens+    , lens-aeson+    , monad-loops+    , network-uri+    , text+    , unliftio-core+  default-language: Haskell2010++test-suite antiope-messages-test+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  other-modules:+      Paths_antiope_messages+  hs-source-dirs:+      test+  default-extensions: BangPatterns GeneralizedNewtypeDeriving OverloadedStrings TupleSections+  ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -O2 -msse4.2 -threaded -rtsopts -with-rtsopts=-N+  build-depends:+      aeson+    , amazonka+    , amazonka-core+    , amazonka-s3+    , amazonka-sqs+    , antiope-messages+    , antiope-s3+    , base >=4.7 && <5+    , generic-lens+    , lens+    , lens-aeson+    , monad-loops+    , network-uri+    , text+    , unliftio-core+  default-language: Haskell2010
+ src/Antiope/Messages.hs view
@@ -0,0 +1,35 @@+module Antiope.Messages+  ( QueueUrl(..)+  , SQSError(..)+  , messageInBody+  , messageToS3Uri+  , messageToS3Uri'+  ) where++import Antiope.Messages.Types (QueueUrl (QueueUrl), SQSError (DeleteMessageBatchError))+import Antiope.S3             (S3Uri (..))+import Control.Lens+import Control.Monad          (join)+import Data.Aeson.Lens+import Data.Text              (Text, pack, unpack)+import Network.AWS.S3         (BucketName (BucketName), ObjectKey (ObjectKey))+import Network.AWS.SQS++import qualified Network.URI as URI++-- Extract the "Message" content in the body if have+messageInBody :: Text -> Maybe Text+messageInBody body = body ^? key "Message" . _String++messageToS3Uri :: Message -> Maybe S3Uri+messageToS3Uri msg = join $ messageToS3Uri' <$> msg ^. mBody++messageToS3Uri' :: Text -> Maybe S3Uri+messageToS3Uri' msg = do+  s3m <- messageInBody msg ^? _Just . key "Records" . nth 0 . key "s3"+  b   <- s3m ^? key "bucket" . key "name" . _String+  k   <- s3m ^? key "object" . key "key" . _String+  pure $ S3Uri (BucketName b) (ObjectKey $ uriDecode k)++uriDecode :: Text -> Text+uriDecode = pack . URI.unEscapeString . unpack
+ src/Antiope/Messages/Types.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE DeriveGeneric #-}++module Antiope.Messages.Types+  ( QueueUrl(..)+  , SQSError(..)+  ) where++import Data.String           (IsString)+import Data.Text             (Text)+import GHC.Generics+import Network.AWS.Data.Text (FromText (..), ToText (..))++data SQSError = DeleteMessageBatchError+  deriving (Eq, Show, Generic)++newtype QueueUrl = QueueUrl Text+  deriving (Show, Eq, IsString, FromText, ToText, Generic)
+ test/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"