This commit is contained in:
2024-05-31 13:35:39 +03:00
parent e7c968797b
commit 3393934456
65 changed files with 905 additions and 393 deletions

View File

@@ -48,15 +48,15 @@ type ListRequest struct {
// Find by public True or False
// Required: false
Public bool `url:"public,omitempty" json:"public,omitempty"`
Public interface{} `url:"public,omitempty" json:"public,omitempty" validate:"omitempty,isBool"`
// Find by hot resize True or False
// Required: false
HotResize bool `url:"hotResize,omitempty" json:"hotResize,omitempty"`
HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"`
// Find by bootable True or False
// Required: false
Bootable bool `url:"bootable,omitempty" json:"bootable,omitempty"`
Bootable interface{} `url:"bootable,omitempty" json:"bootable,omitempty" validate:"omitempty,isBool"`
// Sort by one of supported fields, format +|-(field)
// Required: false

View File

@@ -0,0 +1,39 @@
package image
import (
"context"
"encoding/json"
"fmt"
"net/http"
"os"
)
// UploadImageFileResponse struct to enable image
type UploadImageFileResponse struct {
// ImageFileUri
ImageFileUri string `json:"image_file_uri"`
}
// UploadImageFile uploads file image to platform
func (i Image) UploadImageFile(ctx context.Context, filePath string) (string, error) {
file, err := os.ReadFile(filePath)
if err != nil {
return "", fmt.Errorf("can not read file %v", err)
}
url := "/cloudbroker/image/uploadImageFile"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, file)
if err != nil {
return "", err
}
result := UploadImageFileResponse{}
err = json.Unmarshal(res, &result)
if err != nil {
return "", err
}
return result.ImageFileUri, nil
}