packages feed

hsakamai 0.1.0.0 → 0.1.0.1

raw patch · 2 files changed

+17/−12 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Akamai.NetStorage: delete :: Auth -> NetStoragePath -> IO (Response ByteString)
+ Akamai.NetStorage: delete :: MonadUnliftIO m => Auth -> NetStoragePath -> m (Response ByteString)
- Akamai.NetStorage: dir :: Auth -> NetStoragePath -> IO (Either SomeException [Contents])
+ Akamai.NetStorage: dir :: MonadUnliftIO m => Auth -> NetStoragePath -> m (Either SomeException [Contents])
- Akamai.NetStorage: download :: Auth -> NetStoragePath -> (Response () -> ConduitM ByteString Void IO a) -> IO a
+ Akamai.NetStorage: download :: MonadUnliftIO m => Auth -> NetStoragePath -> (Response () -> ConduitM ByteString Void m a) -> m a
- Akamai.NetStorage: mkReq :: Auth -> ByteString -> ByteString -> Action -> IO Request
+ Akamai.NetStorage: mkReq :: MonadUnliftIO m => Auth -> ByteString -> ByteString -> Action -> m Request
- Akamai.NetStorage: stat :: Auth -> NetStoragePath -> IO (Either SomeException [Contents])
+ Akamai.NetStorage: stat :: MonadUnliftIO m => Auth -> NetStoragePath -> m (Either SomeException [Contents])
- Akamai.NetStorage: upload :: Auth -> NetStoragePath -> Int64 -> ConduitM () ByteString IO () -> IO (Response ByteString)
+ Akamai.NetStorage: upload :: MonadUnliftIO m => Auth -> NetStoragePath -> Int64 -> ConduitM () ByteString IO () -> m (Response ByteString)

Files

hsakamai.cabal view
@@ -2,12 +2,12 @@ -- -- see: https://github.com/sol/hpack ----- hash: 6044931085d4715cad738d927656fc833fd07a6ffe0e2856a4a27970824059c0+-- hash: 5225be4cd7db0b121aa92388a1dda45cc2fd78f88dce9548894857436683db54  name:           hsakamai-version:        0.1.0.0+version:        0.1.0.1 synopsis:       Akamai API(Edgegrid and Netstorage)-description:    Please see the README on GitHub at <https://github.com/githubuser/hsakamai#readme>+description:    Please see the README on GitHub at <https://github.com/junjihashimoto/hsakamai#readme> category:       Web homepage:       https://github.com/junjihashimoto/hsakamai#readme bug-reports:    https://github.com/junjihashimoto/hsakamai/issues@@ -35,6 +35,7 @@       Paths_hsakamai   hs-source-dirs:       src+  default-extensions: Strict StrictData   ghc-options: -Wall   build-depends:       aeson@@ -61,6 +62,7 @@       Paths_hsakamai   hs-source-dirs:       app+  default-extensions: Strict StrictData   ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall   build-depends:       aeson@@ -92,6 +94,7 @@       Paths_hsakamai   hs-source-dirs:       test+  default-extensions: Strict StrictData   ghc-options: -threaded -rtsopts -with-rtsopts=-N   build-depends:       aeson
src/Akamai/NetStorage.hs view
@@ -23,6 +23,7 @@ import qualified Data.ByteString.Char8 as BC import qualified Data.ByteString.Lazy as BL import Data.Char (toLower)+import Conduit (MonadUnliftIO) import Data.Conduit import Data.Int (Int64) import Data.String (fromString)@@ -37,6 +38,7 @@ import System.Random (randomIO) import Text.XML import Text.XML.Cursor+import Control.Monad.IO.Class  type UnixTime = CTime type UniqueId = Word32@@ -134,40 +136,40 @@                     ["symlink"]:[name]:_ -> [Symlink name]                     _ -> [] -mkReq :: Auth -> ByteString -> ByteString -> Action -> IO Request+mkReq :: MonadUnliftIO m => Auth -> ByteString -> ByteString -> Action -> m Request mkReq auth method path action = do   let path' = "/" <> BC.pack (show (authCpCode auth)) <> "/" <> path-  initReq <- parseRequest $ BC.unpack $ method <> " "+  initReq <- liftIO $ parseRequest $ BC.unpack $ method <> " "     <> (if authSsl auth then "https" else "http")     <> "://" <> (T.encodeUtf8 (authHostname auth))     <> path'-  ut <- (getUnixTime >>= return.utSeconds)-  uid <- (randomIO >>= return.(\v -> v `mod` 10000))+  ut <- liftIO $ (getUnixTime >>= return.utSeconds)+  uid <- liftIO (randomIO >>= return.(\v -> v `mod` 10000))   return $ setRequestHeaders (authHeaders ut uid (authKeyName auth) path' action (authKey auth)) initReq -download :: Auth -> NetStoragePath -> ((Response () -> ConduitM ByteString Void IO a)) -> IO a+download :: MonadUnliftIO m => Auth -> NetStoragePath -> ((Response () -> ConduitM ByteString Void m a)) -> m a download auth path fn = do   req <- mkReq auth "GET" path "version=1&action=download"   httpSink req fn -dir :: Auth -> NetStoragePath -> IO (Either SomeException [Contents])+dir :: MonadUnliftIO m => Auth -> NetStoragePath -> m (Either SomeException [Contents]) dir auth path = do   req <- mkReq auth "GET" path "version=1&action=dir&format=xml"   res <- httpBS req   return $ parseContents $ responseBody res -stat :: Auth -> NetStoragePath -> IO (Either SomeException [Contents])+stat :: MonadUnliftIO m => Auth -> NetStoragePath -> m (Either SomeException [Contents]) stat auth path = do   req <- mkReq auth "GET" path "version=1&action=stat&format=xml"   res <- httpBS req   return $ parseContents $ responseBody res -delete :: Auth -> NetStoragePath -> IO (Response ByteString)+delete :: MonadUnliftIO m => Auth -> NetStoragePath -> m (Response ByteString) delete auth path = do   req <- mkReq auth "POST" path "version=1&action=delete"   httpBS req -upload :: Auth -> NetStoragePath -> Int64 -> (ConduitM () ByteString IO ()) -> IO (Response ByteString)+upload :: MonadUnliftIO m => Auth -> NetStoragePath -> Int64 -> (ConduitM () ByteString IO ()) -> m (Response ByteString) upload auth path size fn = do   initReq <- mkReq auth "PUT" path "version=1&action=upload&upload-type=binary"   let req = setRequestBodySource size fn initReq