This commit is contained in:
dayterr
2026-04-10 16:38:00 +03:00
parent 30e464e4d2
commit 5cdae8520f
16 changed files with 458 additions and 62 deletions

View 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
}