v9.0.0
This commit is contained in:
50
pkg/cloudbroker/vgpu/create.go
Normal file
50
pkg/cloudbroker/vgpu/create.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package vgpu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v9/internal/validators"
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user