Skip to content

Commit 27393da

Browse files
delete for rest updated (#182)
1 parent b6b559d commit 27393da

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

aci/resource_rest.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ func PostAndSetStatus(d *schema.ResourceData, m interface{}, status string) (*co
119119
path := d.Get("path").(string)
120120
var cont *container.Container
121121
var err error
122+
method := "POST"
122123

123124
if content, ok := d.GetOk("content"); ok {
124125
contentStrMap := toStrMap(content.(map[string]interface{}))
@@ -165,10 +166,14 @@ func PostAndSetStatus(d *schema.ResourceData, m interface{}, status string) (*co
165166
return nil, fmt.Errorf("Unable to parse the payload to JSON. Please check your payload")
166167
}
167168

169+
if status == "deleted" {
170+
method = "DELETE"
171+
}
172+
168173
} else {
169174
return nil, fmt.Errorf("Either of payload or content is required")
170175
}
171-
req, err := aciClient.MakeRestRequest("POST", path, cont, true)
176+
req, err := aciClient.MakeRestRequest(method, path, cont, true)
172177
if err != nil {
173178
return nil, err
174179
}
@@ -177,7 +182,7 @@ func PostAndSetStatus(d *schema.ResourceData, m interface{}, status string) (*co
177182
if err != nil {
178183
return nil, err
179184
}
180-
err = client.CheckForErrors(respCont, "POST", false)
185+
err = client.CheckForErrors(respCont, method, false)
181186
if err != nil {
182187
return nil, err
183188
}

0 commit comments

Comments
 (0)