From adfa317235cb837a29b2049f4f0e2f4876eae552 Mon Sep 17 00:00:00 2001 From: wb-ywq399345 Date: Thu, 14 Mar 2019 09:37:36 +0800 Subject: [PATCH 1/2] Add forced delete parameter --- ecs/instances.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ecs/instances.go b/ecs/instances.go index dd424f96..373812ba 100644 --- a/ecs/instances.go +++ b/ecs/instances.go @@ -464,6 +464,7 @@ func (client *Client) ModifyInstanceAutoReleaseTime(instanceId, time string) err type DeleteInstanceArgs struct { InstanceId string + Force bool } type DeleteInstanceResponse struct { @@ -473,8 +474,8 @@ type DeleteInstanceResponse struct { // DeleteInstance deletes instance // // You can read doc at http://docs.aliyun.com/#/pub/ecs/open-api/instance&deleteinstance -func (client *Client) DeleteInstance(instanceId string) error { - args := DeleteInstanceArgs{InstanceId: instanceId} +func (client *Client) DeleteInstance(instanceId string, forceDelete bool) error { + args := DeleteInstanceArgs{InstanceId: instanceId, Force: forceDelete} response := DeleteInstanceResponse{} err := client.Invoke("DeleteInstance", &args, &response) return err From 6813a0a82ad2b0e07f6c619a17901793e4e63adc Mon Sep 17 00:00:00 2001 From: wb-ywq399345 Date: Thu, 14 Mar 2019 10:14:18 +0800 Subject: [PATCH 2/2] fix in 'add Force parameter' after that Test problem --- ecs/instances_test.go | 6 +++--- ecs/vpcs_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ecs/instances_test.go b/ecs/instances_test.go index b67699c6..6f7bbd46 100644 --- a/ecs/instances_test.go +++ b/ecs/instances_test.go @@ -87,7 +87,7 @@ func ExampleClient_DeleteInstance() { client := NewTestClient() - err := client.DeleteInstance(TestInstanceId) + err := client.DeleteInstance(TestInstanceId, false) if err != nil { fmt.Printf("Failed to delete Instance %s vnc url: %v \n", TestInstanceId, err) @@ -177,7 +177,7 @@ func TestECSInstanceCreationAndDeletion(t *testing.T) { } t.Logf("Instance %s is stopped successfully.", instanceId) - err = client.DeleteInstance(instanceId) + err = client.DeleteInstance(instanceId, false) if err != nil { t.Errorf("Failed to delete instance %s: %v", instanceId, err) @@ -280,7 +280,7 @@ func TestLocationECSClient(t *testing.T) { t.Logf("InstanceAttribute is %++v", attr) //DeleteInstance - err = client.DeleteInstance(instanceId) + err = client.DeleteInstance(instanceId, false) if err != nil { t.Fatalf("Failed to delete instance %++v", err) } diff --git a/ecs/vpcs_test.go b/ecs/vpcs_test.go index 8baadcf0..7b1653ee 100644 --- a/ecs/vpcs_test.go +++ b/ecs/vpcs_test.go @@ -95,7 +95,7 @@ func TestVPCCreationAndDeletion(t *testing.T) { } t.Logf("Instance %s is stopped successfully.", instanceId) } - err = client.DeleteInstance(instanceId) + err = client.DeleteInstance(instanceId, false) if err != nil { t.Errorf("Failed to delete instance %s: %v", instanceId, err)