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 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)