update go.mod and imports

This commit is contained in:
2023-03-17 12:54:34 +03:00
parent f3a1a4c83f
commit 437841c8dd
268 changed files with 4019 additions and 2045 deletions

View File

@@ -2,38 +2,30 @@ package image
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for create virtual image
type CreateVirtualRequest struct {
// Name of the virtual image to create
// Required: true
Name string `url:"name" json:"name"`
Name string `url:"name" json:"name" validate:"required"`
// ID of real image to link this virtual image to upon creation
// Required: true
TargetID uint64 `url:"targetId" json:"targetId"`
}
func (irq CreateVirtualRequest) validate() error {
if irq.Name == "" {
return errors.New("validation-error: field Name can not be empty")
}
if irq.TargetID == 0 {
return errors.New("validation-error: field TargetID can not be empty or equal to 0")
}
return nil
TargetID uint64 `url:"targetId" json:"targetId" validate:"required"`
}
// CreateVirtual creates virtual image
func (i Image) CreateVirtual(ctx context.Context, req CreateVirtualRequest) (uint64, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return 0, err
for _, validationError := range validators.GetErrors(err) {
return 0, validators.ValidationError(validationError)
}
}
url := "/cloudapi/image/createVirtual"