git.iko.soy/distributed-process
on master help sign in
Update documentation
1da4711Edsko de Vries
azure-service-api/azure-service-api.cabal+10−2
@@ -3,8 +3,16 @@
3
3
4Name: azure-service-api
4Name: azure-service-api
5Version: 0.1.0.0
5Version: 0.1.0.0
6−Synopsis: Haskell bindings for the Azure Service Management API
6+Synopsis: Haskell bindings for the Microsoft Azure Service Management API
7−-- description:
7+Description: At the moment, this module only provides minimal
8+ functionality, just enough to support the
9+ "distributed-process-azure" package (Azure backend for
10+ Cloud Haskell). However, the code is set up in such a way
11+ that adding additional functionality should be relatively
12+ straightforward; developers who wish to do will probably
13+ want to consult the Windows Azure Service Management REST
14+ API Reference
15+ (<http://msdn.microsoft.com/en-us/library/windowsazure/ee460799.aspx>).
8Homepage: github.com/haskell-distributed/azure-service-api
16Homepage: github.com/haskell-distributed/azure-service-api
9License: BSD3
17License: BSD3
10License-File: LICENSE
18License-File: LICENSE
azure-service-api/src/Network/Azure/ServiceManagement.hs+46−18
@@ -1,17 +1,23 @@
1{-# LANGUAGE Arrows #-}
1{-# LANGUAGE Arrows #-}
2module Network.Azure.ServiceManagement
2module Network.Azure.ServiceManagement
3 ( -- * Data types
3 ( -- * Data types
4− HostedService(..)
5− , CloudService(..)
4+ CloudService
5+ , cloudServiceName
6+ , cloudServiceVMs
6− , VirtualMachine(..)
7+ , VirtualMachine
8+ , vmName
9+ , vmIpAddress
10+ , vmInputEndpoints
7− , Endpoint(..)
11+ , Endpoint
12+ , endpointName
13+ , endpointPort
14+ , endpointVip
8 -- * Pure functions
15 -- * Pure functions
9 , vmSshEndpoint
16 , vmSshEndpoint
10 -- * Setup
17 -- * Setup
11 , AzureSetup(..)
18 , AzureSetup(..)
12 , azureSetup
19 , azureSetup
13 -- * High-level API
20 -- * High-level API
14− , hostedServices
15 , cloudServices
21 , cloudServices
16 ) where
22 ) where
17
23
@@ -62,11 +68,7 @@ import Text.XML.HXT.Core
62 , IOSArrow
68 , IOSArrow
63 , ArrowXml
69 , ArrowXml
64 , getText
70 , getText
65−-- , writeDocumentToString
66−-- , withIndent
67−-- , yes
68 )
71 )
69−-- import Control.Arrow.ArrowIO (arrIO)
70import Text.XML.HXT.XPath (getXPathTrees)
72import Text.XML.HXT.XPath (getXPathTrees)
71
73
72--------------------------------------------------------------------------------
74--------------------------------------------------------------------------------
@@ -77,20 +79,39 @@ data HostedService = HostedService {
77 hostedServiceName :: String
79 hostedServiceName :: String
78 }
80 }
79
81
82+-- | A cloud service is a bunch of virtual machines that are part of the same
83+-- network (i.e., can talk to each other directly using standard TCP
84+-- connections).
80data CloudService = CloudService {
85data CloudService = CloudService {
86+ -- | Name of the service.
81 cloudServiceName :: String
87 cloudServiceName :: String
88+ -- | Virtual machines that are part of this cloud service.
82 , cloudServiceVMs :: [VirtualMachine]
89 , cloudServiceVMs :: [VirtualMachine]
83 }
90 }
84
91
92+-- | Virtual machine
85data VirtualMachine = VirtualMachine {
93data VirtualMachine = VirtualMachine {
94+ -- | Name of the virtual machine.
86 vmName :: String
95 vmName :: String
96+ -- | The /internal/ IP address of the virtual machine (that is, the
97+ -- IP address on the Cloud Service). For the globally accessible IP
98+ -- address see 'vmInputEndpoints'.
87 , vmIpAddress :: String
99 , vmIpAddress :: String
100+ -- | Globally accessible endpoints to the virtual machine
88 , vmInputEndpoints :: [Endpoint]
101 , vmInputEndpoints :: [Endpoint]
89 }
102 }
90
103
104+-- | Globally accessible endpoint for a virtual machine
91data Endpoint = Endpoint {
105data Endpoint = Endpoint {
106+ -- | Name of the endpoint (typical example: @SSH@)
92 endpointName :: String
107 endpointName :: String
108+ -- | Port number (typical examples are 22 or high numbered ports such as 53749)
93 , endpointPort :: String
109 , endpointPort :: String
110+ -- | Virtual IP address (that is, globally accessible IP address).
111+ --
112+ -- This corresponds to the IP address associated with the Cloud Service
113+ -- (i.e., that would be returned by a DNS lookup for @name.cloudapp.net@,
114+ -- where @name@ is the name of the Cloud Service).
94 , endpointVip :: String
115 , endpointVip :: String
95 }
116 }
96
117
@@ -148,6 +169,7 @@ hang2 d1 = hang d1 2
148-- Pure operations --
169-- Pure operations --
149--------------------------------------------------------------------------------
170--------------------------------------------------------------------------------
150
171
172+-- | Find the endpoint with name @SSH@.
151vmSshEndpoint :: VirtualMachine -> Maybe Endpoint
173vmSshEndpoint :: VirtualMachine -> Maybe Endpoint
152vmSshEndpoint vm = listToMaybe
174vmSshEndpoint vm = listToMaybe
153 [ ep
175 [ ep
@@ -160,11 +182,21 @@ vmSshEndpoint vm = listToMaybe
160--------------------------------------------------------------------------------
182--------------------------------------------------------------------------------
161
183
162-- | Azure setup
184-- | Azure setup
185+--
186+-- The documentation of "distributed-process-azure" explains in detail how
187+-- to obtain the SSL client certificate and the private key for your Azure
188+-- account.
189+--
190+-- See also 'azureSetup'.
163data AzureSetup = AzureSetup
191data AzureSetup = AzureSetup
192+ { -- | Azure subscription ID
164− { subscriptionId :: String
193+ subscriptionId :: String
194+ -- | SSL client certificate
165− , certificate :: X509
195+ , certificate :: X509
196+ -- | RSA private key
166− , privateKey :: PrivateKey
197+ , privateKey :: PrivateKey
198+ -- | Base URL (generally <https://management.core.windows.net>)
167− , baseUrl :: String
199+ , baseUrl :: String
168 }
200 }
169
201
170-- TODO: it's dubious to be transferring private keys, but we transfer them
202-- TODO: it's dubious to be transferring private keys, but we transfer them
@@ -221,7 +253,7 @@ azureSetup sid certPath pkeyPath = do
221-- High-level API --
253-- High-level API --
222--------------------------------------------------------------------------------
254--------------------------------------------------------------------------------
223
255
224−-- | Get a list of virtual machines
256+-- | Find available cloud services
225cloudServices :: AzureSetup -> IO [CloudService]
257cloudServices :: AzureSetup -> IO [CloudService]
226cloudServices setup = azureExecute setup $ \exec -> do
258cloudServices setup = azureExecute setup $ \exec -> do
227 services <- exec hostedServicesRequest
259 services <- exec hostedServicesRequest
@@ -240,10 +272,6 @@ cloudServices setup = azureExecute setup $ \exec -> do
240 }
272 }
241 return $ CloudService (hostedServiceName service) roles
273 return $ CloudService (hostedServiceName service) roles
242
274
243−-- | Get list of available hosted services
244−hostedServices :: AzureSetup -> IO [HostedService]
245−hostedServices setup = azureExecute setup (\exec -> exec hostedServicesRequest)
246−
247hostedServicesRequest :: AzureRequest HostedService
275hostedServicesRequest :: AzureRequest HostedService
248hostedServicesRequest = AzureRequest
276hostedServicesRequest = AzureRequest
249 { relativeUrl = "/services/hostedservices"
277 { relativeUrl = "/services/hostedservices"