v1.14.7
This commit is contained in:
43
pkg/sdn/hypervisors/delete.go
Normal file
43
pkg/sdn/hypervisors/delete.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package hypervisors
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DeleteRequest to delete a hypervisor
|
||||
type DeleteRequest struct {
|
||||
// Name of a hypervisor
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
// Delete a hypervisor
|
||||
func (hv Hypervisors) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/sdn/hypervisor/delete"
|
||||
|
||||
res, err := hv.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if string(res) == "" {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user