Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE OverloadedStrings #-}
- import Data.HashMap.Strict (toList)
- import Control.Monad.Trans.Resource (runResourceT)
- import Control.Monad.IO.Class (MonadIO, liftIO)
- import Control.Lens ((&),(.~),(^.),(?~))
- import Data.ByteString (pack)
- import Network.AWS (runAWS, send, LogLevel (Debug), Logger, Region (Oregon), newLogger)
- import Network.AWS.SQS
- import Network.AWS.Auth
- import Network.AWS.Env
- import System.IO (stdout)
- import qualified Data.Map as M
- ---- libraries used ----
- -- amazonka
- -- amazonka-sqs
- -- lens
- -- containers
- -- unordered-containers
- -- resourcet
- -- transformers
- -- bytestring
- run :: IO ()
- run = do
- let queueUrl = "TODO"
- env <- buildAwsEnv
- r <- liftIO $ runResourceT $ runAWS env $ send $
- getQueueAttributes queueUrl & gqaAttributeNames .~ attributes
- print $ M.fromList $ toList $ r ^. gqarsAttributes
- attributes :: [QueueAttributeName]
- attributes =
- [ ApproximateNumberOfMessages
- , ApproximateNumberOfMessagesDelayed
- , ApproximateNumberOfMessagesNotVisible
- , CreatedTimestamp
- , DelaySeconds
- , LastModifiedTimestamp
- , MaximumMessageSize
- , MessageRetentionPeriod
- , Policy
- , QueueARN
- , ReceiveMessageWaitTimeSeconds
- , RedrivePolicy
- , VisibilityTimeout
- ]
- buildAwsEnv :: IO Env
- buildAwsEnv = do
- logger <- newLogger Debug stdout
- env <- newEnv Oregon $ FromKeys
- (AccessKey "TODO")
- (SecretKey "TODO")
- return $ envWithLog logger env
- where
- envWithLog :: Logger -> Env -> Env
- envWithLog logger env = env & envLogger .~ logger
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement