From 27393dab822502913879ff503f0c993ed9bd1ec6 Mon Sep 17 00:00:00 2001 From: Nirav Katarmal Date: Tue, 22 Dec 2020 12:37:52 +0530 Subject: [PATCH] delete for rest updated (#182) --- aci/resource_rest.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/aci/resource_rest.go b/aci/resource_rest.go index 6624f2240..9f91ea9ed 100644 --- a/aci/resource_rest.go +++ b/aci/resource_rest.go @@ -119,6 +119,7 @@ func PostAndSetStatus(d *schema.ResourceData, m interface{}, status string) (*co path := d.Get("path").(string) var cont *container.Container var err error + method := "POST" if content, ok := d.GetOk("content"); ok { contentStrMap := toStrMap(content.(map[string]interface{})) @@ -165,10 +166,14 @@ func PostAndSetStatus(d *schema.ResourceData, m interface{}, status string) (*co return nil, fmt.Errorf("Unable to parse the payload to JSON. Please check your payload") } + if status == "deleted" { + method = "DELETE" + } + } else { return nil, fmt.Errorf("Either of payload or content is required") } - req, err := aciClient.MakeRestRequest("POST", path, cont, true) + req, err := aciClient.MakeRestRequest(method, path, cont, true) if err != nil { return nil, err } @@ -177,7 +182,7 @@ func PostAndSetStatus(d *schema.ResourceData, m interface{}, status string) (*co if err != nil { return nil, err } - err = client.CheckForErrors(respCont, "POST", false) + err = client.CheckForErrors(respCont, method, false) if err != nil { return nil, err }