Files
decort-golang-sdk/pkg/sdn/hypervisors/delete.go
dayterr 416a6c4263 v1.15.5
v1.15.5
2026-07-10 15:37:02 +03:00

38 lines
886 B
Go

package hypervisors
import (
"context"
"encoding/json"
"net/http"
"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) (*RecordVersion, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/hypervisor/delete"
res, err := hv.client.DecortApiCallCtype(ctx, http.MethodDelete, url, constants.MIMEJSON, req)
info := RecordVersion{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}