55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package vgpu
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
|
)
|
|
|
|
// CreateRequest struct for creating VGPU
|
|
type CreateRequest struct {
|
|
// ID of pGPU
|
|
// Required: true
|
|
PGPUID uint64 `url:"pgpu_id" json:"pgpu_id" validate:"required"`
|
|
|
|
// Virtual profile id
|
|
// Required: false
|
|
ProfileID string `url:"profile_id,omitempty" json:"profile_id,omitempty"`
|
|
|
|
// MDEV Type
|
|
// Required: false
|
|
MDEVType string `url:"mdev_type,omitempty" json:"mdev_type,omitempty"`
|
|
|
|
// PCI Address
|
|
// Required: false
|
|
PCIAddress string `url:"pci_address,omitempty" json:"pci_address,omitempty"`
|
|
|
|
// Account IDs
|
|
// Required: false
|
|
AccountIDs []uint64 `url:"account_ids,omitempty" json:"account_ids,omitempty"`
|
|
}
|
|
|
|
// Create creates VGPU
|
|
func (v VGPU) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|
err := validators.ValidateRequest(req)
|
|
if err != nil {
|
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
|
}
|
|
|
|
url := "/cloudbroker/vgpu/create"
|
|
|
|
res, err := v.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|