Skip to content

Commit

Permalink
+Cancel Instance (Ref: #25) (#26)
Browse files Browse the repository at this point in the history
* +CencelInstance (Ref: #25)

* Tested Cancel Service

---------

Co-authored-by: Skiepp <[email protected]>
  • Loading branch information
Skiepp and Skiepp authored Oct 17, 2023
1 parent dc865bc commit 40a7063
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions contabo/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,23 @@ func reinstall(d *schema.ResourceData, client *openapi.APIClient, ctx context.Co

func resourceInstanceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
var diags diag.Diagnostics

client := m.(*openapi.APIClient)
instanceId, err := strconv.ParseInt(d.Id(), 10, 64)
if err != nil {
return diag.FromErr(err)
}

_, httpResp, err := client.InstancesApi.
CancelInstance(ctx, instanceId).
XRequestId(uuid.NewV4().String()).
Execute()

if err != nil {
return HandleResponseErrors(diags, httpResp)
}

d.SetId("")
return diags
}

Expand Down

0 comments on commit 40a7063

Please sign in to comment.