git.iko.soy/distributed-process
on master help sign in
Get properties of a hosted service

We don't parse the properties yet

commitb8b899c4968e5feab9f3d60d968b1fabfd4cebe4 authorEdsko de Vries <edsko@edsko.net> dateWed 25 Jul 2012, 17:55 (14 years ago) parent65b475e
2 files changed+42−9
azure-service-api/src/Network/Azure/ServiceManagement.hs+37−9 azure-service-api/src/Network/Azure/ServiceManagement/CommandLine.hs+5
azure-service-api/src/Network/Azure/ServiceManagement.hs+37−9
@@ -1,10 +1,13 @@
11{-# LANGUAGE Arrows #-}
22module Network.Azure.ServiceManagement
3− ( -- * Setup
4− AzureSetup(..)
3+ ( -- * Data types
4+ HostedService
5+ -- * Setup
6+ , AzureSetup(..)
57 , azureSetup
68 -- * High-level API
79 , hostedServices
10+ , hostedServiceProperties
811 -- * Low-level API
912 , azureRequest
1013 , azureRawRequest
@@ -12,6 +15,7 @@ module Network.Azure.ServiceManagement
1215
1316import Prelude hiding (id)
1417import Control.Category (id, (>>>))
18+import Control.Arrow (arr)
1519import Data.ByteString.Lazy (ByteString)
1620import Data.ByteString.Char8 as BSC (pack)
1721import Data.ByteString.Lazy.Char8 as BSLC (unpack)
@@ -34,13 +38,25 @@ import Text.XML.HXT.Core
3438 , no
3539 , XmlTree
3640 , IOSArrow
37− , XNode
3841 , ArrowXml
3942 , deep
4043 , hasName
4144 , getText
45+ -- FOR DEBUGGING ONLY
46+ , writeDocument
47+ , withIndent
48+ , yes
4249 )
4350
51+--------------------------------------------------------------------------------
52+-- Data types --
53+--------------------------------------------------------------------------------
54+
55+newtype HostedService = HostedService { unHostedService :: String }
56+
57+instance Show HostedService where
58+ show = unHostedService
59+
4460--------------------------------------------------------------------------------
4561-- Setup --
4662--------------------------------------------------------------------------------
@@ -72,13 +88,25 @@ azureSetup sid certPath pkeyPath = do
7288-- High-level API --
7389--------------------------------------------------------------------------------
7490
75−hostedServices :: AzureSetup -> IO [(String, String)]
91+-- | Get list of available hosted services
92+hostedServices :: AzureSetup -> IO [HostedService]
7693hostedServices setup =
77− azureRequest setup "/services/hostedservices" "2012-03-01" $ proc xml -> do
78− hostedService <- deep (hasName "HostedService") -< xml
79− url <- getTextNode "Url" -< hostedService
80− serviceName <- getTextNode "ServiceName" -< hostedService
81− id -< (url, serviceName)
94+ azureRequest setup subURL "2012-03-01" $ proc xml -> do
95+ writeDocument [withIndent yes] "hostedservices.xml" -< xml
96+ hostedService <- deep (hasName "HostedService") -< xml
97+ name <- getTextNode "ServiceName" -< hostedService
98+ arr HostedService -< name
99+ where
100+ subURL = "/services/hostedservices"
101+
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
107+ id -< ()
108+ where
109+ subURL = "/services/hostedservices/" ++ service ++ "?embed-detail=true"
82110
83111--------------------------------------------------------------------------------
84112-- Low-level API --
azure-service-api/src/Network/Azure/ServiceManagement/CommandLine.hs+5
@@ -1,4 +1,5 @@
11-- Base
2+import Control.Monad (forM_)
23import System.Environment (getArgs, getEnv)
34import System.FilePath ((</>))
45import System.Posix.Types (Fd)
@@ -7,6 +8,7 @@ import System.Posix.Types (Fd)
78import Network.Azure.ServiceManagement
89 ( azureSetup
910 , hostedServices
11+ , hostedServiceProperties
1012 )
1113
1214-- SSH
@@ -68,4 +70,7 @@ tryConnectToAzure sid pathToCert pathToKey = do
6870 setup <- azureSetup sid pathToCert pathToKey
6971 services <- hostedServices setup
7072 mapM_ print services
73+ forM_ services $ \service -> do
74+ props <- hostedServiceProperties setup service
75+ print props
7176