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

@@ -3,35 +3,30 @@ package image
import (
"context"
"encoding/json"
"errors"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for get detailed information about image
type GetRequest struct {
// ID of image to get
// Required: true
ImageID uint64 `url:"imageId" json:"imageId"`
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
// If set to False returns only images in status CREATED
// Required: false
ShowAll bool `url:"show_all,omitempty" json:"show_all,omitempty"`
}
func (irq GetRequest) validate() error {
if irq.ImageID == 0 {
return errors.New("validation-error: field ImageID can not be empty or equal to 0")
}
return nil
}
// Get gets image by ID.
// Returns image if user has rights on it
func (i Image) Get(ctx context.Context, req GetRequest) (*RecordImage, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return nil, err
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudapi/image/get"