Files
decort-golang-sdk/pkg/cloudbroker/vgpu/destroy.go

39 lines
805 B
Go
Raw Normal View History

2023-04-20 11:17:35 +03:00
package vgpu
import (
"context"
"net/http"
"strconv"
2026-08-21 17:52:28 +04:00
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
2023-04-20 11:17:35 +03:00
)
2023-10-25 17:37:18 +03:00
// DestroyRequest struct for destroying VGPU
2023-04-20 11:17:35 +03:00
type DestroyRequest struct {
// Virtual GPU ID
// Required: true
2026-08-21 17:52:28 +04:00
VGPUID uint64 `url:"vgpu_id" json:"vgpu_id" validate:"required"`
2023-04-20 11:17:35 +03:00
}
// Destroy destroys VGPU
func (v VGPU) Destroy(ctx context.Context, req DestroyRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
2023-10-25 17:37:18 +03:00
return false, validators.ValidationErrors(validators.GetErrors(err))
2023-04-20 11:17:35 +03:00
}
url := "/cloudbroker/vgpu/destroy"
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}