File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,9 +3,10 @@ package request
33import (
44 "encoding/xml"
55 "fmt"
6- "github.com/UpCloudLtd/upcloud-go-api/upcloud"
76 "strings"
87 "time"
8+
9+ "github.com/UpCloudLtd/upcloud-go-api/upcloud"
910)
1011
1112// Constants
@@ -192,6 +193,16 @@ func (r *DeleteServerRequest) RequestURL() string {
192193 return fmt .Sprintf ("/server/%s" , r .UUID )
193194}
194195
196+ // DeleteServerAndStoragesRequest represents a request to delete a server and all attached storages
197+ type DeleteServerAndStoragesRequest struct {
198+ UUID string
199+ }
200+
201+ // RequestURL implements the Request interface
202+ func (r * DeleteServerAndStoragesRequest ) RequestURL () string {
203+ return fmt .Sprintf ("/server/%s/?storages=1" , r .UUID )
204+ }
205+
195206// TagServerRequest represents a request to tag a server with one or more tags
196207type TagServerRequest struct {
197208 UUID string
Original file line number Diff line number Diff line change @@ -2,10 +2,11 @@ package request
22
33import (
44 "encoding/xml"
5- "github.com/UpCloudLtd/upcloud-go-api/upcloud"
6- "github.com/stretchr/testify/assert"
75 "testing"
86 "time"
7+
8+ "github.com/UpCloudLtd/upcloud-go-api/upcloud"
9+ "github.com/stretchr/testify/assert"
910)
1011
1112// TestGetServerDetailsRequest tests that GetServerDetailsRequest objects behave correctly
@@ -127,6 +128,15 @@ func TestDeleteServerRequest(t *testing.T) {
127128 assert .Equal (t , "/server/foo" , request .RequestURL ())
128129}
129130
131+ // TestDeleteServerAndStoragesRequest tests that DeleteServerAndStoragesRequest objects behave correctly
132+ func TestDeleteServerAndStoragesRequest (t * testing.T ) {
133+ request := DeleteServerAndStoragesRequest {
134+ UUID : "foo" ,
135+ }
136+
137+ assert .Equal (t , "/server/foo/?storages=1" , request .RequestURL ())
138+ }
139+
130140// TestTagServerRequest tests that TestTagServer behaves correctly
131141func TestTagServerRequest (t * testing.T ) {
132142 // Test with multiple tags
Original file line number Diff line number Diff line change @@ -270,6 +270,17 @@ func (s *Service) DeleteServer(r *request.DeleteServerRequest) error {
270270 return nil
271271}
272272
273+ // DeleteServerAndStorages deletes the specified server and all attached storages
274+ func (s * Service ) DeleteServerAndStorages (r * request.DeleteServerAndStoragesRequest ) error {
275+ err := s .client .PerformDeleteRequest (s .client .CreateRequestUrl (r .RequestURL ()))
276+
277+ if err != nil {
278+ return parseServiceError (err )
279+ }
280+
281+ return nil
282+ }
283+
273284// TagServer tags a server with with one or more tags
274285func (s * Service ) TagServer (r * request.TagServerRequest ) (* upcloud.ServerDetails , error ) {
275286 serverDetails := upcloud.ServerDetails {}
You can’t perform that action at this time.
0 commit comments