Files
dynamix-golang-sdk/pkg/cloudbroker/node/set_vfs_number.go

52 lines
1.2 KiB
Go
Raw Normal View History

2025-09-23 14:34:24 +03:00
package node
import (
"context"
"net/http"
2025-09-26 19:17:30 +03:00
"strconv"
2025-09-23 14:34:24 +03:00
2025-12-08 16:30:08 +03:00
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v13/internal/validators"
2025-09-23 14:34:24 +03:00
)
// SetVFsNumberRequest struct to set number of VFs for individual NIC on node
type SetVFsNumberRequest struct {
// Node ID
// Required: true
NID uint64 `url:"nid" json:"nid" validate:"required"`
// PCI address or NIC name
// Required: true
2025-09-26 19:17:30 +03:00
NICID string `url:"nicId" json:"nicId" validate:"required"`
2025-09-23 14:34:24 +03:00
// Number of VF to assign
// Required: true
VFNum uint64 `url:"vfNum" json:"vfNum" validate:"required"`
2025-09-26 19:17:30 +03:00
// Number of VF to assign
2025-09-26 18:56:58 +03:00
// Required: true
2025-09-26 19:17:30 +03:00
VFParams []VFParam `url:"vfParams" json:"vfParams" validate:"required"`
2025-09-23 14:34:24 +03:00
}
// SetVFsNumber sets number of VFs for individual NIC on node
2025-09-26 19:17:30 +03:00
func (n Node) SetVFsNumber(ctx context.Context, req SetVFsNumberRequest) (bool, error) {
2025-09-23 14:34:24 +03:00
err := validators.ValidateRequest(req)
if err != nil {
2025-09-26 19:17:30 +03:00
return false, validators.ValidationErrors(validators.GetErrors(err))
2025-09-23 14:34:24 +03:00
}
url := "/cloudbroker/node/setVFsNumber"
res, err := n.client.DecortApiCall(ctx, http.MethodPost, url, req)
2025-09-26 19:17:30 +03:00
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
2025-09-23 14:34:24 +03:00
if err != nil {
2025-09-26 19:17:30 +03:00
return false, err
2025-09-23 14:34:24 +03:00
}
2025-09-26 19:17:30 +03:00
return result, nil
2025-09-23 14:34:24 +03:00
}