This commit is contained in:
2024-04-16 14:26:06 +03:00
parent bc264c4d90
commit e7c968797b
298 changed files with 11066 additions and 398 deletions

View File

@@ -18,10 +18,6 @@ type CreateRequest struct {
// Required: true
URL string `url:"url" json:"url" validate:"required,url"`
// Grid (platform) ID where this template should be create in
// Required: true
GID uint64 `url:"gid" json:"gid" validate:"required"`
// Boot type of image bios or UEFI
// Required: true
BootType string `url:"boottype" json:"boottype" validate:"required,imageBootType"`
@@ -34,6 +30,17 @@ type CreateRequest struct {
// Required: true
ImageType string `url:"imagetype" json:"imagetype" validate:"required,imageType"`
// Account ID to make the image exclusive
// Required: true
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
// Select a network interface naming pattern for your Linux machine. eth - onboard, ens - pci slot naming
// Should be:
// - eth
// - ens (default value)
// Required: false
NetworkInterfaceNaming string `url:"networkInterfaceNaming,omitempty" json:"networkInterfaceNaming,omitempty" validate:"omitempty,networkInterfaceNaming"`
// Does this machine supports hot resize
// Required: false
HotResize bool `url:"hotresize,omitempty" json:"hotresize,omitempty"`
@@ -46,10 +53,6 @@ type CreateRequest struct {
// Required: false
Password string `url:"password,omitempty" json:"password,omitempty"`
// Account ID to make the image exclusive
// Required: false
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
// Username for upload binary media
// Required: false
UsernameDL string `url:"usernameDL,omitempty" json:"usernameDL,omitempty"`

View File

@@ -4,6 +4,8 @@ import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ListRequest struct to get list of available images
@@ -56,6 +58,10 @@ type ListRequest struct {
// Required: false
Bootable bool `url:"bootable,omitempty" json:"bootable,omitempty"`
// Sort by one of supported fields, format +|-(field)
// Required: false
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
// Page number
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
@@ -67,6 +73,7 @@ type ListRequest struct {
// List gets list of available images as a ListImages struct, optionally filtering by account ID
func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
res, err := i.ListRaw(ctx, req)
if err != nil {
return nil, err
@@ -84,6 +91,11 @@ func (i Image) List(ctx context.Context, req ListRequest) (*ListImages, error) {
// ListRaw gets list of available images as an array of bytes
func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
if err := validators.ValidateRequest(req); err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudapi/image/list"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)

View File

@@ -35,6 +35,9 @@ type ItemImage struct {
// Name
Name string `json:"name"`
// NetworkInterfaceNaming
NetworkInterfaceNaming string `json:"networkInterfaceNaming"`
// Pool
Pool string `json:"pool"`
@@ -104,6 +107,9 @@ type RecordImage struct {
// Bootable
Bootable bool `json:"bootable"`
// CdPresentedTo
CdPresentedTo interface{} `json:"cdPresentedTo"`
// ComputeCI ID
ComputeCIID uint64 `json:"computeciId"`
@@ -146,6 +152,9 @@ type RecordImage struct {
// Name
Name string `json:"name"`
// NetworkInterfaceNaming
NetworkInterfaceNaming string `json:"networkInterfaceNaming"`
// Password
Password string `json:"password"`