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
=== modified file 'example/live_example_managementapi.go'
--- example/live_example_managementapi.go 2013-03-20 23:22:47 +0000
+++ example/live_example_managementapi.go 2013-03-21 00:12:24 +0000
@@ -66,7 +66,7 @@
66 fmt.Println("Done listing hosted services\n")66 fmt.Println("Done listing hosted services\n")
6767
68 fmt.Println("Deleting hosted service...")68 fmt.Println("Deleting hosted service...")
69 // TODO: Delete hosted service.69 api.DeleteHostedService(hostServiceName)
70 fmt.Println("Done deleting hosted service\n")70 fmt.Println("Done deleting hosted service\n")
7171
72}72}
7373
=== modified file 'managementapi.go'
--- managementapi.go 2013-03-20 13:09:05 +0000
+++ managementapi.go 2013-03-21 00:12:24 +0000
@@ -5,7 +5,6 @@
55
6import (6import (
7 "encoding/xml"7 "encoding/xml"
8 "fmt"
9)8)
109
11type ManagementAPI struct {10type ManagementAPI struct {
@@ -57,10 +56,14 @@
57 }56 }
58 // TODO: Use the response and (maybe), extract the value of the header named57 // TODO: Use the response and (maybe), extract the value of the header named
59 // 'x-ms-request-id'.58 // 'x-ms-request-id'.
60 res, err := api.session.post(URI, []byte(body), "application/xml")59 _, err = api.session.post(URI, []byte(body), "application/xml")
61 fmt.Println(string(res))
62 if err != nil {60 if err != nil {
63 return err61 return err
64 }62 }
65 return nil63 return nil
66}64}
65
66func (api *ManagementAPI) DeleteHostedService(serviceName string) error {
67 URI := "services/hostedservices/" + serviceName
68 return api.session.delete(URI)
69}
6770
=== modified file 'managementapi_test.go'
--- managementapi_test.go 2013-03-20 23:34:34 +0000
+++ managementapi_test.go 2013-03-21 00:12:24 +0000
@@ -97,3 +97,14 @@
97 c.Assert(err, IsNil)97 c.Assert(err, IsNil)
98 CheckRequest(c, recordedRequests, expectedURL, expectedPayload, "POST")98 CheckRequest(c, recordedRequests, expectedURL, expectedPayload, "POST")
99}99}
100
101func (suite *ManagementAPISuite) TestDeleteHostedService(c *C) {
102 api := suite.makeAPI(c)
103 recordedRequests := suite.setUpDispatcher()
104 hostedServiceName := "testName"
105 err := api.DeleteHostedService(hostedServiceName)
106
107 c.Assert(err, IsNil)
108 expectedURL := AZURE_URL + api.session.subscriptionId + "/services/hostedservices/" + hostedServiceName
109 CheckRequest(c, recordedRequests, expectedURL, []byte{}, "DELETE")
110}
100111
=== modified file 'xmlobjects.go'
--- xmlobjects.go 2013-03-20 23:22:47 +0000
+++ xmlobjects.go 2013-03-21 00:12:24 +0000
@@ -188,7 +188,7 @@
188func NewCreateHostedServiceWithLocation(serviceName, label, location string) *CreateHostedService {188func NewCreateHostedServiceWithLocation(serviceName, label, location string) *CreateHostedService {
189 base64label := base64.StdEncoding.EncodeToString([]byte(label))189 base64label := base64.StdEncoding.EncodeToString([]byte(label))
190 return &CreateHostedService{190 return &CreateHostedService{
191 XMLNS: "http://schemas.microsoft.com/windowsazure",191 XMLNS: XMLNS,
192 ServiceName: serviceName,192 ServiceName: serviceName,
193 Label: base64label,193 Label: base64label,
194 Location: location,194 Location: location,

Subscribers

People subscribed via source and target branches

to all changes: