Merge lp:~julian-edwards/gwacl/deletedisk into lp:gwacl
- deletedisk
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Julian Edwards |
Approved revision: | 185 |
Merged at revision: | 179 |
Proposed branch: | lp:~julian-edwards/gwacl/deletedisk |
Merge into: | lp:gwacl |
Diff against target: |
971 lines (+150/-103) 10 files modified
deletedisk_test.go (+3/-3) management_base.go (+63/-30) management_base_test.go (+30/-28) management_test.go (+2/-5) poller.go (+2/-1) poller_test.go (+3/-3) x509dispatcher.go (+8/-11) x509dispatcher_test.go (+15/-6) x509session.go (+8/-8) x509session_test.go (+16/-8) |
To merge this branch: | bzr merge lp:~julian-edwards/gwacl/deletedisk |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeroen T. Vermeulen (community) | Approve | ||
Review via email: mp+174337@code.launchpad.net |
Commit message
Ensures each api call specifies its own x-ms-version and add Azure url links to relevant docs for each api call
Description of the change
I was intending this to be a fix for the disk deletion problem (http://
1. Adds Azure url links to relevant docs for each api call
2. Ensures each api call specifies its own x-ms-version. This is critical to prevent future cock ups and also because the deletedisk call requires a version other than the old base version.
3. Adds extra test coverage that was missing which ensures x-ms-header is set for all the session op methods.
Julian Edwards (julian-edwards) wrote : | # |
Jeroen T. Vermeulen (jtv) wrote : | # |
Good stuff. Consistent function documentation is lagniappe, but particularly appreciated. Sometimes a top comment for a function doesn't help understanding per se, but I still find that applying them inconsistently can frustrate the scanning of code. It's as if it makes my eyes recover from an exception rather than processing the text in a straight loop.
Preview Diff
1 | === modified file 'deletedisk_test.go' | |||
2 | --- deletedisk_test.go 2013-06-27 10:55:35 +0000 | |||
3 | +++ deletedisk_test.go 2013-07-12 05:06:27 +0000 | |||
4 | @@ -73,7 +73,7 @@ | |||
5 | 73 | c.Assert(response, IsNil) | 73 | c.Assert(response, IsNil) |
6 | 74 | c.Assert(err, IsNil) | 74 | c.Assert(err, IsNil) |
7 | 75 | expectedURL := api.session.composeURL("services/disks/" + diskName) | 75 | expectedURL := api.session.composeURL("services/disks/" + diskName) |
9 | 76 | checkOneRequest(c, recordedRequests, expectedURL, []byte{}, "DELETE") | 76 | checkOneRequest(c, recordedRequests, expectedURL, "2012-08-01", nil, "DELETE") |
10 | 77 | } | 77 | } |
11 | 78 | 78 | ||
12 | 79 | func (suite *deleteDiskSuite) TestManagementAPIDeleteDiskPolls(c *C) { | 79 | func (suite *deleteDiskSuite) TestManagementAPIDeleteDiskPolls(c *C) { |
13 | @@ -98,6 +98,6 @@ | |||
14 | 98 | c.Assert(err, IsNil) | 98 | c.Assert(err, IsNil) |
15 | 99 | expectedURL := api.session.composeURL("services/disks/" + diskName) | 99 | expectedURL := api.session.composeURL("services/disks/" + diskName) |
16 | 100 | c.Check(len(recordedRequests), Equals, 2) | 100 | c.Check(len(recordedRequests), Equals, 2) |
19 | 101 | checkRequest(c, recordedRequests[0], expectedURL, []byte{}, "DELETE") | 101 | checkRequest(c, recordedRequests[0], expectedURL, "2012-08-01", nil, "DELETE") |
20 | 102 | checkRequest(c, recordedRequests[1], expectedURL, []byte{}, "DELETE") | 102 | checkRequest(c, recordedRequests[1], expectedURL, "2012-08-01", nil, "DELETE") |
21 | 103 | } | 103 | } |
22 | 104 | 104 | ||
23 | === modified file 'management_base.go' | |||
24 | --- management_base.go 2013-07-10 15:42:42 +0000 | |||
25 | +++ management_base.go 2013-07-12 05:06:27 +0000 | |||
26 | @@ -97,7 +97,7 @@ | |||
27 | 97 | // Images are returned in the order in which Azure lists them. | 97 | // Images are returned in the order in which Azure lists them. |
28 | 98 | // http://msdn.microsoft.com/en-us/library/windowsazure/jj157191.aspx | 98 | // http://msdn.microsoft.com/en-us/library/windowsazure/jj157191.aspx |
29 | 99 | func (api *ManagementAPI) ListOSImages() (*Images, error) { | 99 | func (api *ManagementAPI) ListOSImages() (*Images, error) { |
31 | 100 | response, err := api.session.get("services/images") | 100 | response, err := api.session.get("services/images", "2013-03-01") |
32 | 101 | if err != nil { | 101 | if err != nil { |
33 | 102 | return nil, err | 102 | return nil, err |
34 | 103 | } | 103 | } |
35 | @@ -110,9 +110,9 @@ | |||
36 | 110 | // Azure management API. | 110 | // Azure management API. |
37 | 111 | // HostedServiceDescriptor objects contains a small subset of the fields present in | 111 | // HostedServiceDescriptor objects contains a small subset of the fields present in |
38 | 112 | // HostedService objects. | 112 | // HostedService objects. |
39 | 113 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460781.aspx | ||
40 | 113 | func (api *ManagementAPI) ListHostedServices() ([]HostedServiceDescriptor, error) { | 114 | func (api *ManagementAPI) ListHostedServices() ([]HostedServiceDescriptor, error) { |
43 | 114 | URI := "services/hostedservices" | 115 | res, err := api.session.get("services/hostedservices", "2012-03-01") |
42 | 115 | res, err := api.session.get(URI) | ||
44 | 116 | if err != nil { | 116 | if err != nil { |
45 | 117 | return nil, err | 117 | return nil, err |
46 | 118 | } | 118 | } |
47 | @@ -123,6 +123,7 @@ | |||
48 | 123 | 123 | ||
49 | 124 | // UpdateHostedService updates the provided values on the named service. | 124 | // UpdateHostedService updates the provided values on the named service. |
50 | 125 | // Use NewUpdateHostedService() to create an UpdateHostedService params object. | 125 | // Use NewUpdateHostedService() to create an UpdateHostedService params object. |
51 | 126 | // See http://msdn.microsoft.com/en-us/library/windowsazure/gg441303.aspx | ||
52 | 126 | func (api *ManagementAPI) UpdateHostedService(serviceName string, params *UpdateHostedService) error { | 127 | func (api *ManagementAPI) UpdateHostedService(serviceName string, params *UpdateHostedService) error { |
53 | 127 | var err error | 128 | var err error |
54 | 128 | checkPathComponents(serviceName) | 129 | checkPathComponents(serviceName) |
55 | @@ -131,7 +132,7 @@ | |||
56 | 131 | if err != nil { | 132 | if err != nil { |
57 | 132 | return err | 133 | return err |
58 | 133 | } | 134 | } |
60 | 134 | response, err := api.session.put(URI, []byte(body), "application/xml") | 135 | response, err := api.session.put(URI, "2012-03-01", []byte(body), "application/xml") |
61 | 135 | if err != nil { | 136 | if err != nil { |
62 | 136 | return err | 137 | return err |
63 | 137 | } | 138 | } |
64 | @@ -140,6 +141,7 @@ | |||
65 | 140 | 141 | ||
66 | 141 | // GetHostedServiceProperties loads a HostedService object from the Azure | 142 | // GetHostedServiceProperties loads a HostedService object from the Azure |
67 | 142 | // management API. | 143 | // management API. |
68 | 144 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460806.aspx | ||
69 | 143 | func (api *ManagementAPI) GetHostedServiceProperties( | 145 | func (api *ManagementAPI) GetHostedServiceProperties( |
70 | 144 | serviceName string, embedDetail bool) (*HostedService, error) { | 146 | serviceName string, embedDetail bool) (*HostedService, error) { |
71 | 145 | checkPathComponents(serviceName) | 147 | checkPathComponents(serviceName) |
72 | @@ -150,7 +152,7 @@ | |||
73 | 150 | case false: | 152 | case false: |
74 | 151 | URI += "false" | 153 | URI += "false" |
75 | 152 | } | 154 | } |
77 | 153 | res, err := api.session.get(URI) | 155 | res, err := api.session.get(URI, "2012-03-01") |
78 | 154 | if err != nil { | 156 | if err != nil { |
79 | 155 | return nil, err | 157 | return nil, err |
80 | 156 | } | 158 | } |
81 | @@ -162,21 +164,25 @@ | |||
82 | 162 | // AddHostedService adds a hosted service. | 164 | // AddHostedService adds a hosted service. |
83 | 163 | // This is an asynchronous operation on Azure, but this call blocks until the | 165 | // This is an asynchronous operation on Azure, but this call blocks until the |
84 | 164 | // operation is completed. | 166 | // operation is completed. |
85 | 167 | // This is actually called CreateHostedService in the Azure documentation. | ||
86 | 168 | // See http://msdn.microsoft.com/en-us/library/windowsazure/gg441304.aspx | ||
87 | 165 | func (api *ManagementAPI) AddHostedService(definition *CreateHostedService) error { | 169 | func (api *ManagementAPI) AddHostedService(definition *CreateHostedService) error { |
88 | 166 | URI := "services/hostedservices" | 170 | URI := "services/hostedservices" |
89 | 167 | body, err := marshalXML(definition) | 171 | body, err := marshalXML(definition) |
90 | 168 | if err != nil { | 172 | if err != nil { |
91 | 169 | return err | 173 | return err |
92 | 170 | } | 174 | } |
94 | 171 | response, err := api.session.post(URI, []byte(body), "application/xml") | 175 | response, err := api.session.post(URI, "2012-03-01", []byte(body), "application/xml") |
95 | 172 | if err != nil { | 176 | if err != nil { |
96 | 173 | return err | 177 | return err |
97 | 174 | } | 178 | } |
98 | 175 | return api.blockUntilCompleted(response) | 179 | return api.blockUntilCompleted(response) |
99 | 176 | } | 180 | } |
100 | 177 | 181 | ||
101 | 182 | // DeleteHostedService deletes the named hosted service. | ||
102 | 183 | // See http://msdn.microsoft.com/en-us/library/windowsazure/gg441305.aspx | ||
103 | 178 | func (api *ManagementAPI) DeleteHostedService(serviceName string) error { | 184 | func (api *ManagementAPI) DeleteHostedService(serviceName string) error { |
105 | 179 | response, err := api.session.delete("services/hostedservices/" + serviceName) | 185 | response, err := api.session.delete("services/hostedservices/" + serviceName, "2010-10-28") |
106 | 180 | if err != nil { | 186 | if err != nil { |
107 | 181 | return err | 187 | return err |
108 | 182 | } | 188 | } |
109 | @@ -184,7 +190,10 @@ | |||
110 | 184 | } | 190 | } |
111 | 185 | 191 | ||
112 | 186 | // AddDeployment adds a virtual machine deployment. | 192 | // AddDeployment adds a virtual machine deployment. |
114 | 187 | // This is an asynchronous operation, it blocks until the operation is completed. | 193 | // This is an asynchronous operation on Azure, but this call blocks until the |
115 | 194 | // operation is completed. | ||
116 | 195 | // This is actually called CreateDeployment in the Azure documentation. | ||
117 | 196 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460813.aspx | ||
118 | 188 | func (api *ManagementAPI) AddDeployment(definition *Deployment, serviceName string) error { | 197 | func (api *ManagementAPI) AddDeployment(definition *Deployment, serviceName string) error { |
119 | 189 | checkPathComponents(serviceName) | 198 | checkPathComponents(serviceName) |
120 | 190 | URI := "services/hostedservices/" + serviceName + "/deployments" | 199 | URI := "services/hostedservices/" + serviceName + "/deployments" |
121 | @@ -192,16 +201,18 @@ | |||
122 | 192 | if err != nil { | 201 | if err != nil { |
123 | 193 | return err | 202 | return err |
124 | 194 | } | 203 | } |
126 | 195 | response, err := api.session.post(URI, []byte(body), "application/xml") | 204 | response, err := api.session.post(URI, "2012-03-01", []byte(body), "application/xml") |
127 | 196 | if err != nil { | 205 | if err != nil { |
128 | 197 | return err | 206 | return err |
129 | 198 | } | 207 | } |
130 | 199 | return api.blockUntilCompleted(response) | 208 | return api.blockUntilCompleted(response) |
131 | 200 | } | 209 | } |
132 | 201 | 210 | ||
133 | 211 | // DeleteDeployment deletes the named deployment from the named hosted service. | ||
134 | 212 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460815.aspx | ||
135 | 202 | func (api *ManagementAPI) DeleteDeployment(serviceName string, deploymentName string) error { | 213 | func (api *ManagementAPI) DeleteDeployment(serviceName string, deploymentName string) error { |
136 | 203 | path := "services/hostedservices/" + serviceName + "/deployments/" + deploymentName | 214 | path := "services/hostedservices/" + serviceName + "/deployments/" + deploymentName |
138 | 204 | response, err := api.session.delete(path) | 215 | response, err := api.session.delete(path, "2012-03-01") |
139 | 205 | if err != nil { | 216 | if err != nil { |
140 | 206 | return err | 217 | return err |
141 | 207 | } | 218 | } |
142 | @@ -213,11 +224,14 @@ | |||
143 | 213 | DeploymentName string | 224 | DeploymentName string |
144 | 214 | } | 225 | } |
145 | 215 | 226 | ||
146 | 227 | // GetDeployment returns a Deployment object for the named hosted service and | ||
147 | 228 | // deployment name. | ||
148 | 229 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460804.aspx | ||
149 | 216 | func (api *ManagementAPI) GetDeployment(request *GetDeploymentRequest) (*Deployment, error) { | 230 | func (api *ManagementAPI) GetDeployment(request *GetDeploymentRequest) (*Deployment, error) { |
150 | 217 | checkPathComponents(request.ServiceName) | 231 | checkPathComponents(request.ServiceName) |
151 | 218 | checkPathComponents(request.DeploymentName) | 232 | checkPathComponents(request.DeploymentName) |
152 | 219 | path := "services/hostedservices/" + request.ServiceName + "/deployments/" + request.DeploymentName | 233 | path := "services/hostedservices/" + request.ServiceName + "/deployments/" + request.DeploymentName |
154 | 220 | response, err := api.session.get(path) | 234 | response, err := api.session.get(path, "2012-03-01") |
155 | 221 | if err != nil { | 235 | if err != nil { |
156 | 222 | return nil, err | 236 | return nil, err |
157 | 223 | } | 237 | } |
158 | @@ -232,14 +246,17 @@ | |||
159 | 232 | // AddStorageAccount starts the creation of a storage account. This is | 246 | // AddStorageAccount starts the creation of a storage account. This is |
160 | 233 | // called a storage service in the Azure API, but nomenclature seems to | 247 | // called a storage service in the Azure API, but nomenclature seems to |
161 | 234 | // have changed. | 248 | // have changed. |
163 | 235 | // This is an asynchronous operation, it blocks until the operation is completed. | 249 | // This is an asynchronous operation on Azure, but the call blocks until the |
164 | 250 | // operation is completed. | ||
165 | 251 | // This is actually called CreateStorageAccount in the Azure documentation. | ||
166 | 252 | // See http://msdn.microsoft.com/en-us/library/windowsazure/hh264518.aspx | ||
167 | 236 | func (api *ManagementAPI) AddStorageAccount(definition *CreateStorageServiceInput) error { | 253 | func (api *ManagementAPI) AddStorageAccount(definition *CreateStorageServiceInput) error { |
168 | 237 | uri := "services/storageservices" | 254 | uri := "services/storageservices" |
169 | 238 | body, err := marshalXML(definition) | 255 | body, err := marshalXML(definition) |
170 | 239 | if err != nil { | 256 | if err != nil { |
171 | 240 | return err | 257 | return err |
172 | 241 | } | 258 | } |
174 | 242 | response, err := api.session.post(uri, []byte(body), "application/xml") | 259 | response, err := api.session.post(uri, "2012-03-01", []byte(body), "application/xml") |
175 | 243 | if err != nil { | 260 | if err != nil { |
176 | 244 | return err | 261 | return err |
177 | 245 | } | 262 | } |
178 | @@ -247,8 +264,9 @@ | |||
179 | 247 | } | 264 | } |
180 | 248 | 265 | ||
181 | 249 | // DeleteStorageAccount deletes a storage account. | 266 | // DeleteStorageAccount deletes a storage account. |
182 | 267 | // See http://msdn.microsoft.com/en-us/library/windowsazure/hh264517.aspx | ||
183 | 250 | func (api *ManagementAPI) DeleteStorageAccount(storageAccountName string) error { | 268 | func (api *ManagementAPI) DeleteStorageAccount(storageAccountName string) error { |
185 | 251 | response, err := api.session.delete("services/storageservices/" + storageAccountName) | 269 | response, err := api.session.delete("services/storageservices/" + storageAccountName, "2011-06-01") |
186 | 252 | if err != nil { | 270 | if err != nil { |
187 | 253 | return err | 271 | return err |
188 | 254 | } | 272 | } |
189 | @@ -257,9 +275,10 @@ | |||
190 | 257 | 275 | ||
191 | 258 | // GetStorageAccountKeys retrieves a storage account's primary and secondary | 276 | // GetStorageAccountKeys retrieves a storage account's primary and secondary |
192 | 259 | // access keys from the Azure service. | 277 | // access keys from the Azure service. |
193 | 278 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460785.aspx | ||
194 | 260 | func (api *ManagementAPI) GetStorageAccountKeys(accountName string) (*StorageAccountKeys, error) { | 279 | func (api *ManagementAPI) GetStorageAccountKeys(accountName string) (*StorageAccountKeys, error) { |
195 | 261 | url := "services/storageservices/" + accountName + "/keys" | 280 | url := "services/storageservices/" + accountName + "/keys" |
197 | 262 | res, err := api.session.get(url) | 281 | res, err := api.session.get(url, "2009-10-01") |
198 | 263 | if err != nil { | 282 | if err != nil { |
199 | 264 | return nil, err | 283 | return nil, err |
200 | 265 | } | 284 | } |
201 | @@ -271,6 +290,9 @@ | |||
202 | 271 | return &keys, nil | 290 | return &keys, nil |
203 | 272 | } | 291 | } |
204 | 273 | 292 | ||
205 | 293 | // DeleteDisk deletes the named OS/data disk. | ||
206 | 294 | // See http://msdn.microsoft.com/en-us/library/windowsazure/jj157200.aspx | ||
207 | 295 | // TODO: set comp=media to optionally delete associated blob. | ||
208 | 274 | func (api *ManagementAPI) DeleteDisk(diskName string) error { | 296 | func (api *ManagementAPI) DeleteDisk(diskName string) error { |
209 | 275 | // Use the disk deletion poller to work around a bug in Windows Azure. | 297 | // Use the disk deletion poller to work around a bug in Windows Azure. |
210 | 276 | // See the documentation in the file deletedisk.go for details. | 298 | // See the documentation in the file deletedisk.go for details. |
211 | @@ -280,24 +302,25 @@ | |||
212 | 280 | } | 302 | } |
213 | 281 | 303 | ||
214 | 282 | func (api *ManagementAPI) _DeleteDisk(diskName string) error { | 304 | func (api *ManagementAPI) _DeleteDisk(diskName string) error { |
216 | 283 | response, err := api.session.delete("services/disks/" + diskName) | 305 | response, err := api.session.delete( |
217 | 306 | "services/disks/" + diskName, "2012-08-01") | ||
218 | 284 | if err != nil { | 307 | if err != nil { |
219 | 285 | return err | 308 | return err |
220 | 286 | } | 309 | } |
221 | 287 | return api.blockUntilCompleted(response) | 310 | return api.blockUntilCompleted(response) |
222 | 288 | } | 311 | } |
223 | 289 | 312 | ||
228 | 290 | // Perform an operation on the specified role (as defined by serviceName, deploymentName and | 313 | // Perform an operation on the specified role (as defined by serviceName, |
229 | 291 | // roleName) | 314 | // deploymentName and roleName) This is an asynchronous operation on Azure, but |
230 | 292 | // This is an asynchronous operation, it blocks until the operation is completed. | 315 | // the call blocks until the operation is completed. |
231 | 293 | func (api *ManagementAPI) performRoleOperation(serviceName string, deploymentName string, roleName string, operation *RoleOperation) error { | 316 | func (api *ManagementAPI) performRoleOperation(serviceName, deploymentName, roleName, apiVersion string, operation *RoleOperation) error { |
232 | 294 | checkPathComponents(serviceName, deploymentName, roleName) | 317 | checkPathComponents(serviceName, deploymentName, roleName) |
233 | 295 | URI := "services/hostedservices/" + serviceName + "/deployments/" + deploymentName + "/roleinstances/" + roleName + "/Operations" | 318 | URI := "services/hostedservices/" + serviceName + "/deployments/" + deploymentName + "/roleinstances/" + roleName + "/Operations" |
234 | 296 | body, err := marshalXML(operation) | 319 | body, err := marshalXML(operation) |
235 | 297 | if err != nil { | 320 | if err != nil { |
236 | 298 | return err | 321 | return err |
237 | 299 | } | 322 | } |
239 | 300 | response, err := api.session.post(URI, []byte(body), "application/xml") | 323 | response, err := api.session.post(URI, apiVersion, []byte(body), "application/xml") |
240 | 301 | if err != nil { | 324 | if err != nil { |
241 | 302 | return err | 325 | return err |
242 | 303 | } | 326 | } |
243 | @@ -313,40 +336,44 @@ | |||
244 | 313 | type StartRoleRequest performRoleOperationRequest | 336 | type StartRoleRequest performRoleOperationRequest |
245 | 314 | 337 | ||
246 | 315 | // StartRole starts the named Role. | 338 | // StartRole starts the named Role. |
247 | 339 | // See http://msdn.microsoft.com/en-us/library/windowsazure/jj157189.aspx | ||
248 | 316 | func (api *ManagementAPI) StartRole(request *StartRoleRequest) error { | 340 | func (api *ManagementAPI) StartRole(request *StartRoleRequest) error { |
249 | 317 | return api.performRoleOperation( | 341 | return api.performRoleOperation( |
250 | 318 | request.ServiceName, request.DeploymentName, request.RoleName, | 342 | request.ServiceName, request.DeploymentName, request.RoleName, |
252 | 319 | startRoleOperation) | 343 | "2012-03-01", startRoleOperation) |
253 | 320 | } | 344 | } |
254 | 321 | 345 | ||
255 | 322 | type RestartRoleRequest performRoleOperationRequest | 346 | type RestartRoleRequest performRoleOperationRequest |
256 | 323 | 347 | ||
257 | 324 | // RestartRole restarts the named Role. | 348 | // RestartRole restarts the named Role. |
258 | 349 | // See http://msdn.microsoft.com/en-us/library/windowsazure/jj157197.aspx | ||
259 | 325 | func (api *ManagementAPI) RestartRole(request *RestartRoleRequest) error { | 350 | func (api *ManagementAPI) RestartRole(request *RestartRoleRequest) error { |
260 | 326 | return api.performRoleOperation( | 351 | return api.performRoleOperation( |
261 | 327 | request.ServiceName, request.DeploymentName, request.RoleName, | 352 | request.ServiceName, request.DeploymentName, request.RoleName, |
263 | 328 | restartRoleOperation) | 353 | "2012-03-01", restartRoleOperation) |
264 | 329 | } | 354 | } |
265 | 330 | 355 | ||
266 | 331 | type ShutdownRoleRequest performRoleOperationRequest | 356 | type ShutdownRoleRequest performRoleOperationRequest |
267 | 332 | 357 | ||
268 | 333 | // ShutdownRole shuts down the named Role. | 358 | // ShutdownRole shuts down the named Role. |
269 | 359 | // See http://msdn.microsoft.com/en-us/library/windowsazure/jj157195.aspx | ||
270 | 334 | func (api *ManagementAPI) ShutdownRole(request *ShutdownRoleRequest) error { | 360 | func (api *ManagementAPI) ShutdownRole(request *ShutdownRoleRequest) error { |
271 | 335 | return api.performRoleOperation( | 361 | return api.performRoleOperation( |
272 | 336 | request.ServiceName, request.DeploymentName, request.RoleName, | 362 | request.ServiceName, request.DeploymentName, request.RoleName, |
274 | 337 | shutdownRoleOperation) | 363 | "2012-03-01", shutdownRoleOperation) |
275 | 338 | } | 364 | } |
276 | 339 | 365 | ||
277 | 340 | type GetRoleRequest performRoleOperationRequest | 366 | type GetRoleRequest performRoleOperationRequest |
278 | 341 | 367 | ||
279 | 342 | // GetRole requests the role data for the specified role. | 368 | // GetRole requests the role data for the specified role. |
280 | 369 | // See http://msdn.microsoft.com/en-us/library/windowsazure/jj157193.aspx | ||
281 | 343 | func (api *ManagementAPI) GetRole(request *GetRoleRequest) (*GetRole, error) { | 370 | func (api *ManagementAPI) GetRole(request *GetRoleRequest) (*GetRole, error) { |
282 | 344 | checkPathComponents( | 371 | checkPathComponents( |
283 | 345 | request.ServiceName, request.DeploymentName, request.RoleName) | 372 | request.ServiceName, request.DeploymentName, request.RoleName) |
284 | 346 | url := ("services/hostedservices/" + request.ServiceName + | 373 | url := ("services/hostedservices/" + request.ServiceName + |
285 | 347 | "/deployments/" + request.DeploymentName + "/roles/" + | 374 | "/deployments/" + request.DeploymentName + "/roles/" + |
286 | 348 | request.RoleName) | 375 | request.RoleName) |
288 | 349 | response, err := api.session.get(url) | 376 | response, err := api.session.get(url, "2012-03-01") |
289 | 350 | if err != nil { | 377 | if err != nil { |
290 | 351 | return nil, err | 378 | return nil, err |
291 | 352 | } | 379 | } |
292 | @@ -363,6 +390,7 @@ | |||
293 | 363 | } | 390 | } |
294 | 364 | 391 | ||
295 | 365 | // CreateAffinityGroup sends a request to make a new affinity group. | 392 | // CreateAffinityGroup sends a request to make a new affinity group. |
296 | 393 | // See http://msdn.microsoft.com/en-us/library/windowsazure/gg715317.aspx | ||
297 | 366 | func (api *ManagementAPI) CreateAffinityGroup(request *CreateAffinityGroupRequest) error { | 394 | func (api *ManagementAPI) CreateAffinityGroup(request *CreateAffinityGroupRequest) error { |
298 | 367 | var err error | 395 | var err error |
299 | 368 | url := "affinitygroups" | 396 | url := "affinitygroups" |
300 | @@ -370,7 +398,7 @@ | |||
301 | 370 | if err != nil { | 398 | if err != nil { |
302 | 371 | return err | 399 | return err |
303 | 372 | } | 400 | } |
305 | 373 | response, err := api.session.post(url, []byte(body), "application/xml") | 401 | response, err := api.session.post(url, "2012-03-01", []byte(body), "application/xml") |
306 | 374 | return api.blockUntilCompleted(response) | 402 | return api.blockUntilCompleted(response) |
307 | 375 | } | 403 | } |
308 | 376 | 404 | ||
309 | @@ -380,6 +408,7 @@ | |||
310 | 380 | } | 408 | } |
311 | 381 | 409 | ||
312 | 382 | // UpdateAffinityGroup sends a request to update the named affinity group. | 410 | // UpdateAffinityGroup sends a request to update the named affinity group. |
313 | 411 | // See http://msdn.microsoft.com/en-us/library/windowsazure/gg715316.aspx | ||
314 | 383 | func (api *ManagementAPI) UpdateAffinityGroup(request *UpdateAffinityGroupRequest) error { | 412 | func (api *ManagementAPI) UpdateAffinityGroup(request *UpdateAffinityGroupRequest) error { |
315 | 384 | var err error | 413 | var err error |
316 | 385 | checkPathComponents(request.Name) | 414 | checkPathComponents(request.Name) |
317 | @@ -388,7 +417,7 @@ | |||
318 | 388 | if err != nil { | 417 | if err != nil { |
319 | 389 | return err | 418 | return err |
320 | 390 | } | 419 | } |
322 | 391 | response, err := api.session.put(url, []byte(body), "application/xml") | 420 | response, err := api.session.put(url, "2011-02-25", []byte(body), "application/xml") |
323 | 392 | if err != nil { | 421 | if err != nil { |
324 | 393 | return err | 422 | return err |
325 | 394 | } | 423 | } |
326 | @@ -400,6 +429,7 @@ | |||
327 | 400 | } | 429 | } |
328 | 401 | 430 | ||
329 | 402 | // DeleteAffinityGroup requests a deletion of the named affinity group. | 431 | // DeleteAffinityGroup requests a deletion of the named affinity group. |
330 | 432 | // See http://msdn.microsoft.com/en-us/library/windowsazure/gg715314.aspx | ||
331 | 403 | func (api *ManagementAPI) DeleteAffinityGroup(request *DeleteAffinityGroupRequest) error { | 433 | func (api *ManagementAPI) DeleteAffinityGroup(request *DeleteAffinityGroupRequest) error { |
332 | 404 | var err error | 434 | var err error |
333 | 405 | checkPathComponents(request.Name) | 435 | checkPathComponents(request.Name) |
334 | @@ -407,7 +437,7 @@ | |||
335 | 407 | if err != nil { | 437 | if err != nil { |
336 | 408 | return err | 438 | return err |
337 | 409 | } | 439 | } |
339 | 410 | response, err := api.session.delete(url) | 440 | response, err := api.session.delete(url, "2011-02-25") |
340 | 411 | if err != nil { | 441 | if err != nil { |
341 | 412 | return err | 442 | return err |
342 | 413 | } | 443 | } |
343 | @@ -417,8 +447,9 @@ | |||
344 | 417 | // GetNetworkConfiguration gets the network configuration for this | 447 | // GetNetworkConfiguration gets the network configuration for this |
345 | 418 | // subscription. If there is no network configuration the configuration will | 448 | // subscription. If there is no network configuration the configuration will |
346 | 419 | // be nil. | 449 | // be nil. |
347 | 450 | // See http://msdn.microsoft.com/en-us/library/windowsazure/jj157196.aspx | ||
348 | 420 | func (api *ManagementAPI) GetNetworkConfiguration() (*NetworkConfiguration, error) { | 451 | func (api *ManagementAPI) GetNetworkConfiguration() (*NetworkConfiguration, error) { |
350 | 421 | response, err := api.session.get("services/networking/media") | 452 | response, err := api.session.get("services/networking/media", "2012-03-01") |
351 | 422 | if err != nil { | 453 | if err != nil { |
352 | 423 | if IsNotFoundError(err) { | 454 | if IsNotFoundError(err) { |
353 | 424 | return nil, nil | 455 | return nil, nil |
354 | @@ -442,7 +473,9 @@ | |||
355 | 442 | if err != nil { | 473 | if err != nil { |
356 | 443 | return err | 474 | return err |
357 | 444 | } | 475 | } |
359 | 445 | response, err := api.session.put("services/networking/media", []byte(body), "application/octet-stream") | 476 | response, err := api.session.put( |
360 | 477 | "services/networking/media", "2012-03-01", []byte(body), | ||
361 | 478 | "application/octet-stream") | ||
362 | 446 | if err != nil { | 479 | if err != nil { |
363 | 447 | return err | 480 | return err |
364 | 448 | } | 481 | } |
365 | 449 | 482 | ||
366 | === modified file 'management_base_test.go' | |||
367 | --- management_base_test.go 2013-07-10 16:02:17 +0000 | |||
368 | +++ management_base_test.go 2013-07-12 05:06:27 +0000 | |||
369 | @@ -246,17 +246,18 @@ | |||
370 | 246 | 246 | ||
371 | 247 | // checkOneRequest asserts that the given slice contains one request, with the | 247 | // checkOneRequest asserts that the given slice contains one request, with the |
372 | 248 | // given characteristics. | 248 | // given characteristics. |
374 | 249 | func checkOneRequest(c *C, recordedRequests *[]*X509Request, URL string, payload []byte, Method string) { | 249 | func checkOneRequest(c *C, recordedRequests *[]*X509Request, URL, version string, payload []byte, Method string) { |
375 | 250 | requests := *recordedRequests | 250 | requests := *recordedRequests |
376 | 251 | c.Assert(len(requests), Equals, 1) | 251 | c.Assert(len(requests), Equals, 1) |
377 | 252 | request := requests[0] | 252 | request := requests[0] |
379 | 253 | checkRequest(c, request, URL, payload, Method) | 253 | checkRequest(c, request, URL, version, payload, Method) |
380 | 254 | } | 254 | } |
381 | 255 | 255 | ||
386 | 256 | func checkRequest(c *C, request *X509Request, URL string, payload []byte, Method string) { | 256 | func checkRequest(c *C, request *X509Request, URL, version string, payload []byte, Method string) { |
387 | 257 | c.Assert(request.URL, Equals, URL) | 257 | c.Check(request.URL, Equals, URL) |
388 | 258 | c.Assert(string(request.Payload), Equals, string(payload)) | 258 | c.Check(string(request.Payload), Equals, string(payload)) |
389 | 259 | c.Assert(request.Method, Equals, Method) | 259 | c.Check(request.Method, Equals, Method) |
390 | 260 | c.Check(request.APIVersion, Equals, version) | ||
391 | 260 | } | 261 | } |
392 | 261 | 262 | ||
393 | 262 | func (suite *managementBaseAPISuite) TestGetOperationFailsIfNoHeader(c *C) { | 263 | func (suite *managementBaseAPISuite) TestGetOperationFailsIfNoHeader(c *C) { |
394 | @@ -366,7 +367,7 @@ | |||
395 | 366 | 367 | ||
396 | 367 | c.Assert(err, IsNil) | 368 | c.Assert(err, IsNil) |
397 | 368 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices" | 369 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices" |
399 | 369 | checkOneRequest(c, &recordedRequests, expectedURL, nil, "GET") | 370 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", nil, "GET") |
400 | 370 | c.Assert(descriptors[0].URL, Equals, url) | 371 | c.Assert(descriptors[0].URL, Equals, url) |
401 | 371 | } | 372 | } |
402 | 372 | 373 | ||
403 | @@ -396,7 +397,7 @@ | |||
404 | 396 | 397 | ||
405 | 397 | c.Assert(err, IsNil) | 398 | c.Assert(err, IsNil) |
406 | 398 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices/" + serviceName | 399 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices/" + serviceName |
408 | 399 | checkOneRequest(c, &recordedRequests, expectedURL, requestPayload, "PUT") | 400 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", requestPayload, "PUT") |
409 | 400 | } | 401 | } |
410 | 401 | 402 | ||
411 | 402 | func assertGetHostedServicePropertiesRequest(c *C, api *ManagementAPI, serviceName string, embedDetail bool, httpRequest *X509Request) { | 403 | func assertGetHostedServicePropertiesRequest(c *C, api *ManagementAPI, serviceName string, embedDetail bool, httpRequest *X509Request) { |
412 | @@ -408,7 +409,7 @@ | |||
413 | 408 | } | 409 | } |
414 | 409 | expectedURL := fmt.Sprintf("%s%s/services/hostedservices/%s?%s", AZURE_URL, | 410 | expectedURL := fmt.Sprintf("%s%s/services/hostedservices/%s?%s", AZURE_URL, |
415 | 410 | api.session.subscriptionId, serviceName, query) | 411 | api.session.subscriptionId, serviceName, query) |
417 | 411 | checkRequest(c, httpRequest, expectedURL, nil, "GET") | 412 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", nil, "GET") |
418 | 412 | } | 413 | } |
419 | 413 | 414 | ||
420 | 414 | func (suite *managementBaseAPISuite) TestGetHostedServiceProperties_withoutDetails(c *C) { | 415 | func (suite *managementBaseAPISuite) TestGetHostedServiceProperties_withoutDetails(c *C) { |
421 | @@ -517,13 +518,13 @@ | |||
422 | 517 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices" | 518 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices" |
423 | 518 | expectedPayload, err := marshalXML(createHostedService) | 519 | expectedPayload, err := marshalXML(createHostedService) |
424 | 519 | c.Assert(err, IsNil) | 520 | c.Assert(err, IsNil) |
426 | 520 | checkOneRequest(c, recordedRequests, expectedURL, expectedPayload, "POST") | 521 | checkOneRequest(c, recordedRequests, expectedURL, "2012-03-01", expectedPayload, "POST") |
427 | 521 | } | 522 | } |
428 | 522 | 523 | ||
429 | 523 | func assertDeleteHostedServiceRequest(c *C, api *ManagementAPI, serviceName string, httpRequest *X509Request) { | 524 | func assertDeleteHostedServiceRequest(c *C, api *ManagementAPI, serviceName string, httpRequest *X509Request) { |
430 | 524 | expectedURL := fmt.Sprintf("%s%s/services/hostedservices/%s", AZURE_URL, | 525 | expectedURL := fmt.Sprintf("%s%s/services/hostedservices/%s", AZURE_URL, |
431 | 525 | api.session.subscriptionId, serviceName) | 526 | api.session.subscriptionId, serviceName) |
433 | 526 | checkRequest(c, httpRequest, expectedURL, nil, "DELETE") | 527 | checkRequest(c, httpRequest, expectedURL, "2010-10-28", nil, "DELETE") |
434 | 527 | } | 528 | } |
435 | 528 | 529 | ||
436 | 529 | func (suite *managementBaseAPISuite) TestDeleteHostedService(c *C) { | 530 | func (suite *managementBaseAPISuite) TestDeleteHostedService(c *C) { |
437 | @@ -550,14 +551,14 @@ | |||
438 | 550 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices/" + serviceName + "/deployments" | 551 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices/" + serviceName + "/deployments" |
439 | 551 | expectedPayload, err := marshalXML(deployment) | 552 | expectedPayload, err := marshalXML(deployment) |
440 | 552 | c.Assert(err, IsNil) | 553 | c.Assert(err, IsNil) |
442 | 553 | checkOneRequest(c, recordedRequests, expectedURL, expectedPayload, "POST") | 554 | checkOneRequest(c, recordedRequests, expectedURL, "2012-03-01", expectedPayload, "POST") |
443 | 554 | } | 555 | } |
444 | 555 | 556 | ||
445 | 556 | func assertDeleteDeploymentRequest(c *C, api *ManagementAPI, hostedServiceName, deploymentName string, httpRequest *X509Request) { | 557 | func assertDeleteDeploymentRequest(c *C, api *ManagementAPI, hostedServiceName, deploymentName string, httpRequest *X509Request) { |
446 | 557 | expectedURL := fmt.Sprintf( | 558 | expectedURL := fmt.Sprintf( |
447 | 558 | "%s%s/services/hostedservices/%s/deployments/%s", AZURE_URL, | 559 | "%s%s/services/hostedservices/%s/deployments/%s", AZURE_URL, |
448 | 559 | api.session.subscriptionId, hostedServiceName, deploymentName) | 560 | api.session.subscriptionId, hostedServiceName, deploymentName) |
450 | 560 | checkRequest(c, httpRequest, expectedURL, nil, "DELETE") | 561 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", nil, "DELETE") |
451 | 561 | } | 562 | } |
452 | 562 | 563 | ||
453 | 563 | func (suite *managementBaseAPISuite) TestDeleteDeployment(c *C) { | 564 | func (suite *managementBaseAPISuite) TestDeleteDeployment(c *C) { |
454 | @@ -650,7 +651,7 @@ | |||
455 | 650 | expectedURL := fmt.Sprintf( | 651 | expectedURL := fmt.Sprintf( |
456 | 651 | "%s%s/services/hostedservices/%s/deployments/%s", AZURE_URL, | 652 | "%s%s/services/hostedservices/%s/deployments/%s", AZURE_URL, |
457 | 652 | api.session.subscriptionId, request.ServiceName, request.DeploymentName) | 653 | api.session.subscriptionId, request.ServiceName, request.DeploymentName) |
459 | 653 | checkRequest(c, httpRequest, expectedURL, nil, "GET") | 654 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", nil, "GET") |
460 | 654 | } | 655 | } |
461 | 655 | 656 | ||
462 | 656 | func (suite *managementBaseAPISuite) TestGetDeployment(c *C) { | 657 | func (suite *managementBaseAPISuite) TestGetDeployment(c *C) { |
463 | @@ -693,7 +694,7 @@ | |||
464 | 693 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/storageservices" | 694 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/storageservices" |
465 | 694 | expectedPayload, err := marshalXML(cssi) | 695 | expectedPayload, err := marshalXML(cssi) |
466 | 695 | c.Assert(err, IsNil) | 696 | c.Assert(err, IsNil) |
468 | 696 | checkOneRequest(c, &recordedRequests, expectedURL, expectedPayload, "POST") | 697 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", expectedPayload, "POST") |
469 | 697 | } | 698 | } |
470 | 698 | 699 | ||
471 | 699 | func (suite *managementBaseAPISuite) TestDeleteStorageAccount(c *C) { | 700 | func (suite *managementBaseAPISuite) TestDeleteStorageAccount(c *C) { |
472 | @@ -705,7 +706,7 @@ | |||
473 | 705 | err := api.DeleteStorageAccount(accountName) | 706 | err := api.DeleteStorageAccount(accountName) |
474 | 706 | c.Assert(err, IsNil) | 707 | c.Assert(err, IsNil) |
475 | 707 | 708 | ||
477 | 708 | checkOneRequest(c, recordedRequests, accountURL, nil, "DELETE") | 709 | checkOneRequest(c, recordedRequests, accountURL, "2011-06-01", nil, "DELETE") |
478 | 709 | } | 710 | } |
479 | 710 | 711 | ||
480 | 711 | func (suite *managementBaseAPISuite) TestGetStorageAccountKeys(c *C) { | 712 | func (suite *managementBaseAPISuite) TestGetStorageAccountKeys(c *C) { |
481 | @@ -741,7 +742,7 @@ | |||
482 | 741 | func assertDeleteDiskRequest(c *C, api *ManagementAPI, diskName string, httpRequest *X509Request) { | 742 | func assertDeleteDiskRequest(c *C, api *ManagementAPI, diskName string, httpRequest *X509Request) { |
483 | 742 | expectedURL := fmt.Sprintf("%s%s/services/disks/%s", AZURE_URL, | 743 | expectedURL := fmt.Sprintf("%s%s/services/disks/%s", AZURE_URL, |
484 | 743 | api.session.subscriptionId, diskName) | 744 | api.session.subscriptionId, diskName) |
486 | 744 | checkRequest(c, httpRequest, expectedURL, nil, "DELETE") | 745 | checkRequest(c, httpRequest, expectedURL, "2012-08-01", nil, "DELETE") |
487 | 745 | } | 746 | } |
488 | 746 | 747 | ||
489 | 747 | func (suite *managementBaseAPISuite) TestDeleteDisk(c *C) { | 748 | func (suite *managementBaseAPISuite) TestDeleteDisk(c *C) { |
490 | @@ -767,13 +768,14 @@ | |||
491 | 767 | deploymentName := "deploymentName" | 768 | deploymentName := "deploymentName" |
492 | 768 | roleName := "roleName" | 769 | roleName := "roleName" |
493 | 769 | operation := newRoleOperation("RandomOperation") | 770 | operation := newRoleOperation("RandomOperation") |
495 | 770 | err := api.performRoleOperation(serviceName, deploymentName, roleName, operation) | 771 | version := "test-version" |
496 | 772 | err := api.performRoleOperation(serviceName, deploymentName, roleName, version, operation) | ||
497 | 771 | 773 | ||
498 | 772 | c.Assert(err, IsNil) | 774 | c.Assert(err, IsNil) |
499 | 773 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices/" + serviceName + "/deployments/" + deploymentName + "/roleinstances/" + roleName + "/Operations" | 775 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices/" + serviceName + "/deployments/" + deploymentName + "/roleinstances/" + roleName + "/Operations" |
500 | 774 | expectedPayload, err := marshalXML(operation) | 776 | expectedPayload, err := marshalXML(operation) |
501 | 775 | c.Assert(err, IsNil) | 777 | c.Assert(err, IsNil) |
503 | 776 | checkOneRequest(c, recordedRequests, expectedURL, expectedPayload, "POST") | 778 | checkOneRequest(c, recordedRequests, expectedURL, version, expectedPayload, "POST") |
504 | 777 | } | 779 | } |
505 | 778 | 780 | ||
506 | 779 | func (suite *managementBaseAPISuite) TestStartRole(c *C) { | 781 | func (suite *managementBaseAPISuite) TestStartRole(c *C) { |
507 | @@ -787,7 +789,7 @@ | |||
508 | 787 | request.RoleName + "/Operations") | 789 | request.RoleName + "/Operations") |
509 | 788 | expectedPayload, err := marshalXML(startRoleOperation) | 790 | expectedPayload, err := marshalXML(startRoleOperation) |
510 | 789 | c.Assert(err, IsNil) | 791 | c.Assert(err, IsNil) |
512 | 790 | checkOneRequest(c, recordedRequests, expectedURL, expectedPayload, "POST") | 792 | checkOneRequest(c, recordedRequests, expectedURL, "2012-03-01", expectedPayload, "POST") |
513 | 791 | } | 793 | } |
514 | 792 | 794 | ||
515 | 793 | func (suite *managementBaseAPISuite) TestRestartRole(c *C) { | 795 | func (suite *managementBaseAPISuite) TestRestartRole(c *C) { |
516 | @@ -801,7 +803,7 @@ | |||
517 | 801 | request.RoleName + "/Operations") | 803 | request.RoleName + "/Operations") |
518 | 802 | expectedPayload, err := marshalXML(restartRoleOperation) | 804 | expectedPayload, err := marshalXML(restartRoleOperation) |
519 | 803 | c.Assert(err, IsNil) | 805 | c.Assert(err, IsNil) |
521 | 804 | checkOneRequest(c, recordedRequests, expectedURL, expectedPayload, "POST") | 806 | checkOneRequest(c, recordedRequests, expectedURL, "2012-03-01", expectedPayload, "POST") |
522 | 805 | } | 807 | } |
523 | 806 | 808 | ||
524 | 807 | func assertShutdownRoleRequest(c *C, api *ManagementAPI, request *ShutdownRoleRequest, httpRequest *X509Request) { | 809 | func assertShutdownRoleRequest(c *C, api *ManagementAPI, request *ShutdownRoleRequest, httpRequest *X509Request) { |
525 | @@ -811,7 +813,7 @@ | |||
526 | 811 | request.DeploymentName, request.RoleName) | 813 | request.DeploymentName, request.RoleName) |
527 | 812 | expectedPayload, err := marshalXML(shutdownRoleOperation) | 814 | expectedPayload, err := marshalXML(shutdownRoleOperation) |
528 | 813 | c.Assert(err, IsNil) | 815 | c.Assert(err, IsNil) |
530 | 814 | checkRequest(c, httpRequest, expectedURL, expectedPayload, "POST") | 816 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", expectedPayload, "POST") |
531 | 815 | } | 817 | } |
532 | 816 | 818 | ||
533 | 817 | func (suite *managementBaseAPISuite) TestShutdownRole(c *C) { | 819 | func (suite *managementBaseAPISuite) TestShutdownRole(c *C) { |
534 | @@ -843,7 +845,7 @@ | |||
535 | 843 | "/services/hostedservices/" + | 845 | "/services/hostedservices/" + |
536 | 844 | request.ServiceName + "/deployments/" + request.DeploymentName + | 846 | request.ServiceName + "/deployments/" + request.DeploymentName + |
537 | 845 | "/roles/" + request.RoleName) | 847 | "/roles/" + request.RoleName) |
539 | 846 | checkOneRequest(c, &recordedRequests, expectedURL, nil, "GET") | 848 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", nil, "GET") |
540 | 847 | 849 | ||
541 | 848 | c.Check(role.RoleName, Equals, "rolename") | 850 | c.Check(role.RoleName, Equals, "rolename") |
542 | 849 | } | 851 | } |
543 | @@ -865,7 +867,7 @@ | |||
544 | 865 | 867 | ||
545 | 866 | expectedURL := AZURE_URL + api.session.subscriptionId + "/affinitygroups" | 868 | expectedURL := AZURE_URL + api.session.subscriptionId + "/affinitygroups" |
546 | 867 | expectedBody, _ := cag.Serialize() | 869 | expectedBody, _ := cag.Serialize() |
548 | 868 | checkOneRequest(c, &recordedRequests, expectedURL, []byte(expectedBody), "POST") | 870 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", []byte(expectedBody), "POST") |
549 | 869 | } | 871 | } |
550 | 870 | 872 | ||
551 | 871 | func (suite *managementBaseAPISuite) TestUpdateAffinityGroup(c *C) { | 873 | func (suite *managementBaseAPISuite) TestUpdateAffinityGroup(c *C) { |
552 | @@ -886,7 +888,7 @@ | |||
553 | 886 | expectedURL := (AZURE_URL + api.session.subscriptionId + | 888 | expectedURL := (AZURE_URL + api.session.subscriptionId + |
554 | 887 | "/affinitygroups/" + request.Name) | 889 | "/affinitygroups/" + request.Name) |
555 | 888 | expectedBody, _ := uag.Serialize() | 890 | expectedBody, _ := uag.Serialize() |
557 | 889 | checkOneRequest(c, &recordedRequests, expectedURL, []byte(expectedBody), "PUT") | 891 | checkOneRequest(c, &recordedRequests, expectedURL, "2011-02-25", []byte(expectedBody), "PUT") |
558 | 890 | } | 892 | } |
559 | 891 | 893 | ||
560 | 892 | func (suite *managementBaseAPISuite) TestDeleteAffinityGroup(c *C) { | 894 | func (suite *managementBaseAPISuite) TestDeleteAffinityGroup(c *C) { |
561 | @@ -904,7 +906,7 @@ | |||
562 | 904 | 906 | ||
563 | 905 | expectedURL := (AZURE_URL + api.session.subscriptionId + | 907 | expectedURL := (AZURE_URL + api.session.subscriptionId + |
564 | 906 | "/affinitygroups/" + request.Name) | 908 | "/affinitygroups/" + request.Name) |
566 | 907 | checkOneRequest(c, &recordedRequests, expectedURL, nil, "DELETE") | 909 | checkOneRequest(c, &recordedRequests, expectedURL, "2011-02-25", nil, "DELETE") |
567 | 908 | } | 910 | } |
568 | 909 | 911 | ||
569 | 910 | func makeNetworkConfiguration() *NetworkConfiguration { | 912 | func makeNetworkConfiguration() *NetworkConfiguration { |
570 | @@ -964,7 +966,7 @@ | |||
571 | 964 | expectedURL := fmt.Sprintf( | 966 | expectedURL := fmt.Sprintf( |
572 | 965 | "%s%s/services/networking/media", AZURE_URL, | 967 | "%s%s/services/networking/media", AZURE_URL, |
573 | 966 | api.session.subscriptionId) | 968 | api.session.subscriptionId) |
575 | 967 | checkRequest(c, httpRequest, expectedURL, nil, "GET") | 969 | checkRequest(c, httpRequest, expectedURL, "2012-03-01", nil, "GET") |
576 | 968 | } | 970 | } |
577 | 969 | 971 | ||
578 | 970 | func (suite *managementBaseAPISuite) TestGetNetworkConfiguration(c *C) { | 972 | func (suite *managementBaseAPISuite) TestGetNetworkConfiguration(c *C) { |
579 | @@ -1014,5 +1016,5 @@ | |||
580 | 1014 | 1016 | ||
581 | 1015 | c.Assert(err, IsNil) | 1017 | c.Assert(err, IsNil) |
582 | 1016 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/networking/media" | 1018 | expectedURL := AZURE_URL + api.session.subscriptionId + "/services/networking/media" |
584 | 1017 | checkOneRequest(c, &recordedRequests, expectedURL, requestPayload, "PUT") | 1019 | checkOneRequest(c, &recordedRequests, expectedURL, "2012-03-01", requestPayload, "PUT") |
585 | 1018 | } | 1020 | } |
586 | 1019 | 1021 | ||
587 | === modified file 'management_test.go' | |||
588 | --- management_test.go 2013-07-10 15:37:52 +0000 | |||
589 | +++ management_test.go 2013-07-12 05:06:27 +0000 | |||
590 | @@ -88,11 +88,8 @@ | |||
591 | 88 | expectedURL := fmt.Sprintf( | 88 | expectedURL := fmt.Sprintf( |
592 | 89 | "%ssubscriptionId/services/hostedservices/%s?embed-detail=true", | 89 | "%ssubscriptionId/services/hostedservices/%s?embed-detail=true", |
593 | 90 | AZURE_URL, service.ServiceName) | 90 | AZURE_URL, service.ServiceName) |
599 | 91 | c.Check(record[0], DeepEquals, &X509Request{ | 91 | c.Check(record[0].URL, Equals, expectedURL) |
600 | 92 | APIVersion: baseAPIVersion, | 92 | c.Check(record[0].Method, Equals, "GET") |
596 | 93 | URL: expectedURL, | ||
597 | 94 | Method: "GET", | ||
598 | 95 | }) | ||
601 | 96 | } | 93 | } |
602 | 97 | 94 | ||
603 | 98 | func (suite *managementAPISuite) TestListInstancesFailsGettingDetails(c *C) { | 95 | func (suite *managementAPISuite) TestListInstancesFailsGettingDetails(c *C) { |
604 | 99 | 96 | ||
605 | === modified file 'poller.go' | |||
606 | --- poller.go 2013-07-02 14:22:42 +0000 | |||
607 | +++ poller.go 2013-07-12 05:06:27 +0000 | |||
608 | @@ -93,9 +93,10 @@ | |||
609 | 93 | 93 | ||
610 | 94 | // Poll issues a blocking request to microsoft Azure to fetch the information | 94 | // Poll issues a blocking request to microsoft Azure to fetch the information |
611 | 95 | // related to the operation associated with the poller. | 95 | // related to the operation associated with the poller. |
612 | 96 | // See http://msdn.microsoft.com/en-us/library/windowsazure/ee460783.aspx | ||
613 | 96 | func (poller operationPoller) poll() (*x509Response, error) { | 97 | func (poller operationPoller) poll() (*x509Response, error) { |
614 | 97 | URI := "operations/" + poller.operationID | 98 | URI := "operations/" + poller.operationID |
616 | 98 | return poller.api.session.get(URI) | 99 | return poller.api.session.get(URI, "2009-10-01") |
617 | 99 | } | 100 | } |
618 | 100 | 101 | ||
619 | 101 | // IsDone returns true if the given response has a status code indicating | 102 | // IsDone returns true if the given response has a status code indicating |
620 | 102 | 103 | ||
621 | === modified file 'poller_test.go' | |||
622 | --- poller_test.go 2013-07-02 13:51:00 +0000 | |||
623 | +++ poller_test.go 2013-07-12 05:06:27 +0000 | |||
624 | @@ -120,7 +120,7 @@ | |||
625 | 120 | 120 | ||
626 | 121 | c.Assert(err, IsNil) | 121 | c.Assert(err, IsNil) |
627 | 122 | expectedURL := AZURE_URL + api.session.subscriptionId + "/operations/" + operationID | 122 | expectedURL := AZURE_URL + api.session.subscriptionId + "/operations/" + operationID |
629 | 123 | checkOneRequest(c, recordedRequests, expectedURL, []byte{}, "GET") | 123 | checkOneRequest(c, recordedRequests, expectedURL, "2009-10-01", nil, "GET") |
630 | 124 | } | 124 | } |
631 | 125 | 125 | ||
632 | 126 | var operationXMLTemplate = dedent.Dedent(` | 126 | var operationXMLTemplate = dedent.Dedent(` |
633 | @@ -212,6 +212,6 @@ | |||
634 | 212 | operationPollerInstance := poller.(operationPoller) | 212 | operationPollerInstance := poller.(operationPoller) |
635 | 213 | expectedURL := AZURE_URL + operationPollerInstance.api.session.subscriptionId + "/operations/" + operationID | 213 | expectedURL := AZURE_URL + operationPollerInstance.api.session.subscriptionId + "/operations/" + operationID |
636 | 214 | c.Assert(len(recordedRequests), Equals, 2) | 214 | c.Assert(len(recordedRequests), Equals, 2) |
639 | 215 | checkRequest(c, recordedRequests[0], expectedURL, []byte{}, "GET") | 215 | checkRequest(c, recordedRequests[0], expectedURL, "2009-10-01", nil, "GET") |
640 | 216 | checkRequest(c, recordedRequests[1], expectedURL, []byte{}, "GET") | 216 | checkRequest(c, recordedRequests[1], expectedURL, "2009-10-01", nil, "GET") |
641 | 217 | } | 217 | } |
642 | 218 | 218 | ||
643 | === modified file 'x509dispatcher.go' | |||
644 | --- x509dispatcher.go 2013-07-10 15:42:42 +0000 | |||
645 | +++ x509dispatcher.go 2013-07-12 05:06:27 +0000 | |||
646 | @@ -25,47 +25,44 @@ | |||
647 | 25 | verbose = newVerbose | 25 | verbose = newVerbose |
648 | 26 | } | 26 | } |
649 | 27 | 27 | ||
650 | 28 | // baseAPIVersion is the default Azure API version to use. | ||
651 | 29 | const baseAPIVersion = "2013-03-01" | ||
652 | 30 | |||
653 | 31 | // newX509RequestGET initializes an X509Request for a GET. You may still need | 28 | // newX509RequestGET initializes an X509Request for a GET. You may still need |
654 | 32 | // to set further values. | 29 | // to set further values. |
656 | 33 | func newX509RequestGET(url string) *X509Request { | 30 | func newX509RequestGET(url, apiVersion string) *X509Request { |
657 | 34 | return &X509Request{ | 31 | return &X509Request{ |
658 | 35 | Method: "GET", | 32 | Method: "GET", |
659 | 36 | URL: url, | 33 | URL: url, |
661 | 37 | APIVersion: baseAPIVersion, | 34 | APIVersion: apiVersion, |
662 | 38 | } | 35 | } |
663 | 39 | } | 36 | } |
664 | 40 | 37 | ||
665 | 41 | // newX509RequestPOST initializes an X509Request for a POST. You may still | 38 | // newX509RequestPOST initializes an X509Request for a POST. You may still |
666 | 42 | // need to set further values. | 39 | // need to set further values. |
668 | 43 | func newX509RequestPOST(url string, payload []byte, contentType string) *X509Request { | 40 | func newX509RequestPOST(url, apiVersion string, payload []byte, contentType string) *X509Request { |
669 | 44 | return &X509Request{ | 41 | return &X509Request{ |
670 | 45 | Method: "POST", | 42 | Method: "POST", |
671 | 46 | URL: url, | 43 | URL: url, |
673 | 47 | APIVersion: baseAPIVersion, | 44 | APIVersion: apiVersion, |
674 | 48 | Payload: payload, | 45 | Payload: payload, |
675 | 49 | ContentType: contentType, | 46 | ContentType: contentType, |
676 | 50 | } | 47 | } |
677 | 51 | } | 48 | } |
678 | 52 | 49 | ||
679 | 53 | // newX509RequestDELETE initializes an X509Request for a DELETE. | 50 | // newX509RequestDELETE initializes an X509Request for a DELETE. |
681 | 54 | func newX509RequestDELETE(url string) *X509Request { | 51 | func newX509RequestDELETE(url, apiVersion string) *X509Request { |
682 | 55 | return &X509Request{ | 52 | return &X509Request{ |
683 | 56 | Method: "DELETE", | 53 | Method: "DELETE", |
684 | 57 | URL: url, | 54 | URL: url, |
686 | 58 | APIVersion: baseAPIVersion, | 55 | APIVersion: apiVersion, |
687 | 59 | } | 56 | } |
688 | 60 | } | 57 | } |
689 | 61 | 58 | ||
690 | 62 | // newX509RequestPUT initializes an X509Request for a PUT. You may still | 59 | // newX509RequestPUT initializes an X509Request for a PUT. You may still |
691 | 63 | // need to set further values. | 60 | // need to set further values. |
693 | 64 | func newX509RequestPUT(url string, payload []byte, contentType string) *X509Request { | 61 | func newX509RequestPUT(url, apiVersion string, payload []byte, contentType string) *X509Request { |
694 | 65 | return &X509Request{ | 62 | return &X509Request{ |
695 | 66 | Method: "PUT", | 63 | Method: "PUT", |
696 | 67 | URL: url, | 64 | URL: url, |
698 | 68 | APIVersion: baseAPIVersion, | 65 | APIVersion: apiVersion, |
699 | 69 | Payload: payload, | 66 | Payload: payload, |
700 | 70 | ContentType: contentType, | 67 | ContentType: contentType, |
701 | 71 | } | 68 | } |
702 | 72 | 69 | ||
703 | === modified file 'x509dispatcher_test.go' | |||
704 | --- x509dispatcher_test.go 2013-07-10 15:42:42 +0000 | |||
705 | +++ x509dispatcher_test.go 2013-07-12 05:06:27 +0000 | |||
706 | @@ -78,7 +78,8 @@ | |||
707 | 78 | session, err := newX509Session("subscriptionid", "cert.pem") | 78 | session, err := newX509Session("subscriptionid", "cert.pem") |
708 | 79 | c.Assert(err, IsNil) | 79 | c.Assert(err, IsNil) |
709 | 80 | path := "/foo/bar" | 80 | path := "/foo/bar" |
711 | 81 | request := newX509RequestGET(server.URL + path) | 81 | version := "test-version" |
712 | 82 | request := newX509RequestGET(server.URL + path, version) | ||
713 | 82 | 83 | ||
714 | 83 | response, err := performX509CurlRequest(session, request) | 84 | response, err := performX509CurlRequest(session, request) |
715 | 84 | c.Assert(err, IsNil) | 85 | c.Assert(err, IsNil) |
716 | @@ -86,6 +87,7 @@ | |||
717 | 86 | 87 | ||
718 | 87 | httpRequest := <-httpRequests | 88 | httpRequest := <-httpRequests |
719 | 88 | c.Check(httpRequest.Method, Equals, "GET") | 89 | c.Check(httpRequest.Method, Equals, "GET") |
720 | 90 | c.Check(httpRequest.Header[http.CanonicalHeaderKey("X-Ms-Version")], DeepEquals, []string{version}) | ||
721 | 89 | c.Check(httpRequest.URL.String(), Equals, path) | 91 | c.Check(httpRequest.URL.String(), Equals, path) |
722 | 90 | c.Check(httpRequest.BodyContent, HasLen, 0) | 92 | c.Check(httpRequest.BodyContent, HasLen, 0) |
723 | 91 | } | 93 | } |
724 | @@ -101,7 +103,8 @@ | |||
725 | 101 | session, err := newX509Session("subscriptionid", "cert.pem") | 103 | session, err := newX509Session("subscriptionid", "cert.pem") |
726 | 102 | c.Assert(err, IsNil) | 104 | c.Assert(err, IsNil) |
727 | 103 | path := "/foo/bar" | 105 | path := "/foo/bar" |
729 | 104 | request := newX509RequestGET(server.URL + path) | 106 | version := "test-version" |
730 | 107 | request := newX509RequestGET(server.URL + path, version) | ||
731 | 105 | 108 | ||
732 | 106 | _, err = performX509CurlRequest(session, request) | 109 | _, err = performX509CurlRequest(session, request) |
733 | 107 | c.Check(err, ErrorMatches, ".*Number of redirects hit maximum amount.*") | 110 | c.Check(err, ErrorMatches, ".*Number of redirects hit maximum amount.*") |
734 | @@ -114,6 +117,7 @@ | |||
735 | 114 | c.Error("The original request has not been performed.") | 117 | c.Error("The original request has not been performed.") |
736 | 115 | } | 118 | } |
737 | 116 | c.Check(httpRequest.Method, Equals, "GET") | 119 | c.Check(httpRequest.Method, Equals, "GET") |
738 | 120 | c.Check(httpRequest.Header[http.CanonicalHeaderKey("X-Ms-Version")], DeepEquals, []string{version}) | ||
739 | 117 | c.Check(httpRequest.URL.String(), Equals, path) | 121 | c.Check(httpRequest.URL.String(), Equals, path) |
740 | 118 | 122 | ||
741 | 119 | // _CURL_MAX_REDIRECTS redirected requests have been performed. | 123 | // _CURL_MAX_REDIRECTS redirected requests have been performed. |
742 | @@ -139,7 +143,8 @@ | |||
743 | 139 | session, err := newX509Session("subscriptionid", "cert.pem") | 143 | session, err := newX509Session("subscriptionid", "cert.pem") |
744 | 140 | c.Assert(err, IsNil) | 144 | c.Assert(err, IsNil) |
745 | 141 | path := "/foo/bar" | 145 | path := "/foo/bar" |
747 | 142 | request := newX509RequestPOST(server.URL+path, requestBody, requestContentType) | 146 | version := "test-version" |
748 | 147 | request := newX509RequestPOST(server.URL+path, version, requestBody, requestContentType) | ||
749 | 143 | 148 | ||
750 | 144 | response, err := performX509CurlRequest(session, request) | 149 | response, err := performX509CurlRequest(session, request) |
751 | 145 | c.Assert(err, IsNil) | 150 | c.Assert(err, IsNil) |
752 | @@ -162,7 +167,8 @@ | |||
753 | 162 | session, err := newX509Session("subscriptionid", "cert.pem") | 167 | session, err := newX509Session("subscriptionid", "cert.pem") |
754 | 163 | c.Assert(err, IsNil) | 168 | c.Assert(err, IsNil) |
755 | 164 | path := "/foo/bar" | 169 | path := "/foo/bar" |
757 | 165 | request := newX509RequestDELETE(server.URL + path) | 170 | version := "test-version" |
758 | 171 | request := newX509RequestDELETE(server.URL + path, version) | ||
759 | 166 | 172 | ||
760 | 167 | response, err := performX509CurlRequest(session, request) | 173 | response, err := performX509CurlRequest(session, request) |
761 | 168 | c.Assert(err, IsNil) | 174 | c.Assert(err, IsNil) |
762 | @@ -170,6 +176,7 @@ | |||
763 | 170 | 176 | ||
764 | 171 | httpRequest := <-httpRequests | 177 | httpRequest := <-httpRequests |
765 | 172 | c.Check(httpRequest.Method, Equals, "DELETE") | 178 | c.Check(httpRequest.Method, Equals, "DELETE") |
766 | 179 | c.Check(httpRequest.Header[http.CanonicalHeaderKey("X-Ms-Version")], DeepEquals, []string{version}) | ||
767 | 173 | c.Check(httpRequest.URL.String(), Equals, path) | 180 | c.Check(httpRequest.URL.String(), Equals, path) |
768 | 174 | c.Check(httpRequest.BodyContent, HasLen, 0) | 181 | c.Check(httpRequest.BodyContent, HasLen, 0) |
769 | 175 | } | 182 | } |
770 | @@ -184,7 +191,8 @@ | |||
771 | 184 | session, err := newX509Session("subscriptionid", "cert.pem") | 191 | session, err := newX509Session("subscriptionid", "cert.pem") |
772 | 185 | c.Assert(err, IsNil) | 192 | c.Assert(err, IsNil) |
773 | 186 | path := "/foo/bar" | 193 | path := "/foo/bar" |
775 | 187 | request := newX509RequestPUT(server.URL+path, requestBody, "application/octet-stream") | 194 | version := "test-version" |
776 | 195 | request := newX509RequestPUT(server.URL+path, version, requestBody, "application/octet-stream") | ||
777 | 188 | 196 | ||
778 | 189 | response, err := performX509CurlRequest(session, request) | 197 | response, err := performX509CurlRequest(session, request) |
779 | 190 | c.Assert(err, IsNil) | 198 | c.Assert(err, IsNil) |
780 | @@ -193,6 +201,7 @@ | |||
781 | 193 | 201 | ||
782 | 194 | httpRequest := <-httpRequests | 202 | httpRequest := <-httpRequests |
783 | 195 | c.Check(httpRequest.Method, Equals, "PUT") | 203 | c.Check(httpRequest.Method, Equals, "PUT") |
784 | 204 | c.Check(httpRequest.Header[http.CanonicalHeaderKey("X-Ms-Version")], DeepEquals, []string{version}) | ||
785 | 196 | c.Check(httpRequest.URL.String(), Equals, path) | 205 | c.Check(httpRequest.URL.String(), Equals, path) |
786 | 197 | c.Check(httpRequest.BodyContent, DeepEquals, requestBody) | 206 | c.Check(httpRequest.BodyContent, DeepEquals, requestBody) |
787 | 198 | } | 207 | } |
788 | @@ -211,7 +220,7 @@ | |||
789 | 211 | session, err := newX509Session("subscriptionid", "cert.pem") | 220 | session, err := newX509Session("subscriptionid", "cert.pem") |
790 | 212 | c.Assert(err, IsNil) | 221 | c.Assert(err, IsNil) |
791 | 213 | path := "/foo/bar" | 222 | path := "/foo/bar" |
793 | 214 | request := newX509RequestGET(server.URL + path) | 223 | request := newX509RequestGET(server.URL + path, "testversion") |
794 | 215 | 224 | ||
795 | 216 | response, err := performX509CurlRequest(session, request) | 225 | response, err := performX509CurlRequest(session, request) |
796 | 217 | c.Assert(err, IsNil) | 226 | c.Assert(err, IsNil) |
797 | 218 | 227 | ||
798 | === modified file 'x509session.go' | |||
799 | --- x509session.go 2013-07-10 15:42:42 +0000 | |||
800 | +++ x509session.go 2013-07-12 05:06:27 +0000 | |||
801 | @@ -60,8 +60,8 @@ | |||
802 | 60 | // It returns the response body and/or an error. If the error is a | 60 | // It returns the response body and/or an error. If the error is a |
803 | 61 | // ServerError, the returned body will be the one received from the server. | 61 | // ServerError, the returned body will be the one received from the server. |
804 | 62 | // For any other kind of error, the returned body will be nil. | 62 | // For any other kind of error, the returned body will be nil. |
807 | 63 | func (session *x509Session) get(path string) (*x509Response, error) { | 63 | func (session *x509Session) get(path, apiVersion string) (*x509Response, error) { |
808 | 64 | request := newX509RequestGET(session.composeURL(path)) | 64 | request := newX509RequestGET(session.composeURL(path), apiVersion) |
809 | 65 | response, err := _X509Dispatcher(session, request) | 65 | response, err := _X509Dispatcher(session, request) |
810 | 66 | if err != nil { | 66 | if err != nil { |
811 | 67 | return nil, err | 67 | return nil, err |
812 | @@ -76,8 +76,8 @@ | |||
813 | 76 | // For any other kind of error, the returned body will be nil. | 76 | // For any other kind of error, the returned body will be nil. |
814 | 77 | // Be aware that Azure may perform POST operations asynchronously. If you are | 77 | // Be aware that Azure may perform POST operations asynchronously. If you are |
815 | 78 | // not sure, call blockUntilCompleted() on the response. | 78 | // not sure, call blockUntilCompleted() on the response. |
818 | 79 | func (session *x509Session) post(path string, body []byte, contentType string) (*x509Response, error) { | 79 | func (session *x509Session) post(path, apiVersion string, body []byte, contentType string) (*x509Response, error) { |
819 | 80 | request := newX509RequestPOST(session.composeURL(path), body, contentType) | 80 | request := newX509RequestPOST(session.composeURL(path), apiVersion, body, contentType) |
820 | 81 | response, err := _X509Dispatcher(session, request) | 81 | response, err := _X509Dispatcher(session, request) |
821 | 82 | if err != nil { | 82 | if err != nil { |
822 | 83 | return nil, err | 83 | return nil, err |
823 | @@ -89,8 +89,8 @@ | |||
824 | 89 | // delete performs a DELETE request to the Azure management API. | 89 | // delete performs a DELETE request to the Azure management API. |
825 | 90 | // Be aware that Azure may perform DELETE operations asynchronously. If you | 90 | // Be aware that Azure may perform DELETE operations asynchronously. If you |
826 | 91 | // are not sure, call blockUntilCompleted() on the response. | 91 | // are not sure, call blockUntilCompleted() on the response. |
829 | 92 | func (session *x509Session) delete(path string) (*x509Response, error) { | 92 | func (session *x509Session) delete(path, apiVersion string) (*x509Response, error) { |
830 | 93 | request := newX509RequestDELETE(session.composeURL(path)) | 93 | request := newX509RequestDELETE(session.composeURL(path), apiVersion) |
831 | 94 | response, err := _X509Dispatcher(session, request) | 94 | response, err := _X509Dispatcher(session, request) |
832 | 95 | if err != nil { | 95 | if err != nil { |
833 | 96 | return response, err | 96 | return response, err |
834 | @@ -102,8 +102,8 @@ | |||
835 | 102 | // put performs a PUT request to the Azure management API. | 102 | // put performs a PUT request to the Azure management API. |
836 | 103 | // Be aware that Azure may perform PUT operations asynchronously. If you are | 103 | // Be aware that Azure may perform PUT operations asynchronously. If you are |
837 | 104 | // not sure, call blockUntilCompleted() on the response. | 104 | // not sure, call blockUntilCompleted() on the response. |
840 | 105 | func (session *x509Session) put(path string, body []byte, contentType string) (*x509Response, error) { | 105 | func (session *x509Session) put(path, apiVersion string, body []byte, contentType string) (*x509Response, error) { |
841 | 106 | request := newX509RequestPUT(session.composeURL(path), body, contentType) | 106 | request := newX509RequestPUT(session.composeURL(path), apiVersion, body, contentType) |
842 | 107 | response, err := _X509Dispatcher(session, request) | 107 | response, err := _X509Dispatcher(session, request) |
843 | 108 | if err != nil { | 108 | if err != nil { |
844 | 109 | return nil, err | 109 | return nil, err |
845 | 110 | 110 | ||
846 | === modified file 'x509session_test.go' | |||
847 | --- x509session_test.go 2013-07-10 15:42:42 +0000 | |||
848 | +++ x509session_test.go 2013-07-12 05:06:27 +0000 | |||
849 | @@ -192,13 +192,15 @@ | |||
850 | 192 | recordedRequests := make([]*X509Request, 0) | 192 | recordedRequests := make([]*X509Request, 0) |
851 | 193 | rigRecordingDispatcher(&recordedRequests) | 193 | rigRecordingDispatcher(&recordedRequests) |
852 | 194 | 194 | ||
854 | 195 | receivedResponse, err := session.get(uri) | 195 | version := "test-version" |
855 | 196 | receivedResponse, err := session.get(uri,version) | ||
856 | 196 | c.Assert(err, IsNil) | 197 | c.Assert(err, IsNil) |
857 | 197 | 198 | ||
858 | 198 | c.Assert(len(recordedRequests), Equals, 1) | 199 | c.Assert(len(recordedRequests), Equals, 1) |
859 | 199 | request := recordedRequests[0] | 200 | request := recordedRequests[0] |
860 | 200 | c.Check(request.URL, Equals, AZURE_URL+subscriptionID+"/"+uri) | 201 | c.Check(request.URL, Equals, AZURE_URL+subscriptionID+"/"+uri) |
861 | 201 | c.Check(request.Method, Equals, "GET") | 202 | c.Check(request.Method, Equals, "GET") |
862 | 203 | c.Check(request.APIVersion, Equals, version) | ||
863 | 202 | c.Check(*receivedResponse, DeepEquals, fixedResponse) | 204 | c.Check(*receivedResponse, DeepEquals, fixedResponse) |
864 | 203 | } | 205 | } |
865 | 204 | 206 | ||
866 | @@ -207,7 +209,7 @@ | |||
867 | 207 | msg := "could not dispatch request" | 209 | msg := "could not dispatch request" |
868 | 208 | rigFailingDispatcher(fmt.Errorf(msg)) | 210 | rigFailingDispatcher(fmt.Errorf(msg)) |
869 | 209 | 211 | ||
871 | 210 | body, err := session.get("flop") | 212 | body, err := session.get("flop", "version") |
872 | 211 | c.Assert(err, NotNil) | 213 | c.Assert(err, NotNil) |
873 | 212 | 214 | ||
874 | 213 | c.Check(body, IsNil) | 215 | c.Check(body, IsNil) |
875 | @@ -222,7 +224,7 @@ | |||
876 | 222 | } | 224 | } |
877 | 223 | rigFixedResponseDispatcher(&fixedResponse) | 225 | rigFixedResponseDispatcher(&fixedResponse) |
878 | 224 | 226 | ||
880 | 225 | response, err := session.get("fail") | 227 | response, err := session.get("fail", "version") |
881 | 226 | c.Assert(err, NotNil) | 228 | c.Assert(err, NotNil) |
882 | 227 | 229 | ||
883 | 228 | serverError := err.(*ServerError) | 230 | serverError := err.(*ServerError) |
884 | @@ -233,6 +235,7 @@ | |||
885 | 233 | func (suite *x509SessionSuite) TestPostIssuesRequest(c *C) { | 235 | func (suite *x509SessionSuite) TestPostIssuesRequest(c *C) { |
886 | 234 | subscriptionID := "subscriptionID" | 236 | subscriptionID := "subscriptionID" |
887 | 235 | uri := "resource" | 237 | uri := "resource" |
888 | 238 | version := "test-version" | ||
889 | 236 | requestBody := []byte("Request body") | 239 | requestBody := []byte("Request body") |
890 | 237 | requestContentType := "bogusContentType" | 240 | requestContentType := "bogusContentType" |
891 | 238 | session, err := newX509Session(subscriptionID, "cert.pem") | 241 | session, err := newX509Session(subscriptionID, "cert.pem") |
892 | @@ -246,13 +249,14 @@ | |||
893 | 246 | recordedRequests := make([]*X509Request, 0) | 249 | recordedRequests := make([]*X509Request, 0) |
894 | 247 | rigRecordingDispatcher(&recordedRequests) | 250 | rigRecordingDispatcher(&recordedRequests) |
895 | 248 | 251 | ||
897 | 249 | receivedResponse, err := session.post(uri, requestBody, requestContentType) | 252 | receivedResponse, err := session.post(uri, version, requestBody, requestContentType) |
898 | 250 | c.Assert(err, IsNil) | 253 | c.Assert(err, IsNil) |
899 | 251 | 254 | ||
900 | 252 | c.Assert(len(recordedRequests), Equals, 1) | 255 | c.Assert(len(recordedRequests), Equals, 1) |
901 | 253 | request := recordedRequests[0] | 256 | request := recordedRequests[0] |
902 | 254 | c.Check(request.URL, Equals, AZURE_URL+subscriptionID+"/"+uri) | 257 | c.Check(request.URL, Equals, AZURE_URL+subscriptionID+"/"+uri) |
903 | 255 | c.Check(request.Method, Equals, "POST") | 258 | c.Check(request.Method, Equals, "POST") |
904 | 259 | c.Check(request.APIVersion, Equals, version) | ||
905 | 256 | c.Check(request.ContentType, Equals, requestContentType) | 260 | c.Check(request.ContentType, Equals, requestContentType) |
906 | 257 | c.Check(request.Payload, DeepEquals, requestBody) | 261 | c.Check(request.Payload, DeepEquals, requestBody) |
907 | 258 | c.Check(*receivedResponse, DeepEquals, fixedResponse) | 262 | c.Check(*receivedResponse, DeepEquals, fixedResponse) |
908 | @@ -263,7 +267,7 @@ | |||
909 | 263 | msg := "could not dispatch request" | 267 | msg := "could not dispatch request" |
910 | 264 | rigFailingDispatcher(fmt.Errorf(msg)) | 268 | rigFailingDispatcher(fmt.Errorf(msg)) |
911 | 265 | 269 | ||
913 | 266 | body, err := session.post("flop", []byte("body"), "contentType") | 270 | body, err := session.post("flop", "version", []byte("body"), "contentType") |
914 | 267 | c.Assert(err, NotNil) | 271 | c.Assert(err, NotNil) |
915 | 268 | 272 | ||
916 | 269 | c.Check(body, IsNil) | 273 | c.Check(body, IsNil) |
917 | @@ -278,7 +282,7 @@ | |||
918 | 278 | } | 282 | } |
919 | 279 | rigFixedResponseDispatcher(&fixedResponse) | 283 | rigFixedResponseDispatcher(&fixedResponse) |
920 | 280 | 284 | ||
922 | 281 | reponse, err := session.post("fail", []byte("request body"), "contentType") | 285 | reponse, err := session.post("fail", "version", []byte("request body"), "contentType") |
923 | 282 | c.Assert(err, NotNil) | 286 | c.Assert(err, NotNil) |
924 | 283 | 287 | ||
925 | 284 | serverError := err.(*ServerError) | 288 | serverError := err.(*ServerError) |
926 | @@ -289,6 +293,7 @@ | |||
927 | 289 | func (suite *x509SessionSuite) TestDeleteIssuesRequest(c *C) { | 293 | func (suite *x509SessionSuite) TestDeleteIssuesRequest(c *C) { |
928 | 290 | subscriptionID := "subscriptionID" | 294 | subscriptionID := "subscriptionID" |
929 | 291 | uri := "resource" | 295 | uri := "resource" |
930 | 296 | version := "test-version" | ||
931 | 292 | session, err := newX509Session(subscriptionID, "cert.pem") | 297 | session, err := newX509Session(subscriptionID, "cert.pem") |
932 | 293 | c.Assert(err, IsNil) | 298 | c.Assert(err, IsNil) |
933 | 294 | // Record incoming requests, and have them return a given reply. | 299 | // Record incoming requests, and have them return a given reply. |
934 | @@ -297,7 +302,7 @@ | |||
935 | 297 | recordedRequests := make([]*X509Request, 0) | 302 | recordedRequests := make([]*X509Request, 0) |
936 | 298 | rigRecordingDispatcher(&recordedRequests) | 303 | rigRecordingDispatcher(&recordedRequests) |
937 | 299 | 304 | ||
939 | 300 | response, err := session.delete(uri) | 305 | response, err := session.delete(uri, version) |
940 | 301 | c.Assert(err, IsNil) | 306 | c.Assert(err, IsNil) |
941 | 302 | 307 | ||
942 | 303 | c.Check(*response, DeepEquals, fixedResponse) | 308 | c.Check(*response, DeepEquals, fixedResponse) |
943 | @@ -305,11 +310,13 @@ | |||
944 | 305 | request := recordedRequests[0] | 310 | request := recordedRequests[0] |
945 | 306 | c.Check(request.URL, Equals, AZURE_URL+subscriptionID+"/"+uri) | 311 | c.Check(request.URL, Equals, AZURE_URL+subscriptionID+"/"+uri) |
946 | 307 | c.Check(request.Method, Equals, "DELETE") | 312 | c.Check(request.Method, Equals, "DELETE") |
947 | 313 | c.Check(request.APIVersion, Equals, version) | ||
948 | 308 | } | 314 | } |
949 | 309 | 315 | ||
950 | 310 | func (suite *x509SessionSuite) TestPutIssuesRequest(c *C) { | 316 | func (suite *x509SessionSuite) TestPutIssuesRequest(c *C) { |
951 | 311 | subscriptionID := "subscriptionID" | 317 | subscriptionID := "subscriptionID" |
952 | 312 | uri := "resource" | 318 | uri := "resource" |
953 | 319 | version := "test-version" | ||
954 | 313 | requestBody := []byte("Request body") | 320 | requestBody := []byte("Request body") |
955 | 314 | session, err := newX509Session(subscriptionID, "cert.pem") | 321 | session, err := newX509Session(subscriptionID, "cert.pem") |
956 | 315 | c.Assert(err, IsNil) | 322 | c.Assert(err, IsNil) |
957 | @@ -321,12 +328,13 @@ | |||
958 | 321 | recordedRequests := make([]*X509Request, 0) | 328 | recordedRequests := make([]*X509Request, 0) |
959 | 322 | rigRecordingDispatcher(&recordedRequests) | 329 | rigRecordingDispatcher(&recordedRequests) |
960 | 323 | 330 | ||
962 | 324 | _, err = session.put(uri, requestBody, "text/plain") | 331 | _, err = session.put(uri, version, requestBody, "text/plain") |
963 | 325 | c.Assert(err, IsNil) | 332 | c.Assert(err, IsNil) |
964 | 326 | 333 | ||
965 | 327 | c.Assert(len(recordedRequests), Equals, 1) | 334 | c.Assert(len(recordedRequests), Equals, 1) |
966 | 328 | request := recordedRequests[0] | 335 | request := recordedRequests[0] |
967 | 329 | c.Check(request.URL, Equals, AZURE_URL+subscriptionID+"/"+uri) | 336 | c.Check(request.URL, Equals, AZURE_URL+subscriptionID+"/"+uri) |
968 | 330 | c.Check(request.Method, Equals, "PUT") | 337 | c.Check(request.Method, Equals, "PUT") |
969 | 338 | c.Check(request.APIVersion, Equals, version) | ||
970 | 331 | c.Check(request.Payload, DeepEquals, requestBody) | 339 | c.Check(request.Payload, DeepEquals, requestBody) |
971 | 332 | } | 340 | } |
Well I tell a lie - disk deletion has worked, so this fixes that too.
However the example program is still not cleaning up the storage, that needs looking at still.