This commit is contained in:
dayterr
2025-09-11 15:56:44 +03:00
parent 825b1a0a00
commit abd35f858c
87 changed files with 930 additions and 571 deletions

View File

@@ -124,6 +124,18 @@ type ListAccounts struct {
EntryCount uint64 `json:"entryCount"`
}
// Policy
type Policy struct {
// Size of the disk
DiskSize float64 `json:"disksize"`
// Max size of the disk
DiskSizeMax float64 `json:"disksizemax"`
// SEPs used
SEPs map[string]map[string]DiskUsage `json:"seps"`
}
// Resources used
type Resource struct {
// Number of cores
@@ -144,6 +156,9 @@ type Resource struct {
// Number of grafic cores
GPU int64 `json:"gpu"`
// Policies
Policies map[string]Policy `json:"policies"`
// Number of RAM
RAM int64 `json:"ram"`
@@ -218,9 +233,6 @@ type RecordAccount struct {
// DCLocation
DCLocation string `json:"DCLocation"`
// CKey
CKey string `json:"_ckey"`
// Access control list
ACL []RecordACL `json:"acl"`

View File

@@ -55,7 +55,6 @@ var computes = ListComputes{
GID: 212,
GUID: 48500,
ID: 48500,
ImageID: 9884,
Interfaces: []ItemVNFInterface{},
LockStatus: "UNLOCKED",
ManagerID: 0,
@@ -82,7 +81,6 @@ var computes = ListComputes{
UserManaged: true,
VGPUs: []uint64{},
VINSConnected: 0,
VirtualImageID: 0,
ZoneID: 1,
},
{
@@ -118,7 +116,6 @@ var computes = ListComputes{
GID: 212,
GUID: 48556,
ID: 48556,
ImageID: 9884,
Interfaces: []ItemVNFInterface{},
LockStatus: "UNLOCKED",
ManagerID: 0,
@@ -145,7 +142,6 @@ var computes = ListComputes{
UserManaged: true,
VGPUs: []uint64{},
VINSConnected: 0,
VirtualImageID: 0,
ZoneID: 5,
},
},

View File

@@ -443,6 +443,9 @@ type RecordCompute struct {
// Natable VINS network name
NatableVINSNetworkName string `json:"natableVinsNetworkName"`
// Name of OS
OSVersion string `json:"os_version"`
// List OS Users
OSUsers ListOSUser `json:"osUsers"`
@@ -509,12 +512,6 @@ type RecordCompute struct {
// vGPUs list
VGPUs []VGPUItem `json:"vgpus"`
// Virtual image ID
VirtualImageID uint64 `json:"virtualImageId"`
// Virtual image name
VirtualImageName string `json:"virtualImageName"`
// VNC password
VNCPassword string `json:"vncPasswd"`
@@ -1066,9 +1063,6 @@ type ItemCompute struct {
// ID
ID uint64 `json:"id"`
// Image ID
ImageID uint64 `json:"imageId"`
// List interfaces
Interfaces ListInterfaces `json:"interfaces"`
@@ -1117,6 +1111,9 @@ type ItemCompute struct {
// Number of RAM
RAM uint64 `json:"ram"`
// Name of OS
OSVersion string `json:"os_version"`
// Qemu_quest
QemuQuest QemuQuest `json:"qemu_guest"`
@@ -1174,9 +1171,6 @@ type ItemCompute struct {
// VINS connected
VINSConnected uint64 `json:"vinsConnected"`
// Virtual image ID
VirtualImageID uint64 `json:"virtualImageId"`
// Zone ID
ZoneID uint64 `json:"zoneId"`
}

View File

@@ -21,6 +21,10 @@ type RedeployRequest struct {
// ID of the new OS image, if image change is required
// Required: false
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
// The OS version that will be installed on the virtual machine
// Required: false
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
// new size for the boot disk in GB, if boot disk size change is required
// Required: false

View File

@@ -65,6 +65,10 @@ type UpdateRequest struct {
// Does this machine supports hot resize, true or false
// Required: false
HotResize interface{} `url:"hotResize,omitempty" json:"hotResize,omitempty" validate:"omitempty,isBool"`
// The OS version that will be installed on the virtual machine
// Required: false
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
}
// Update updates some properties of the compute

View File

@@ -46,6 +46,10 @@ type ListRequest struct {
// Required: false
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
// Find by storage policy id
// Required: false
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
// Find by pool name
// Required: false
Pool string `url:"pool,omitempty" json:"pool,omitempty"`

View File

@@ -38,6 +38,10 @@ type ListUnattachedRequest struct {
// Required: false
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
// Find by storage policy id
// Required: false
StoragePolicyID uint64 `url:"storage_policy_id,omitempty" json:"storage_policy_id,omitempty"`
// Find by pool name
// Required: false
Pool string `url:"pool,omitempty" json:"pool,omitempty"`

View File

@@ -121,6 +121,10 @@ type CreateRequest struct {
// Required: false
ImageID uint64 `url:"imageId,omitempty" json:"imageId,omitempty"`
// The OS version that will be installed on the virtual machine
// Required: false
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
// Size of the boot disk in GB
// Required: false
BootDisk uint64 `url:"bootDisk,omitempty" json:"bootDisk,omitempty"`

View File

@@ -92,6 +92,10 @@ type CreateBlankRequest struct {
// Zone ID
// Required: false
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
// The OS version that will be installed on the virtual machine
// Required: false
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
}
// GetRAM returns RAM field values

View File

@@ -83,8 +83,8 @@ type CreateRequest struct {
}
type StoragePolicy struct {
ID int64 `url:"id" json:"id"`
Limit int `url:"limit" json:"limit"`
ID uint64 `url:"id" json:"id"`
Limit int `url:"limit" json:"limit"`
}
// Create creates resource group

View File

@@ -1,4 +1,4 @@
package securitygroup
package secgroup
import (
"context"

View File

@@ -1,4 +1,4 @@
package securitygroup
package secgroup
import (
"context"

View File

@@ -1,4 +1,4 @@
package securitygroup
package secgroup
import (
"context"

View File

@@ -1,4 +1,4 @@
package securitygroup
package secgroup
import (
"context"

View File

@@ -1,4 +1,4 @@
package securitygroup
package secgroup
// FilterByID returns ListSecurityGroups with specified ID.
func (lsg ListSecurityGroups) FilterByID(id uint64) ListSecurityGroups {

View File

@@ -1,4 +1,4 @@
package securitygroup
package secgroup
import "testing"

View File

@@ -1,4 +1,4 @@
package securitygroup
package secgroup
import (
"context"

View File

@@ -1,4 +1,4 @@
package securitygroup
package secgroup
import (
"context"

View File

@@ -0,0 +1,94 @@
package secgroup
type ListSecurityGroups struct {
// List
Data []ItemSecurityGroup `json:"data"`
// Entry count
EntryCount uint64 `json:"entryCount"`
}
type ItemSecurityGroup struct {
// ID of the security group
ID uint64 `json:"id"`
// Account ID that owns the security group
AccountID uint64 `json:"account_id"`
// Name of the security group
Name string `json:"name"`
// Description of the security group
Description string `json:"description"`
// List of rules
Rules Rules `json:"rules"`
// Created at
CreatedAt uint64 `json:"created_at"`
// Updated at
UpdatedAt uint64 `json:"updated_at"`
// Created by
CreatedBy string `json:"created_by"`
// Updated by
UpdatedBy string `json:"updated_by"`
}
type RecordSecurityGroup struct {
// ID of the security group
ID uint64 `json:"id"`
// Account ID that owns the security group
AccountID uint64 `json:"account_id"`
// Name of the security group
Name string `json:"name"`
// Description of the security group
Description string `json:"description"`
// List of rules
Rules Rules `json:"rules"`
// Created at
CreatedAt uint64 `json:"created_at"`
// Updated at
UpdatedAt uint64 `json:"updated_at"`
// Created by
CreatedBy string `json:"created_by"`
// Updated by
UpdatedBy string `json:"updated_by"`
}
type Rules []Rule
type Rule struct {
// ID of the rule
ID uint64 `json:"id"`
// Traffic direction (inbound/outbound)
Direction string `json:"direction"`
// IP protocol version
Ethertype string `json:"ethertype"`
// Network protocol
Protocol string `json:"protocol"`
// Start port number (for TCP/UDP)
PortRangeMin uint64 `json:"port_range_min"`
// End port number (for TCP/UDP)
PortRangeMax uint64 `json:"port_range_max"`
// Remote IP prefix in CIDR notation
RemoteIPPrefix string `json:"remote_ip_prefix"`
RemoteGroupID uint64 `json:"remote_group_id"`
}

View File

@@ -1,4 +1,4 @@
package securitygroup
package secgroup
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"

View File

@@ -1,4 +1,4 @@
package securitygroup
package secgroup
import "sort"

View File

@@ -1,4 +1,4 @@
package securitygroup
package secgroup
import (
"context"

View File

@@ -1,43 +0,0 @@
package securitygroup
type ListSecurityGroups struct {
Data []ItemSecurityGroup `json:"data"`
EntryCount uint64 `json:"entryCount"`
}
type ItemSecurityGroup struct {
ID uint64 `json:"id"`
AccountID uint64 `json:"account_id"`
Name string `json:"name"`
Description string `json:"description"`
Rules Rules `json:"rules"`
CreatedAt uint64 `json:"created_at"`
UpdatedAt uint64 `json:"updated_at"`
CreatedBy string `json:"created_by"`
UpdatedBy string `json:"updated_by"`
}
type RecordSecurityGroup struct {
ID uint64 `json:"id"`
AccountID uint64 `json:"account_id"`
Name string `json:"name"`
Description string `json:"description"`
Rules Rules `json:"rules"`
CreatedAt uint64 `json:"created_at"`
UpdatedAt uint64 `json:"updated_at"`
CreatedBy string `json:"created_by"`
UpdatedBy string `json:"updated_by"`
}
type Rules []Rule
type Rule struct {
ID uint64 `json:"id"`
Direction string `json:"direction"`
Ethertype string `json:"ethertype"`
Protocol string `json:"protocol"`
PortRangeMin uint64 `json:"port_range_min"`
PortRangeMax uint64 `json:"port_range_max"`
RemoteIPPrefix string `json:"remote_ip_prefix"`
RemoteGroupID uint64 `json:"remote_group_id"`
}

View File

@@ -1,10 +1,10 @@
package cloudapi
import (
securitygroup "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/security_group"
secgroup "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/secgroup"
)
// Accessing the Security Group method group
func (ca *CloudAPI) SecurityGroup() *securitygroup.SecurityGroup {
return securitygroup.New(ca.client)
func (ca *CloudAPI) SecurityGroup() *secgroup.SecurityGroup {
return secgroup.New(ca.client)
}

View File

@@ -0,0 +1,10 @@
package cloudapi
import (
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stpolicy"
)
// Accessing the Storage Policy method group
func (ca *CloudAPI) StPolicy() *stpolicy.StPolicy {
return stpolicy.New(ca.client)
}

View File

@@ -1,40 +0,0 @@
package storagepolicy
type ListStoragePolicies struct {
Data []ItemStoragePolicy `json:"data"`
EntryCount uint64 `json:"entryCount"`
}
type ItemStoragePolicy struct {
ID uint64 `json:"id"`
GUID uint64 `json:"guid"`
Name string `json:"name"`
Description string `json:"description"`
AccessSepPools ListAccessSepPools `json:"access_seps_pools"`
Status string `json:"status"`
LimitIOPS uint64 `json:"limit_iops"`
Usage Usage `json:"usage"`
}
type InfoStoragePolicy struct {
ID uint64 `json:"id"`
GUID uint64 `json:"guid"`
Name string `json:"name"`
Description string `json:"description"`
AccessSepPools ListAccessSepPools `json:"access_seps_pools"`
Status string `json:"status"`
LimitIOPS uint64 `json:"limit_iops"`
Usage Usage `json:"usage"`
}
type ListAccessSepPools []AccessSepPool
type AccessSepPool struct {
SepID uint64 `json:"sep_id"`
PoolNames []string `json:"pool_names"`
}
type Usage struct {
Accounts []uint64 `json:"accounts"`
Resgroups []uint64 `json:"resgroups"`
}

View File

@@ -1,10 +0,0 @@
package cloudapi
import (
storagepolicy "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/storage_policy"
)
// Accessing the Storage Policy method group
func (ca *CloudAPI) StoragePolicy() *storagepolicy.StoragePolicy {
return storagepolicy.New(ca.client)
}

View File

@@ -1,4 +1,4 @@
package storagepolicy
package stpolicy
import (
"context"
@@ -14,7 +14,7 @@ type GetRequest struct {
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
}
func (sp StoragePolicy) Get(ctx context.Context, req GetRequest) (*InfoStoragePolicy, error) {
func (sp StPolicy) Get(ctx context.Context, req GetRequest) (*InfoStoragePolicy, error) {
res, err := sp.GetRaw(ctx, req)
if err != nil {
return nil, err
@@ -30,7 +30,7 @@ func (sp StoragePolicy) Get(ctx context.Context, req GetRequest) (*InfoStoragePo
return &info, nil
}
func (sp StoragePolicy) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
func (sp StPolicy) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))

View File

@@ -1,4 +1,4 @@
package storagepolicy
package stpolicy
import (
"context"
@@ -59,7 +59,7 @@ type ListRequest struct {
}
// List gets list of storage policies as a ListStoragePolicies struct
func (sp StoragePolicy) List(ctx context.Context, req ListRequest) (*ListStoragePolicies, error) {
func (sp StPolicy) List(ctx context.Context, req ListRequest) (*ListStoragePolicies, error) {
res, err := sp.ListRaw(ctx, req)
if err != nil {
@@ -77,7 +77,7 @@ func (sp StoragePolicy) List(ctx context.Context, req ListRequest) (*ListStorage
}
// ListRaw gets list of storage policies as an array of bytes
func (sp StoragePolicy) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
func (sp StPolicy) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
if err := validators.ValidateRequest(req); err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))

View File

@@ -0,0 +1,82 @@
package stpolicy
type ListStoragePolicies struct {
// List
Data []ItemStoragePolicy `json:"data"`
// Entry Count
EntryCount uint64 `json:"entryCount"`
}
type ItemStoragePolicy struct {
// ID of the storage policy
ID uint64 `json:"id"`
// GUID
GUID uint64 `json:"guid"`
// Name of the storage policy
Name string `json:"name"`
// Description of the storage policy
Description string `json:"description"`
// List of pools in SEP for storage policy
AccessSEPPools ListAccessSEPPools `json:"access_seps_pools"`
// Status of the storage policy
Status string `json:"status"`
// Max IOPS for the sotrage policy
LimitIOPS uint64 `json:"limit_iops"`
// Which accounts and resource groups use the storage policy
Usage Usage `json:"usage"`
}
type InfoStoragePolicy struct {
// ID of the storage policy
ID uint64 `json:"id"`
// GUID
GUID uint64 `json:"guid"`
// Name of the storage policy
Name string `json:"name"`
// Description of the storage policy
Description string `json:"description"`
// List of pools in SEP for storage policy
AccessSEPPools ListAccessSEPPools `json:"access_seps_pools"`
// Status of the storage policy
Status string `json:"status"`
// Max IOPS for the sotrage policy
LimitIOPS uint64 `json:"limit_iops"`
// Which accounts and resource groups use the storage policy
Usage Usage `json:"usage"`
}
type ListAccessSEPPools []AccessSEPPool
type AccessSEPPool struct {
// SEP ID
SEPID uint64 `json:"sep_id"`
// SEP name
Name string `json:"sep_name"`
// Pool names
PoolNames []string `json:"pool_names"`
}
type Usage struct {
// List of accounts
Accounts []uint64 `json:"accounts"`
// List of resource groups
Resgroups []uint64 `json:"resgroups"`
}

View File

@@ -1,15 +1,15 @@
package storagepolicy
package stpolicy
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
// Structure for creating request to storage policy
type StoragePolicy struct {
type StPolicy struct {
client interfaces.Caller
}
// Builder for stack endpoint
func New(client interfaces.Caller) *StoragePolicy {
return &StoragePolicy{
func New(client interfaces.Caller) *StPolicy {
return &StPolicy{
client: client,
}
}