packages feed

antiope-sns (empty) → 1.0.0

raw patch · 7 files changed

+137/−0 lines, 7 filesdep +aesondep +amazonkadep +amazonka-coresetup-changed

Dependencies added: aeson, amazonka, amazonka-core, amazonka-sns, antiope-sns, base, generic-lens, lens, text

Files

+ ChangeLog.md view
@@ -0,0 +1,3 @@+# Changelog for antiope-sns++## 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-sns
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ antiope-sns.cabal view
@@ -0,0 +1,68 @@+-- This file has been generated from package.yaml by hpack version 0.20.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 2bc4d9dfd35dab184e47ae0e005d66572c189b238be10abc23fa08483e32c0fd++name:           antiope-sns+version:        1.0.0+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:         Tyler Durden+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+  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-sns+    , base >=4.7 && <5+    , generic-lens+    , lens+    , text+  exposed-modules:+      Antiope.SNS+  other-modules:+      Paths_antiope_sns+  default-language: Haskell2010++test-suite antiope-sns-test+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  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-sns+    , antiope-sns+    , base >=4.7 && <5+    , generic-lens+    , lens+    , text+  other-modules:+      Paths_antiope_sns+  default-language: Haskell2010
+ src/Antiope/SNS.hs view
@@ -0,0 +1,31 @@+module Antiope.SNS+( MonadAWS+, MessageId (..)+, Protocol (..)+, SubscriptionArn (..)+, publishMessage+, subscribeTopic+, module Network.AWS.SNS+) where++import Control.Lens+import Data.Text             (Text)+import Network.AWS           (MonadAWS, send)+import Network.AWS.Data.Text (FromText (..), ToText (..))+import Network.AWS.SNS++newtype MessageId = MessageId Text deriving (Show, Eq, Ord, ToText, FromText)+newtype Protocol = Protocol Text deriving (Show, Eq, Ord, ToText, FromText)+newtype SubscriptionArn = SubscriptionArn Text deriving (Show, Eq, Ord, ToText, FromText)++publishMessage :: MonadAWS m => Topic -> Text -> m (Maybe MessageId)+publishMessage topicArn message = do+  resp <- send $ publish message & pTopicARN <>~ (topicArn ^. tTopicARN)+  return $ MessageId <$> resp ^. prsMessageId++subscribeTopic :: MonadAWS m => Topic -> Protocol -> Endpoint -> m (Maybe SubscriptionArn)+subscribeTopic topicArn (Protocol p) ep = case topicArn ^. tTopicARN of+  Just t -> do+    resp <- send $ subscribe t p & subEndpoint <>~ (ep ^. eEndpointARN)+    return $ SubscriptionArn <$> resp ^. srsSubscriptionARN+  Nothing -> return Nothing
+ test/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"