Skip to content

Commit

Permalink
delete for rest updated (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkatarmal-crest authored Dec 22, 2020
1 parent b6b559d commit 27393da
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions aci/resource_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}))
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 27393da

Please sign in to comment.