You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
decort-golang-sdk/pkg/cloudbroker/vgpu/create.go

50 lines
1.1 KiB

package vgpu
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
"strconv"
)
// CreateRequest struct for creating VGPU
type CreateRequest struct {
// ID of pGPU
// Required: true
PGPUID uint64 `url:"pgpuId" json:"pgpuId" validate:"required"`
// ID of the target resource group.
// Required: true
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
// Virtual profile id
// Required: false
ProfileID uint64 `url:"profileId,omitempty" json:"profileId,omitempty"`
// Allocate vgpu after creation
// Required: false
Allocate bool `url:"allocate,omitempty" json:"allocate,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
}