From 45576d273b1d01ad3949debd4a1830a5e988cbad Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Thu, 27 Sep 2018 15:32:21 +0800 Subject: [PATCH 1/2] Add DeleteWithBody for MLS MLS service request delete with empty body. --- openstack/mls/v1/instances/requests.go | 3 ++- service_client.go | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/openstack/mls/v1/instances/requests.go b/openstack/mls/v1/instances/requests.go index 6cca149b7..0957efbac 100644 --- a/openstack/mls/v1/instances/requests.go +++ b/openstack/mls/v1/instances/requests.go @@ -63,7 +63,8 @@ func Create(client *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateRe //delete an instance via id func Delete(client *golangsdk.ServiceClient, id string) (r DeleteResult) { - _, r.Err = client.Delete(resourceURL(client, id), &golangsdk.RequestOpts{ + b := make(map[string]interface{}) + _, r.Err = client.DeleteWithBody(resourceURL(client, id), b, &golangsdk.RequestOpts{ OkCodes: []int{202}, }) return diff --git a/service_client.go b/service_client.go index df6eaa23f..db12a9d67 100644 --- a/service_client.go +++ b/service_client.go @@ -108,6 +108,15 @@ func (client *ServiceClient) Delete(url string, opts *RequestOpts) (*http.Respon return client.Request("DELETE", url, opts) } +// DeleteWithBody calls `Request` with the "DELETE" HTTP verb. +func (client *ServiceClient) DeleteWithBody(url string, JSONBody interface{}, opts *RequestOpts) (*http.Response, error) { + if opts == nil { + opts = new(RequestOpts) + } + client.initReqOpts(url, JSONBody, nil, opts) + return client.Request("DELETE", url, opts) +} + func (client *ServiceClient) setMicroversionHeader(opts *RequestOpts) { switch client.Type { case "compute": From 1e187954d25a13110ec331dc5513e90fd1a4a397 Mon Sep 17 00:00:00 2001 From: Zhenguo Niu Date: Thu, 27 Sep 2018 15:32:21 +0800 Subject: [PATCH 2/2] Add DeleteWithBody for MLS MLS service request delete with empty body. --- openstack/mls/v1/instances/requests.go | 5 ++++- service_client.go | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/openstack/mls/v1/instances/requests.go b/openstack/mls/v1/instances/requests.go index 7335ada22..c669ad1a3 100644 --- a/openstack/mls/v1/instances/requests.go +++ b/openstack/mls/v1/instances/requests.go @@ -68,7 +68,10 @@ func Create(client *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateRe //delete an instance via id func Delete(client *golangsdk.ServiceClient, id string) (r DeleteResult) { - _, r.Err = client.Delete(resourceURL(client, id), &RequestOpts) + b := make(map[string]interface{}) + _, r.Err = client.DeleteWithBody(resourceURL(client, id), b, &golangsdk.RequestOpts{ + OkCodes: []int{202}, + }) return } diff --git a/service_client.go b/service_client.go index df6eaa23f..db12a9d67 100644 --- a/service_client.go +++ b/service_client.go @@ -108,6 +108,15 @@ func (client *ServiceClient) Delete(url string, opts *RequestOpts) (*http.Respon return client.Request("DELETE", url, opts) } +// DeleteWithBody calls `Request` with the "DELETE" HTTP verb. +func (client *ServiceClient) DeleteWithBody(url string, JSONBody interface{}, opts *RequestOpts) (*http.Response, error) { + if opts == nil { + opts = new(RequestOpts) + } + client.initReqOpts(url, JSONBody, nil, opts) + return client.Request("DELETE", url, opts) +} + func (client *ServiceClient) setMicroversionHeader(opts *RequestOpts) { switch client.Type { case "compute":