Reorganize api

This commit is contained in:
Aditya Manthramurthy 2017-01-04 20:57:18 +05:30
parent 00e9198e60
commit fe1dfe24d6
5 changed files with 59 additions and 23 deletions

View File

@ -1,12 +1,10 @@
module Main where module Main where
-- import qualified Network.HTTP.Conduit as NC
import Protolude import Protolude
import Network.Minio.Data import Network.Minio
import Network.Minio.API -- import Network.Minio.S3API
import Control.Monad.Trans.Resource (runResourceT) import Control.Monad.Trans.Resource (runResourceT)
-- import qualified Data.Conduit as C -- import qualified Data.Conduit as C
-- import qualified Data.Conduit.List as CL -- import qualified Data.Conduit.List as CL

View File

@ -16,14 +16,16 @@ cabal-version: >=1.10
library library
hs-source-dirs: src hs-source-dirs: src
ghc-options: -Wall ghc-options: -Wall
exposed-modules: Network.Minio.Data exposed-modules: Network.Minio
, Network.Minio.S3API
other-modules: Lib.Prelude
, Network.Minio.Data
, Network.Minio.Data.ByteString , Network.Minio.Data.ByteString
, Network.Minio.Data.Crypto , Network.Minio.Data.Crypto
, Network.Minio.Data.Time , Network.Minio.Data.Time
, Network.Minio.Sign.V4 , Network.Minio.Sign.V4
, Network.Minio.API , Network.Minio.API
, Network.Minio.XmlParser , Network.Minio.XmlParser
other-modules: Lib.Prelude
build-depends: base >= 4.7 && < 5 build-depends: base >= 4.7 && < 5
, protolude >= 0.1.6 && < 0.2 , protolude >= 0.1.6 && < 0.2
, bytestring , bytestring

21
src/Network/Minio.hs Normal file
View File

@ -0,0 +1,21 @@
module Network.Minio
( module Exports
) where
{-
This module exports the high-level Minio API for object storage.
-}
import Network.Minio.S3API as
Exports (
getService
, getLocation
)
import Network.Minio.Data as
Exports (
runMinio
, defaultConnectInfo
, connect
, ConnectInfo(..)
)

View File

@ -4,8 +4,8 @@ module Network.Minio.API
, defaultConnectInfo , defaultConnectInfo
, RequestInfo(..) , RequestInfo(..)
, runMinio , runMinio
, getService , executeRequest
, getLocation , requestInfo
) where ) where
import qualified Network.HTTP.Types as HT import qualified Network.HTTP.Types as HT
@ -20,7 +20,6 @@ import qualified Data.Conduit as C
import Network.Minio.Data import Network.Minio.Data
import Network.Minio.Data.Crypto import Network.Minio.Data.Crypto
import Network.Minio.Sign.V4 import Network.Minio.Sign.V4
import Network.Minio.XmlParser
-- runRequestDebug r mgr = do -- runRequestDebug r mgr = do
-- print $ "runRequestDebug" -- print $ "runRequestDebug"
@ -94,17 +93,3 @@ requestInfo :: Method -> Maybe Bucket -> Maybe Object
-> Query -> [Header] -> Payload -> Query -> [Header] -> Payload
-> RequestInfo -> RequestInfo
requestInfo m b o q h p = RequestInfo m b o q h p "" requestInfo m b o q h p = RequestInfo m b o q h p ""
getService :: Minio [BucketInfo]
getService = do
resp <- executeRequest $
requestInfo HT.methodGet Nothing Nothing [] [] $
PayloadSingle ""
parseListBuckets $ NC.responseBody resp
getLocation :: Bucket -> Minio Text
getLocation bucket = do
resp <- executeRequest $
requestInfo HT.methodGet (Just bucket) Nothing [("location", Nothing)] []
(PayloadSingle "")
parseLocation $ NC.responseBody resp

View File

@ -0,0 +1,30 @@
module Network.Minio.S3API
( getService
, getLocation
) where
import qualified Network.HTTP.Types as HT
import qualified Network.HTTP.Conduit as NC
import Lib.Prelude
import Network.Minio.Data
import Network.Minio.API
import Network.Minio.XmlParser
getService :: Minio [BucketInfo]
getService = do
resp <- executeRequest $
requestInfo HT.methodGet Nothing Nothing [] [] $
PayloadSingle ""
parseListBuckets $ NC.responseBody resp
getLocation :: Bucket -> Minio Text
getLocation bucket = do
resp <- executeRequest $
requestInfo HT.methodGet (Just bucket) Nothing [("location", Nothing)] []
(PayloadSingle "")
parseLocation $ NC.responseBody resp
-- getObject ::