@@ -1,10 +1,13 @@
1{-# LANGUAGE Arrows #-}
1{-# LANGUAGE Arrows #-}
2module Network.Azure.ServiceManagement
2module Network.Azure.ServiceManagement
3− ( -- * Setup
5+ -- * Setup
4− AzureSetup(..)
6+ , AzureSetup(..)
5 , azureSetup
7 , azureSetup
6 -- * High-level API
8 -- * High-level API
7 , hostedServices
9 , hostedServices
10+ , hostedServiceProperties
8 -- * Low-level API
11 -- * Low-level API
9 , azureRequest
12 , azureRequest
10 , azureRawRequest
13 , azureRawRequest
@@ -12,6 +15,7 @@ module Network.Azure.ServiceManagement
13import Prelude hiding (id)
16import Prelude hiding (id)
14import Control.Category (id, (>>>))
17import Control.Category (id, (>>>))
18+import Control.Arrow (arr)
15import Data.ByteString.Lazy (ByteString)
19import Data.ByteString.Lazy (ByteString)
16import Data.ByteString.Char8 as BSC (pack)
20import Data.ByteString.Char8 as BSC (pack)
17import Data.ByteString.Lazy.Char8 as BSLC (unpack)
21import Data.ByteString.Lazy.Char8 as BSLC (unpack)
@@ -34,13 +38,25 @@ import Text.XML.HXT.Core
36 , IOSArrow
40 , IOSArrow
38 , ArrowXml
41 , ArrowXml
45+ -- FOR DEBUGGING ONLY
51+--------------------------------------------------------------------------------
53+--------------------------------------------------------------------------------
55+newtype HostedService = HostedService { unHostedService :: String }
57+instance Show HostedService where
58+ show = unHostedService
44--------------------------------------------------------------------------------
60--------------------------------------------------------------------------------
45-- Setup --
61-- Setup --
46--------------------------------------------------------------------------------
62--------------------------------------------------------------------------------
@@ -72,13 +88,25 @@ azureSetup sid certPath pkeyPath = do
72-- High-level API --
88-- High-level API --
73--------------------------------------------------------------------------------
89--------------------------------------------------------------------------------
91+-- | Get list of available hosted services
75−hostedServices :: AzureSetup -> IO [(String, String)]
92+hostedServices :: AzureSetup -> IO [HostedService]
76hostedServices setup =
93hostedServices setup =
77− azureRequest setup "/services/hostedservices" "2012-03-01" $ proc xml -> do
94+ azureRequest setup subURL "2012-03-01" $ proc xml -> do
95+ writeDocument [withIndent yes] "hostedservices.xml" -< xml
78− hostedService <- deep (hasName "HostedService") -< xml
96+ hostedService <- deep (hasName "HostedService") -< xml
79− url <- getTextNode "Url" -< hostedService
80− serviceName <- getTextNode "ServiceName" -< hostedService
97+ name <- getTextNode "ServiceName" -< hostedService
81− id -< (url, serviceName)
98+ arr HostedService -< name
100+ subURL = "/services/hostedservices"
102+-- | Get properties of the given hosted service
103+hostedServiceProperties :: AzureSetup -> HostedService -> IO [()]
104+hostedServiceProperties setup (HostedService service) = do
105+ azureRequest setup subURL "2012-03-01" $ proc xml -> do
106+ writeDocument [withIndent yes] "properties.xml" -< xml
109+ subURL = "/services/hostedservices/" ++ service ++ "?embed-detail=true"
83--------------------------------------------------------------------------------
111--------------------------------------------------------------------------------
84-- Low-level API --
112-- Low-level API --