This commit is contained in:
2024-11-12 12:51:21 +03:00
parent f1e0f7abb6
commit 80491ed643
226 changed files with 3033 additions and 2633 deletions

View File

@@ -1,38 +0,0 @@
package grid
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// CheckVMsRequest struct to check virtual machine
type CheckVMsRequest struct {
// Grid (platform) ID
// Required: true
GID uint64 `url:"gid" json:"gid" validate:"required"`
}
// CheckVMs run checkvms jumpscript
func (g Grid) CheckVMs(ctx context.Context, req CheckVMsRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/grid/checkVMs"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return false, err
}
result, err := strconv.ParseBool(string(res))
if err != nil {
return false, err
}
return result, nil
}

View File

@@ -1,60 +0,0 @@
package grid
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// CreateSystemSpaceRequest struct to create system space
type CreateSystemSpaceRequest struct {
// Grid (platform) ID
// Required: true
GID uint64 `url:"id" json:"id" validate:"required"`
// Name of the account/cloudspace to be created for the system
// Required: true
Name string `url:"name" json:"name" validate:"required"`
// ID of the specific image
// Required: true
ImageID uint64 `url:"imageId" json:"imageId" validate:"required"`
// Size of base volume
// Required: true
BootSize uint64 `url:"bootsize" json:"bootsize" validate:"required"`
// Data disk size in gigabytes
// Required: true
DataDiskSize uint64 `url:"dataDiskSize" json:"dataDiskSize" validate:"required"`
// ID of the specific size
// Required: false
SizeID uint64 `url:"sizeId,omitempty" json:"sizeId,omitempty"`
// Number of vcpus to provide
// Required: false
VCPUS uint64 `url:"vcpus,omitempty" json:"vcpus,omitempty"`
// Amount of memory to provide
// Required: false
Memory uint64 `url:"memory,omitempty" json:"memory,omitempty"`
}
// CreateSystemSpace creates system space
func (g Grid) CreateSystemSpace(ctx context.Context, req CreateSystemSpaceRequest) (string, error) {
err := validators.ValidateRequest(req)
if err != nil {
return "", validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/grid/createSystemSpace"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return "", err
}
return string(res), nil
}

View File

@@ -12,7 +12,7 @@ import (
type ExecuteMaintenanceScriptRequest struct {
// Grid (platform) ID
// Required: true
GID string `url:"gid" json:"gid" validate:"required"`
GID uint64 `url:"gid" json:"gid" validate:"required"`
// Type of nodes you want to apply the action on
// Required: true

View File

@@ -0,0 +1,46 @@
package grid
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetSettingsRequest struct to get grid settings
type GetSettingsRequest struct {
// Grid (platform) ID
// Required: true
GID uint64 `url:"grid_id" json:"grid_id" validate:"required"`
}
// GetSettings gets settings grid by ID as a RecordSettingsGrid struct
func (g Grid) GetSettings(ctx context.Context, req GetSettingsRequest) (*RecordSettingsGrid, error) {
res, err := g.GetSettingsRaw(ctx, req)
if err != nil {
return nil, err
}
settings := RecordSettingsGrid{}
err = json.Unmarshal(res, &settings)
if err != nil {
return nil, err
}
return &settings, nil
}
// GetSettingsRaw gets settings grid by ID as an array of bytes
func (g Grid) GetSettingsRaw(ctx context.Context, req GetSettingsRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/grid/getSettings"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -67,6 +67,12 @@ type DiskUsage struct {
// Detailed information about grid
type RecordGrid struct {
// CKey
CKey string `json:"_ckey"`
// Meta
Meta []interface{} `json:"_meta"`
// AuthBroker
AuthBroker []interface{} `json:"authBroker"`
@@ -133,3 +139,101 @@ type ListEmails struct {
// Entry count
EntryCount uint64 `json:"entryCount"`
}
// Detailed information about grid settings
type RecordSettingsGrid struct {
//Allowed ports
Allowedports []int `json:"allowedports"`
//Cleanup retention period
CleanupRetentionPeriod uint64 `json:"cleanupRetentionPeriod"`
//Docker registry
DockerRegistry DockerRegistry `json:"docker_registry"`
//Enable uptime monitor
EnableUptimeMonitor bool `json:"enableUptimeMonitor"`
//Extnet max prereservation num
ExtnetMaxPreReservationsNum int `json:"extnetMaxPreReservationsNum"`
//Healthcheck notifications
HealthcheckNotifications HealthcheckNotifications `json:"healthcheck_notifications"`
//k8s cleanup enabled
K8sCleanupEnabled bool `json:"k8s_cleanup_enabled"`
//Limits
Limits interface{} `json:"limits"`
//Location url
LocationURL string `json:"location_url"`
//Net QOS
NetQOS NetQOS `json:"net_qos"`
//Networks
Networks string `json:"networks"`
//Prometheus
Prometheus Prometheus `json:"prometheus"`
//Vins max prereservation num
VinsMaxPreReservationsNum int `json:"vinsMaxPreReservationsNum"`
//Vnfdev mgmt net range
VnfdevMgmtNetRange string `json:"vnfdev_mgmt_net_range"`
}
// DockerRegistry in grid settings
type DockerRegistry struct {
//Password
Password string `json:"password"`
//Server
Server string `json:"server"`
//Username
Username string `json:"username"`
}
// NetQOS in grid settings
type NetQOS struct {
// ExtNet Net QOS settings
ExtNet SettingsNetQOS `json:"ext_net"`
// VINS Net QOS settings
VINS SettingsNetQOS `json:"vins"`
}
// SettingsNetQOS in grid settings
type SettingsNetQOS struct {
//ERate
ERate uint64 `json:"eRate"`
//InBurst
InBurst uint64 `json:"inBurst"`
//InRate
InRate uint64 `json:"inRate"`
}
// HealthcheckNotifications settings in grid
type HealthcheckNotifications struct {
//Emails
Emails []Emails `json:"emails"`
}
type Emails struct {
//Address
Address string `json:"address"`
//Enabled
Enabled bool `json:"enabled"`
}
// Prometheus setting in grid
type Prometheus struct {
//ScrapeInterval
ScrapeInterval int `json:"scrapeInterval"`
}

View File

@@ -17,7 +17,7 @@ type SetPasswordPolicyRequest struct {
// Available numbers in the password
// Default value : true
// Required: true
Digits bool `url:"digits" json:"digits"`
Digits interface{} `url:"digits" json:"digits" validate:"isBool"`
// Available special characters in the password
// Default value : false
@@ -27,12 +27,12 @@ type SetPasswordPolicyRequest struct {
// Number of characters in the password
// Default value : 9
// Required: true
PasswordLength uint64 `url:"passwordLength" json:"passwordLength" validate:"required"`
PasswordLength uint64 `url:"passwordLength" json:"passwordLength"`
// Capital letters in the password are available
// Default value : true
// Required: true
Uppercase bool `url:"uppercase" json:"uppercase"`
Uppercase interface{} `url:"uppercase" json:"uppercase" validate:"isBool"`
}
// RemoveCustomBackupPath set set password policy for a grid
@@ -42,6 +42,18 @@ func (g Grid) SetPasswordPolicy(ctx context.Context, req SetPasswordPolicyReques
return false, validators.ValidationErrors(validators.GetErrors(err))
}
if req.PasswordLength == 0 {
req.PasswordLength = 9
}
if req.Digits == nil {
req.Digits = true
}
if req.Uppercase == nil {
req.Uppercase = true
}
url := "/cloudbroker/grid/setPasswordPolicy"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)