Merge lp:~rvb/gwacl/delete-hosted-service into lp:gwacl

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: 35
Merged at revision: 38
Proposed branch: lp:~rvb/gwacl/delete-hosted-service
Merge into: lp:gwacl
Diff against target: 73 lines (+19/-5)
4 files modified
example/live_example_managementapi.go (+1/-1)
managementapi.go (+6/-3)
managementapi_test.go (+11/-0)
xmlobjects.go (+1/-1)
To merge this branch: bzr merge lp:~rvb/gwacl/delete-hosted-service
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+154557@code.launchpad.net

Commit message

Add method to delete a hosted service.

Description of the change

Drive-by fixes:
- use the predefined const for the value of the xmlns
- remove left-over Println() statement

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Forgot to approve this earlier.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'example/live_example_managementapi.go'
2--- example/live_example_managementapi.go 2013-03-20 23:22:47 +0000
3+++ example/live_example_managementapi.go 2013-03-21 00:12:24 +0000
4@@ -66,7 +66,7 @@
5 fmt.Println("Done listing hosted services\n")
6
7 fmt.Println("Deleting hosted service...")
8- // TODO: Delete hosted service.
9+ api.DeleteHostedService(hostServiceName)
10 fmt.Println("Done deleting hosted service\n")
11
12 }
13
14=== modified file 'managementapi.go'
15--- managementapi.go 2013-03-20 13:09:05 +0000
16+++ managementapi.go 2013-03-21 00:12:24 +0000
17@@ -5,7 +5,6 @@
18
19 import (
20 "encoding/xml"
21- "fmt"
22 )
23
24 type ManagementAPI struct {
25@@ -57,10 +56,14 @@
26 }
27 // TODO: Use the response and (maybe), extract the value of the header named
28 // 'x-ms-request-id'.
29- res, err := api.session.post(URI, []byte(body), "application/xml")
30- fmt.Println(string(res))
31+ _, err = api.session.post(URI, []byte(body), "application/xml")
32 if err != nil {
33 return err
34 }
35 return nil
36 }
37+
38+func (api *ManagementAPI) DeleteHostedService(serviceName string) error {
39+ URI := "services/hostedservices/" + serviceName
40+ return api.session.delete(URI)
41+}
42
43=== modified file 'managementapi_test.go'
44--- managementapi_test.go 2013-03-20 23:34:34 +0000
45+++ managementapi_test.go 2013-03-21 00:12:24 +0000
46@@ -97,3 +97,14 @@
47 c.Assert(err, IsNil)
48 CheckRequest(c, recordedRequests, expectedURL, expectedPayload, "POST")
49 }
50+
51+func (suite *ManagementAPISuite) TestDeleteHostedService(c *C) {
52+ api := suite.makeAPI(c)
53+ recordedRequests := suite.setUpDispatcher()
54+ hostedServiceName := "testName"
55+ err := api.DeleteHostedService(hostedServiceName)
56+
57+ c.Assert(err, IsNil)
58+ expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices/" + hostedServiceName
59+ CheckRequest(c, recordedRequests, expectedURL, []byte{}, "DELETE")
60+}
61
62=== modified file 'xmlobjects.go'
63--- xmlobjects.go 2013-03-20 23:22:47 +0000
64+++ xmlobjects.go 2013-03-21 00:12:24 +0000
65@@ -188,7 +188,7 @@
66 func NewCreateHostedServiceWithLocation(serviceName, label, location string) *CreateHostedService {
67 base64label := base64.StdEncoding.EncodeToString([]byte(label))
68 return &CreateHostedService{
69- XMLNS: "http://schemas.microsoft.com/windowsazure",
70+ XMLNS: XMLNS,
71 ServiceName: serviceName,
72 Label: base64label,
73 Location: location,

Subscribers

People subscribed via source and target branches

to all changes: