Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46af79b664 | ||
|
|
84bcd2eb53 | ||
|
|
cc9aa2a6fc | ||
|
|
7ddd8c5fbe |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,6 +1,15 @@
|
|||||||
## Version 1.0.2
|
## Version 1.1.1
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
|
||||||
- Update tags for Kubernetes create
|
#### CloudAPI
|
||||||
- Add License file
|
|
||||||
|
- Disks
|
||||||
|
- Change the SizeUsed field type to float64
|
||||||
|
- Compute
|
||||||
|
- Chnage the SizeUsed field type to float64
|
||||||
|
|
||||||
|
#### Cloudbroker
|
||||||
|
|
||||||
|
- Disks
|
||||||
|
- Change the SizeUsed field type to float64
|
||||||
|
|||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
Decort SDK - это библиотека, написанная на языке GO, позволяющая взаимодействовать с API облачной платформы **DECORT**. Библиотека содеражит в себе структуры и методы, необходимые для отправки запросов. Decort SDK имеет встроенный http-клиент и поддерживает разные способы авторизации на платформе. Библиотека так же содержит в себе модели ответов от платформы.
|
Decort SDK - это библиотека, написанная на языке GO, позволяющая взаимодействовать с API облачной платформы **DECORT**. Библиотека содеражит в себе структуры и методы, необходимые для отправки запросов. Decort SDK имеет встроенный http-клиент и поддерживает разные способы авторизации на платформе. Библиотека так же содержит в себе модели ответов от платформы.
|
||||||
|
|
||||||
|
## Версии
|
||||||
|
- Версия 1.0.0 Decort-SDK соответствует 3.8.4 версии платформы
|
||||||
|
- Версия 1.1.0 Decort-SDK соответствует 3.8.5 версии платформы
|
||||||
|
|
||||||
## Оглавление
|
## Оглавление
|
||||||
|
|
||||||
- [Установка](#установка)
|
- [Установка](#установка)
|
||||||
@@ -417,7 +421,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Выполнение запроса с помощью конвейера
|
//Выполнение запроса с помощью конвейера
|
||||||
res, err := client.СloudAPI().KVMX86().Create(context.Background(), req)
|
res, err := client.CloudAPI().KVMX86().Create(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for creating account
|
// Request struct for creating account
|
||||||
@@ -50,17 +48,6 @@ type CreateRequest struct {
|
|||||||
// Limit (positive) or disable (0) GPU resources
|
// Limit (positive) or disable (0) GPU resources
|
||||||
// Required: false
|
// Required: false
|
||||||
GPUUnits uint64 `url:"gpu_units,omitempty"`
|
GPUUnits uint64 `url:"gpu_units,omitempty"`
|
||||||
|
|
||||||
// Resource types available to create in this account
|
|
||||||
// Each element in a resource type slice must be one of:
|
|
||||||
// - compute
|
|
||||||
// - vins
|
|
||||||
// - k8s
|
|
||||||
// - openshift
|
|
||||||
// - lb
|
|
||||||
// - flipgroup
|
|
||||||
// Required: false
|
|
||||||
ResTypes []string `url:"resourceTypes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq CreateRequest) validate() error {
|
func (arq CreateRequest) validate() error {
|
||||||
@@ -70,14 +57,6 @@ func (arq CreateRequest) validate() error {
|
|||||||
if arq.Username == "" {
|
if arq.Username == "" {
|
||||||
return errors.New("validation-error: field Username can not be empty")
|
return errors.New("validation-error: field Username can not be empty")
|
||||||
}
|
}
|
||||||
if len(arq.ResTypes) > 0 {
|
|
||||||
for _, value := range arq.ResTypes {
|
|
||||||
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
|
||||||
if !validate {
|
|
||||||
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,75 +45,6 @@ type ResourceLimits struct {
|
|||||||
GPUUnits float64 `json:"gpu_units"`
|
GPUUnits float64 `json:"gpu_units"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main information of account
|
|
||||||
type InfoAccount struct {
|
|
||||||
// Segment
|
|
||||||
DCLocation string `json:"DCLocation"`
|
|
||||||
|
|
||||||
// Key
|
|
||||||
CKey string `jspn:"_ckey"`
|
|
||||||
|
|
||||||
// Meta
|
|
||||||
Meta []interface{} `json:"_meta"`
|
|
||||||
|
|
||||||
// Access Control List
|
|
||||||
ACL []RecordACL `json:"acl"`
|
|
||||||
|
|
||||||
// Company
|
|
||||||
Company string `json:"company"`
|
|
||||||
|
|
||||||
// Company URL
|
|
||||||
CompanyURL string `json:"companyurl"`
|
|
||||||
|
|
||||||
// Created by
|
|
||||||
CreatedBy string `jspn:"createdBy"`
|
|
||||||
|
|
||||||
// Created time
|
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
|
||||||
|
|
||||||
// Deactiovation time
|
|
||||||
DeactiovationTime float64 `json:"deactivationTime"`
|
|
||||||
|
|
||||||
// Deleted by
|
|
||||||
DeletedBy string `json:"deletedBy"`
|
|
||||||
|
|
||||||
// Deleted time
|
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
|
||||||
|
|
||||||
// Display name
|
|
||||||
DisplayName string `json:"displayname"`
|
|
||||||
|
|
||||||
// GUID
|
|
||||||
GUID uint64 `json:"guid"`
|
|
||||||
|
|
||||||
// ID
|
|
||||||
ID uint64 `json:"id"`
|
|
||||||
|
|
||||||
// Name
|
|
||||||
Name string `json:"name"`
|
|
||||||
|
|
||||||
// Resource Limits
|
|
||||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
|
||||||
|
|
||||||
// If true send emails when a user is granted access to resources
|
|
||||||
SendAccessEmails bool `json:"sendAccessEmails"`
|
|
||||||
|
|
||||||
// Service Account
|
|
||||||
ServiceAccount bool `json:"serviceAccount"`
|
|
||||||
|
|
||||||
// Status
|
|
||||||
Status string `json:"status"`
|
|
||||||
|
|
||||||
// Updated time
|
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
|
||||||
|
|
||||||
// Version
|
|
||||||
Version uint64 `json:"version"`
|
|
||||||
|
|
||||||
// List VINS in account
|
|
||||||
VINS []uint64 `json:"vins"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main information in one of if the list of accounts
|
// Main information in one of if the list of accounts
|
||||||
type ItemAccount struct {
|
type ItemAccount struct {
|
||||||
// Access Control List
|
// Access Control List
|
||||||
@@ -149,6 +80,9 @@ type Resource struct {
|
|||||||
// Disk size
|
// Disk size
|
||||||
DiskSize int64 `json:"disksize"`
|
DiskSize int64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Max disk size
|
||||||
|
DiskSizeMax int64 `json:"disksizemax"`
|
||||||
|
|
||||||
// Number of External IPs
|
// Number of External IPs
|
||||||
ExtIPs int64 `json:"extips"`
|
ExtIPs int64 `json:"extips"`
|
||||||
|
|
||||||
@@ -160,6 +94,18 @@ type Resource struct {
|
|||||||
|
|
||||||
// Number of RAM
|
// Number of RAM
|
||||||
RAM int64 `json:"ram"`
|
RAM int64 `json:"ram"`
|
||||||
|
|
||||||
|
// SEPs
|
||||||
|
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disk usage
|
||||||
|
type DiskUsage struct {
|
||||||
|
// Disk size
|
||||||
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Disk size max
|
||||||
|
DiskSizeMax float64 `json:"disksizemax"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Information about resources
|
// Information about resources
|
||||||
@@ -189,21 +135,84 @@ type Machines struct {
|
|||||||
Halted uint64 `json:"halted"`
|
Halted uint64 `json:"halted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Сomplete information about account
|
// Main information about account
|
||||||
type RecordAccount struct {
|
type RecordAccount struct {
|
||||||
// Main information about account
|
// DCLocation
|
||||||
InfoAccount
|
DCLocation string `json:"DCLocation"`
|
||||||
|
|
||||||
// Resources
|
// Resources
|
||||||
Resources Resources `json:"Resources"`
|
Resources Resources `json:"Resources"`
|
||||||
|
|
||||||
|
// CKey
|
||||||
|
CKey string `json:"_ckey"`
|
||||||
|
|
||||||
|
// Access control list
|
||||||
|
ACL []RecordACL `json:"acl"`
|
||||||
|
|
||||||
|
// Company
|
||||||
|
Company string `json:"company"`
|
||||||
|
|
||||||
|
// Company URL
|
||||||
|
CompanyURL string `json:"companyurl"`
|
||||||
|
|
||||||
// Computes
|
// Computes
|
||||||
Computes Computes `json:"computes"`
|
Computes Computes `json:"computes"`
|
||||||
|
|
||||||
|
// Created by
|
||||||
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|
||||||
|
// Created time
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// Deactivation time
|
||||||
|
DeactivationTime uint64 `json:"deactivationTime"`
|
||||||
|
|
||||||
|
// Deleted by
|
||||||
|
DeletedBy string `json:"deletedBy"`
|
||||||
|
|
||||||
|
// Deleted time
|
||||||
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
|
// Display name
|
||||||
|
DisplayName string `json:"displayname"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
// Machines
|
// Machines
|
||||||
Machines Machines `json:"machines"`
|
Machines Machines `json:"machines"`
|
||||||
|
|
||||||
// Number of VINSes
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// Resource limits
|
||||||
|
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||||
|
|
||||||
|
// Resource types
|
||||||
|
ResourceTypes []string `json:"resourceTypes"`
|
||||||
|
|
||||||
|
// Send access emails
|
||||||
|
SendAccessEmails bool `json:"sendAccessEmails"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// UniqPools
|
||||||
|
UniqPools []interface{} `json:"uniqPools"`
|
||||||
|
|
||||||
|
// Updated time
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// Version
|
||||||
|
Version uint64 `json:"version"`
|
||||||
|
|
||||||
|
// VINS
|
||||||
|
VINS []uint64 `json:"vins"`
|
||||||
|
|
||||||
|
// VINSes
|
||||||
VINSes uint64 `json:"vinses"`
|
VINSes uint64 `json:"vinses"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +296,9 @@ type ItemDisk struct {
|
|||||||
// ID SEP
|
// ID SEP
|
||||||
SEPID uint64 `json:"sepId"`
|
SEPID uint64 `json:"sepId"`
|
||||||
|
|
||||||
|
// Shareable
|
||||||
|
Shareable bool `json:"shareable"`
|
||||||
|
|
||||||
// Max size
|
// Max size
|
||||||
SizeMax uint64 `json:"sizeMax"`
|
SizeMax uint64 `json:"sizeMax"`
|
||||||
|
|
||||||
@@ -378,10 +390,10 @@ type ListAudits []ItemAudit
|
|||||||
// Information compute in resource group
|
// Information compute in resource group
|
||||||
type RGComputes struct {
|
type RGComputes struct {
|
||||||
// Number of started computes
|
// Number of started computes
|
||||||
Started uint64 `json:"started"`
|
Started uint64 `json:"Started"`
|
||||||
|
|
||||||
// Number of stopped computes
|
// Number of stopped computes
|
||||||
Stopped uint64 `json:"stopped"`
|
Stopped uint64 `json:"Stopped"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resources of Resource group
|
// Resources of Resource group
|
||||||
@@ -390,12 +402,39 @@ type RGResources struct {
|
|||||||
Consumed Resource `json:"Consumed"`
|
Consumed Resource `json:"Consumed"`
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
Limits Resource `json:"Limits"`
|
Limits LimitsRG `json:"Limits"`
|
||||||
|
|
||||||
// Reserved
|
// Reserved
|
||||||
Reserved Resource `json:"Reserved"`
|
Reserved Resource `json:"Reserved"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resources used
|
||||||
|
type LimitsRG struct {
|
||||||
|
// Number of cores
|
||||||
|
CPU int64 `json:"cpu"`
|
||||||
|
|
||||||
|
// Disk size
|
||||||
|
DiskSize int64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Max disk size
|
||||||
|
DiskSizeMax int64 `json:"disksizemax"`
|
||||||
|
|
||||||
|
// Number of External IPs
|
||||||
|
ExtIPs int64 `json:"extips"`
|
||||||
|
|
||||||
|
// External traffic
|
||||||
|
ExtTraffic int64 `json:"exttraffic"`
|
||||||
|
|
||||||
|
// Number of grafic cores
|
||||||
|
GPU int64 `json:"gpu"`
|
||||||
|
|
||||||
|
// Number of RAM
|
||||||
|
RAM int64 `json:"ram"`
|
||||||
|
|
||||||
|
// SEPs
|
||||||
|
SEPs uint64 `json:"seps"`
|
||||||
|
}
|
||||||
|
|
||||||
// Main information about resource group
|
// Main information about resource group
|
||||||
type ItemRG struct {
|
type ItemRG struct {
|
||||||
// Computes
|
// Computes
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for updaate account
|
// Request struct for updaate account
|
||||||
@@ -46,31 +44,12 @@ type UpdateRequest struct {
|
|||||||
// Limit (positive) or disable (0) GPU resources
|
// Limit (positive) or disable (0) GPU resources
|
||||||
// Required: false
|
// Required: false
|
||||||
GPUUnits uint64 `url:"gpu_units,omitempty"`
|
GPUUnits uint64 `url:"gpu_units,omitempty"`
|
||||||
|
|
||||||
// Resource types available to create in this account
|
|
||||||
// Each element in a resource type slice must be one of:
|
|
||||||
// - compute
|
|
||||||
// - vins
|
|
||||||
// - k8s
|
|
||||||
// - openshift
|
|
||||||
// - lb
|
|
||||||
// - flipgroup
|
|
||||||
// Required: false
|
|
||||||
ResTypes []string `url:"resourceTypes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq UpdateRequest) validate() error {
|
func (arq UpdateRequest) validate() error {
|
||||||
if arq.AccountID == 0 {
|
if arq.AccountID == 0 {
|
||||||
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
return errors.New("validation-error: field AccountID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
if len(arq.ResTypes) > 0 {
|
|
||||||
for _, value := range arq.ResTypes {
|
|
||||||
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
|
||||||
if !validate {
|
|
||||||
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ type GroupAddRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
Driver string `url:"driver"`
|
Driver string `url:"driver"`
|
||||||
|
|
||||||
|
// Storage endpoint provider ID
|
||||||
|
// Required: false
|
||||||
|
SEPID uint64 `url:"sepId,omitempty"`
|
||||||
|
|
||||||
|
// Pool to use if sepId is set, can be also empty if needed to be chosen by system
|
||||||
|
// Required: false
|
||||||
|
SEPPool string `url:"sepPool,omitempty"`
|
||||||
|
|
||||||
// Group role tag. Can be empty string, does not have to be unique
|
// Group role tag. Can be empty string, does not have to be unique
|
||||||
// Required: false
|
// Required: false
|
||||||
Role string `url:"role,omitempty"`
|
Role string `url:"role,omitempty"`
|
||||||
|
|||||||
@@ -191,6 +191,9 @@ type RecordGroup struct {
|
|||||||
// List of Parent IDs
|
// List of Parent IDs
|
||||||
Parents []uint64 `json:"parents"`
|
Parents []uint64 `json:"parents"`
|
||||||
|
|
||||||
|
// Pool name
|
||||||
|
PoolName string `json:"poolName"`
|
||||||
|
|
||||||
// Number of RAM, MB
|
// Number of RAM, MB
|
||||||
RAM uint64 `json:"ram"`
|
RAM uint64 `json:"ram"`
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ package compute
|
|||||||
// Access Control List
|
// Access Control List
|
||||||
type RecordACL struct {
|
type RecordACL struct {
|
||||||
// Account ACL list
|
// Account ACL list
|
||||||
AccountACL ListACL `json:"accountACL"`
|
AccountACL ListACL `json:"accountAcl"`
|
||||||
|
|
||||||
// Compute ACL list
|
// Compute ACL list
|
||||||
ComputeACL ListACL `json:"computeACL"`
|
ComputeACL ListACL `json:"computeAcl"`
|
||||||
|
|
||||||
// Resource group ACL list
|
// Resource group ACL list
|
||||||
RGACL ListACL `json:"rgACL"`
|
RGACL ListACL `json:"rgAcl"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ACL information
|
// ACL information
|
||||||
@@ -281,7 +281,7 @@ type RecordCompute struct {
|
|||||||
// Created time
|
// Created time
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
// Custom fields
|
// Custom fields items
|
||||||
CustomFields map[string]interface{} `json:"customFields"`
|
CustomFields map[string]interface{} `json:"customFields"`
|
||||||
|
|
||||||
// Deleted by
|
// Deleted by
|
||||||
@@ -597,6 +597,9 @@ type ItemComputeDisk struct {
|
|||||||
// Pool
|
// Pool
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
|
// Present to
|
||||||
|
PresentTo []uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
|
|
||||||
@@ -612,11 +615,14 @@ type ItemComputeDisk struct {
|
|||||||
// SepID
|
// SepID
|
||||||
SepID uint64 `json:"sepId"`
|
SepID uint64 `json:"sepId"`
|
||||||
|
|
||||||
|
// Shareable
|
||||||
|
Shareable bool `json:"shareable"`
|
||||||
|
|
||||||
// Size max
|
// Size max
|
||||||
SizeMax uint64 `json:"sizeMax"`
|
SizeMax uint64 `json:"sizeMax"`
|
||||||
|
|
||||||
//Size used
|
//Size used
|
||||||
SizeUsed uint64 `json:"sizeUsed"`
|
SizeUsed float64 `json:"sizeUsed"`
|
||||||
|
|
||||||
// List extend snapshots
|
// List extend snapshots
|
||||||
Snapshots SnapshotExtendList `json:"snapshots"`
|
Snapshots SnapshotExtendList `json:"snapshots"`
|
||||||
@@ -703,7 +709,7 @@ type IOTune struct {
|
|||||||
// Main information about compute
|
// Main information about compute
|
||||||
type ItemCompute struct {
|
type ItemCompute struct {
|
||||||
// Access Control List
|
// Access Control List
|
||||||
ACL []interface{} `json:"ACL"`
|
ACL []interface{} `json:"acl"`
|
||||||
|
|
||||||
// Account ID
|
// Account ID
|
||||||
AccountID uint64 `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
@@ -750,7 +756,7 @@ type ItemCompute struct {
|
|||||||
// Created time
|
// Created time
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
// Custom fields
|
// Custom fields list
|
||||||
CustomFields map[string]interface{} `json:"customFields"`
|
CustomFields map[string]interface{} `json:"customFields"`
|
||||||
|
|
||||||
// Deleted by
|
// Deleted by
|
||||||
@@ -765,8 +771,8 @@ type ItemCompute struct {
|
|||||||
// Devices
|
// Devices
|
||||||
Devices interface{} `json:"devices"`
|
Devices interface{} `json:"devices"`
|
||||||
|
|
||||||
// List disk IDs
|
// List disk items
|
||||||
Disks []uint64 `json:"disks"`
|
Disks []InfoDisk `json:"disks"`
|
||||||
|
|
||||||
// Driver
|
// Driver
|
||||||
Driver string `json:"driver"`
|
Driver string `json:"driver"`
|
||||||
@@ -783,9 +789,6 @@ type ItemCompute struct {
|
|||||||
// Image ID
|
// Image ID
|
||||||
ImageID uint64 `json:"imageId"`
|
ImageID uint64 `json:"imageId"`
|
||||||
|
|
||||||
// Image name
|
|
||||||
ImageName string `json:"imageName"`
|
|
||||||
|
|
||||||
// List interfaces
|
// List interfaces
|
||||||
Interfaces ListInterfaces `json:"interfaces"`
|
Interfaces ListInterfaces `json:"interfaces"`
|
||||||
|
|
||||||
@@ -858,17 +861,23 @@ type ItemCompute struct {
|
|||||||
// User Managed or not
|
// User Managed or not
|
||||||
UserManaged bool `json:"userManaged"`
|
UserManaged bool `json:"userManaged"`
|
||||||
|
|
||||||
// Userdata
|
|
||||||
Userdata interface{} `json:"userdata"`
|
|
||||||
|
|
||||||
// List vGPU IDs
|
// List vGPU IDs
|
||||||
VGPUs []uint64 `json:"vgpus"`
|
VGPUs []uint64 `json:"vgpus"`
|
||||||
|
|
||||||
|
// VINS connected
|
||||||
|
VINSConnected uint64 `json:"vinsConnected"`
|
||||||
|
|
||||||
// Virtual image ID
|
// Virtual image ID
|
||||||
VirtualImageID uint64 `json:"virtualImageId"`
|
VirtualImageID uint64 `json:"virtualImageId"`
|
||||||
|
}
|
||||||
|
|
||||||
// Virtual image name
|
// Information Disk
|
||||||
VirtualImageName string `json:"virtualImageName"`
|
type InfoDisk struct {
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// PCISlot
|
||||||
|
PCISlot uint64 `json:"pciSlot"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List information about computes
|
// List information about computes
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type ItemComputeCI struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Template
|
// Template
|
||||||
Template string `jsnn:"template"`
|
Template string `json:"template"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of computeci instances
|
// List of computeci instances
|
||||||
|
|||||||
@@ -11,18 +11,12 @@ type ItemDisk struct {
|
|||||||
// Account name
|
// Account name
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
|
|
||||||
// Boot partition
|
// Computes
|
||||||
BootPartition uint64 `json:"bootPartition"`
|
Computes map[string]string `json:"computes"`
|
||||||
|
|
||||||
// Created time
|
// Created time
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
// Compute ID
|
|
||||||
ComputeID uint64 `json:"computeId"`
|
|
||||||
|
|
||||||
// Compute name
|
|
||||||
ComputeName string `json:"computeName"`
|
|
||||||
|
|
||||||
// Deleted time
|
// Deleted time
|
||||||
DeletedTime uint64 `json:"deletedTime"`
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
@@ -69,11 +63,14 @@ type ItemDisk struct {
|
|||||||
ParentID uint64 `json:"parentId"`
|
ParentID uint64 `json:"parentId"`
|
||||||
|
|
||||||
// PCI slot
|
// PCI slot
|
||||||
PCISlot uint64 `json:"pciSlot"`
|
PCISlot int64 `json:"pciSlot"`
|
||||||
|
|
||||||
// Pool
|
// Pool
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
|
// Present to
|
||||||
|
PresentTo []uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
|
|
||||||
@@ -89,12 +86,18 @@ type ItemDisk struct {
|
|||||||
// SepType
|
// SepType
|
||||||
SepType string `json:"sepType"`
|
SepType string `json:"sepType"`
|
||||||
|
|
||||||
|
// Shareable
|
||||||
|
Shareable bool `json:"shareable"`
|
||||||
|
|
||||||
// SepID
|
// SepID
|
||||||
SepID uint64 `json:"sepId"`
|
SepID uint64 `json:"sepId"`
|
||||||
|
|
||||||
// Size max
|
// Size max
|
||||||
SizeMax uint64 `json:"sizeMax"`
|
SizeMax uint64 `json:"sizeMax"`
|
||||||
|
|
||||||
|
// Size used
|
||||||
|
SizeUsed float64 `json:"sizeUsed"`
|
||||||
|
|
||||||
// List of snapshots
|
// List of snapshots
|
||||||
Snapshots ListSnapshots `json:"snapshots"`
|
Snapshots ListSnapshots `json:"snapshots"`
|
||||||
|
|
||||||
@@ -191,6 +194,9 @@ type RecordDisk struct {
|
|||||||
// Account name
|
// Account name
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
|
|
||||||
|
// Computes
|
||||||
|
Computes map[string]string `json:"computes"`
|
||||||
|
|
||||||
// Created time
|
// Created time
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
@@ -239,6 +245,9 @@ type RecordDisk struct {
|
|||||||
// Pool
|
// Pool
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
|
// Present to
|
||||||
|
PresentTo []uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Purge time
|
// Purge time
|
||||||
PurgeTime uint64 `json:"purgeTime"`
|
PurgeTime uint64 `json:"purgeTime"`
|
||||||
|
|
||||||
@@ -257,11 +266,14 @@ type RecordDisk struct {
|
|||||||
// SepID
|
// SepID
|
||||||
SepID uint64 `json:"sepId"`
|
SepID uint64 `json:"sepId"`
|
||||||
|
|
||||||
|
// Shareable
|
||||||
|
Shareable bool `json:"shareable"`
|
||||||
|
|
||||||
// Size max
|
// Size max
|
||||||
SizeMax uint64 `json:"sizeMax"`
|
SizeMax uint64 `json:"sizeMax"`
|
||||||
|
|
||||||
// Size used
|
// Size used
|
||||||
SizeUsed uint64 `json:"sizeUsed"`
|
SizeUsed float64 `json:"sizeUsed"`
|
||||||
|
|
||||||
// List of snapshots
|
// List of snapshots
|
||||||
Snapshots ListSnapshots `json:"snapshots"`
|
Snapshots ListSnapshots `json:"snapshots"`
|
||||||
|
|||||||
45
pkg/cloudapi/disks/share.go
Normal file
45
pkg/cloudapi/disks/share.go
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for share data disk
|
||||||
|
type ShareRequest struct {
|
||||||
|
// ID of the disk to share
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (drq ShareRequest) validate() error {
|
||||||
|
if drq.DiskID == 0 {
|
||||||
|
return errors.New("validation-error: field DiskID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Share shares data disk
|
||||||
|
func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/share"
|
||||||
|
|
||||||
|
res, err := d.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
|
||||||
|
}
|
||||||
45
pkg/cloudapi/disks/unshare.go
Normal file
45
pkg/cloudapi/disks/unshare.go
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for unshare data disk
|
||||||
|
type UnshareRequest struct {
|
||||||
|
// ID of the disk to unshare
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (drq UnshareRequest) validate() error {
|
||||||
|
if drq.DiskID == 0 {
|
||||||
|
return errors.New("validation-error: field DiskID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unshare unshares data disk
|
||||||
|
func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/disks/unshare"
|
||||||
|
|
||||||
|
res, err := d.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
|
||||||
|
}
|
||||||
@@ -29,6 +29,9 @@ type ItemFLIPGroup struct {
|
|||||||
// List of client IDs
|
// List of client IDs
|
||||||
ClientIDs []uint64 `json:"clientIds"`
|
ClientIDs []uint64 `json:"clientIds"`
|
||||||
|
|
||||||
|
// Client names list
|
||||||
|
ClientNames []string `json:"clientNames"`
|
||||||
|
|
||||||
// Client type
|
// Client type
|
||||||
ClientType string `json:"clientType"`
|
ClientType string `json:"clientType"`
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,9 @@ type RecordImage struct {
|
|||||||
// Pool
|
// Pool
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
|
// Present to
|
||||||
|
PresentTo []uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// ProviderName
|
// ProviderName
|
||||||
ProviderName string `json:"provider_name"`
|
ProviderName string `json:"provider_name"`
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,22 @@ type CreateRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
WorkerGroupName string `url:"workerGroupName"`
|
WorkerGroupName string `url:"workerGroupName"`
|
||||||
|
|
||||||
|
// ID of SEP to create boot disks for master nodes. Uses images SEP ID if not set
|
||||||
|
// Required: false
|
||||||
|
MasterSEPID uint64 `url:"masterSepId,omitempty"`
|
||||||
|
|
||||||
|
// Pool to use if master SEP ID is set, can be also empty if needed to be chosen by system
|
||||||
|
// Required: false
|
||||||
|
MasterSEPPool string `url:"masterSepPool,omitempty"`
|
||||||
|
|
||||||
|
// ID of SEP to create boot disks for default worker nodes group. Uses images SEP ID if not set
|
||||||
|
// Required: false
|
||||||
|
WorkerSEPID uint64 `url:"workerSepId,omitempty"`
|
||||||
|
|
||||||
|
// Pool to use if worker SEP ID is set, can be also empty if needed to be chosen by system
|
||||||
|
// Required: false
|
||||||
|
WorkerSEPPool string `url:"workerSepPool,omitempty"`
|
||||||
|
|
||||||
// List of strings with labels for default worker group
|
// List of strings with labels for default worker group
|
||||||
// i.e: ["label1=value1", "label2=value2"]
|
// i.e: ["label1=value1", "label2=value2"]
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
46
pkg/cloudapi/k8s/get_node_labels.go
Normal file
46
pkg/cloudapi/k8s/get_node_labels.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package k8s
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for get node labels
|
||||||
|
type GetNodeLabelsRequest struct {
|
||||||
|
// Kubernetes cluster ID
|
||||||
|
// Required: true
|
||||||
|
K8SID uint64 `url:"k8sId"`
|
||||||
|
|
||||||
|
// Node ID
|
||||||
|
// Required: false
|
||||||
|
NodeID uint64 `url:"nodeId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (krq GetNodeLabelsRequest) validate() error {
|
||||||
|
if krq.K8SID == 0 {
|
||||||
|
return errors.New("validation-error: field K8SID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
if krq.NodeID == 0 {
|
||||||
|
return errors.New("validation-error: field NodeID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetNodeLabels gets kubernetes cluster worker node labels
|
||||||
|
func (k8s K8S) GetNodeLabels(ctx context.Context, req GetNodeLabelsRequest) (string, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/k8s/getNodeLabels"
|
||||||
|
|
||||||
|
res, err := k8s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(res), nil
|
||||||
|
}
|
||||||
@@ -17,6 +17,14 @@ type WorkersGroupAddRequest struct {
|
|||||||
// Required: true
|
// Required: true
|
||||||
Name string `url:"name"`
|
Name string `url:"name"`
|
||||||
|
|
||||||
|
// ID of SEP to create boot disks for default worker nodes group. Uses images SEP ID if not set
|
||||||
|
// Required: false
|
||||||
|
WorkerSEPID uint64 `url:"workerSepId,omitempty"`
|
||||||
|
|
||||||
|
// Pool to use if worker SEP ID is set, can be also empty if needed to be chosen by system
|
||||||
|
// Required: false
|
||||||
|
WorkerSEPPool string `url:"workerSepPool,omitempty"`
|
||||||
|
|
||||||
// List of strings with labels for worker group
|
// List of strings with labels for worker group
|
||||||
// i.e: ["label1=value1", "label2=value2"]
|
// i.e: ["label1=value1", "label2=value2"]
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
45
pkg/cloudapi/lb/start.go
Normal file
45
pkg/cloudapi/lb/start.go
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for start load balancer
|
||||||
|
type StartRequest struct {
|
||||||
|
// ID of the load balancer instance to start
|
||||||
|
// Required: true
|
||||||
|
LBID uint64 `url:"lbId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lbrq StartRequest) validate() error {
|
||||||
|
if lbrq.LBID == 0 {
|
||||||
|
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start starts specified load balancer instance
|
||||||
|
func (l LB) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/lb/start"
|
||||||
|
|
||||||
|
res, err := l.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
|
||||||
|
}
|
||||||
45
pkg/cloudapi/lb/stop.go
Normal file
45
pkg/cloudapi/lb/stop.go
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package lb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for stop load balancer
|
||||||
|
type StopRequest struct {
|
||||||
|
// ID of the load balancer instance to stop
|
||||||
|
// Required: true
|
||||||
|
LBID uint64 `url:"lbId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lbrq StopRequest) validate() error {
|
||||||
|
if lbrq.LBID == 0 {
|
||||||
|
return errors.New("validation-error: field LBID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop stops specified load balancer instance
|
||||||
|
func (l LB) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudapi/lb/start"
|
||||||
|
|
||||||
|
res, err := l.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
|
||||||
|
}
|
||||||
@@ -5,8 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for create resource group
|
// Request struct for create resource group
|
||||||
@@ -80,17 +78,6 @@ type CreateRequest struct {
|
|||||||
// Register computes in registration system
|
// Register computes in registration system
|
||||||
// Required: false
|
// Required: false
|
||||||
RegisterComputes bool `url:"registerComputes,omitempty"`
|
RegisterComputes bool `url:"registerComputes,omitempty"`
|
||||||
|
|
||||||
// Resource types available to create in this account
|
|
||||||
// Each element in a resource type slice must be one of:
|
|
||||||
// - compute
|
|
||||||
// - vins
|
|
||||||
// - k8s
|
|
||||||
// - openshift
|
|
||||||
// - lb
|
|
||||||
// - flipgroup
|
|
||||||
// Required: false
|
|
||||||
ResTypes []string `url:"resourceTypes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rgrq CreateRequest) validate() error {
|
func (rgrq CreateRequest) validate() error {
|
||||||
@@ -103,14 +90,6 @@ func (rgrq CreateRequest) validate() error {
|
|||||||
if len(rgrq.Name) < 2 {
|
if len(rgrq.Name) < 2 {
|
||||||
return errors.New("field Name can not be shorter than two bytes")
|
return errors.New("field Name can not be shorter than two bytes")
|
||||||
}
|
}
|
||||||
if len(rgrq.ResTypes) > 0 {
|
|
||||||
for _, value := range rgrq.ResTypes {
|
|
||||||
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
|
||||||
if !validate {
|
|
||||||
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,55 @@
|
|||||||
package rg
|
package rg
|
||||||
|
|
||||||
|
// Resources used
|
||||||
|
type Resource struct {
|
||||||
|
// Number of cores
|
||||||
|
CPU int64 `json:"cpu"`
|
||||||
|
|
||||||
|
// Disk size
|
||||||
|
DiskSize int64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Max disk size
|
||||||
|
DiskSizeMax int64 `json:"disksizemax"`
|
||||||
|
|
||||||
|
// Number of External IPs
|
||||||
|
ExtIPs int64 `json:"extips"`
|
||||||
|
|
||||||
|
// External traffic
|
||||||
|
ExtTraffic int64 `json:"exttraffic"`
|
||||||
|
|
||||||
|
// Number of grafic cores
|
||||||
|
GPU int64 `json:"gpu"`
|
||||||
|
|
||||||
|
// Number of RAM
|
||||||
|
RAM int64 `json:"ram"`
|
||||||
|
|
||||||
|
// SEPs
|
||||||
|
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disk usage
|
||||||
|
type DiskUsage struct {
|
||||||
|
// Disk size
|
||||||
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Disk size max
|
||||||
|
DiskSizeMax float64 `json:"disksizemax"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Information about resources
|
||||||
|
type Resources struct {
|
||||||
|
// Current information about resources
|
||||||
|
Current Resource `json:"Current"`
|
||||||
|
|
||||||
|
// Reserved information about resources
|
||||||
|
Reserved Resource `json:"Reserved"`
|
||||||
|
}
|
||||||
|
|
||||||
// Detailed information about resource group
|
// Detailed information about resource group
|
||||||
type RecordResourceGroup struct {
|
type RecordResourceGroup struct {
|
||||||
|
// Resources
|
||||||
|
Resources Resources `json:"Resources"`
|
||||||
|
|
||||||
// Account ID
|
// Account ID
|
||||||
AccountID uint64 `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
|
|
||||||
@@ -78,14 +126,101 @@ type RecordResourceGroup struct {
|
|||||||
Computes []uint64 `json:"vms"`
|
Computes []uint64 `json:"vms"`
|
||||||
|
|
||||||
// List of resource types
|
// List of resource types
|
||||||
ResTypes []string `json:"resTypes"`
|
ResTypes []string `json:"resourceTypes"`
|
||||||
|
|
||||||
|
// UniqPools
|
||||||
|
UniqPools []string `json:"uniqPools"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main information about resource group
|
||||||
|
type ItemResourceGroup struct {
|
||||||
|
//
|
||||||
|
AccountACL ItemACL `json:"accountAcl"`
|
||||||
|
|
||||||
|
// Account ID
|
||||||
|
AccountID uint64 `json:"accountId"`
|
||||||
|
|
||||||
|
// Account name
|
||||||
|
AccountName string `json:"accountName"`
|
||||||
|
|
||||||
|
// Access Control List
|
||||||
|
ACL ListACL `json:"acl"`
|
||||||
|
|
||||||
|
// Created by
|
||||||
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|
||||||
|
// Created time
|
||||||
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
|
// DefNetID
|
||||||
|
DefNetID int64 `json:"def_net_id"`
|
||||||
|
|
||||||
|
// DefNetType
|
||||||
|
DefNetType string `json:"def_net_type"`
|
||||||
|
|
||||||
|
// Deleted by
|
||||||
|
DeletedBy string `json:"deletedBy"`
|
||||||
|
|
||||||
|
// Deleted time
|
||||||
|
DeletedTime uint64 `json:"deletedTime"`
|
||||||
|
|
||||||
|
// Description
|
||||||
|
Description string `json:"desc"`
|
||||||
|
|
||||||
|
// Dirty
|
||||||
|
Dirty bool `json:"dirty"`
|
||||||
|
|
||||||
|
// Grid ID
|
||||||
|
GID uint64 `json:"gid"`
|
||||||
|
|
||||||
|
// GUID
|
||||||
|
GUID uint64 `json:"guid"`
|
||||||
|
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// Lock status
|
||||||
|
LockStatus string `json:"lockStatus"`
|
||||||
|
|
||||||
|
// Milestones
|
||||||
|
Milestones uint64 `json:"milestones"`
|
||||||
|
|
||||||
|
// Name
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
|
// RegisterComputes
|
||||||
|
RegisterComputes bool `json:"registerComputes"`
|
||||||
|
|
||||||
|
// Resource limits
|
||||||
|
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||||
|
|
||||||
|
// Secret
|
||||||
|
Secret string `json:"secret"`
|
||||||
|
|
||||||
|
// Status
|
||||||
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// Updated by
|
||||||
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
|
||||||
|
// Updated time
|
||||||
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
|
// List of VINS IDs
|
||||||
|
VINS []uint64 `json:"vins"`
|
||||||
|
|
||||||
|
// List of compute IDs
|
||||||
|
Computes []uint64 `json:"vms"`
|
||||||
|
|
||||||
|
// List of resource types
|
||||||
|
ResTypes []string `json:"resourceTypes"`
|
||||||
|
|
||||||
// UniqPools
|
// UniqPools
|
||||||
UniqPools []string `json:"uniqPools"`
|
UniqPools []string `json:"uniqPools"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of resource groups
|
// List of resource groups
|
||||||
type ListResourceGroups []RecordResourceGroup
|
type ListResourceGroups []ItemResourceGroup
|
||||||
|
|
||||||
// Main information about Access Control List
|
// Main information about Access Control List
|
||||||
type ItemACL struct {
|
type ItemACL struct {
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for update resource group
|
// Request struct for update resource group
|
||||||
@@ -50,31 +48,12 @@ type UpdateRequest struct {
|
|||||||
// Reason for action
|
// Reason for action
|
||||||
// Required: false
|
// Required: false
|
||||||
Reason string `url:"reason,omitempty"`
|
Reason string `url:"reason,omitempty"`
|
||||||
|
|
||||||
// Resource types available to create in this account
|
|
||||||
// Each element in a resource type slice must be one of:
|
|
||||||
// - compute
|
|
||||||
// - vins
|
|
||||||
// - k8s
|
|
||||||
// - openshift
|
|
||||||
// - lb
|
|
||||||
// - flipgroup
|
|
||||||
// Required: false
|
|
||||||
ResTypes []string `url:"resourceTypes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rgrq UpdateRequest) validate() error {
|
func (rgrq UpdateRequest) validate() error {
|
||||||
if rgrq.RGID == 0 {
|
if rgrq.RGID == 0 {
|
||||||
return errors.New("field RGID can not be empty or equal to 0")
|
return errors.New("field RGID can not be empty or equal to 0")
|
||||||
}
|
}
|
||||||
if len(rgrq.ResTypes) > 0 {
|
|
||||||
for _, value := range rgrq.ResTypes {
|
|
||||||
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
|
||||||
if !validate {
|
|
||||||
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for creating account
|
// Request struct for creating account
|
||||||
@@ -55,17 +53,6 @@ type CreateRequest struct {
|
|||||||
// i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
|
// i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
|
||||||
// Required: false
|
// Required: false
|
||||||
UniqPools []string `url:"uniqPools,omitempty"`
|
UniqPools []string `url:"uniqPools,omitempty"`
|
||||||
|
|
||||||
// Resource types available to create in this account
|
|
||||||
// Each element in a resource type slice must be one of:
|
|
||||||
// - compute
|
|
||||||
// - vins
|
|
||||||
// - k8s
|
|
||||||
// - openshift
|
|
||||||
// - lb
|
|
||||||
// - flipgroup
|
|
||||||
// Required: false
|
|
||||||
ResTypes []string `url:"resourceTypes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq CreateRequest) validate() error {
|
func (arq CreateRequest) validate() error {
|
||||||
@@ -75,14 +62,6 @@ func (arq CreateRequest) validate() error {
|
|||||||
if arq.Username == "" {
|
if arq.Username == "" {
|
||||||
return errors.New("validation-error: field Username can not be empty")
|
return errors.New("validation-error: field Username can not be empty")
|
||||||
}
|
}
|
||||||
if len(arq.ResTypes) > 0 {
|
|
||||||
for _, value := range arq.ResTypes {
|
|
||||||
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
|
||||||
if !validate {
|
|
||||||
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ type Resource struct {
|
|||||||
// Disk size
|
// Disk size
|
||||||
DiskSize int64 `json:"disksize"`
|
DiskSize int64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Disk size max
|
||||||
|
DiskSizeMax int64 `json:"disksizemax"`
|
||||||
|
|
||||||
// Number of External IPs
|
// Number of External IPs
|
||||||
ExtIPs int64 `json:"extips"`
|
ExtIPs int64 `json:"extips"`
|
||||||
|
|
||||||
@@ -47,6 +50,18 @@ type Resource struct {
|
|||||||
|
|
||||||
// Number of RAM
|
// Number of RAM
|
||||||
RAM int64 `json:"ram"`
|
RAM int64 `json:"ram"`
|
||||||
|
|
||||||
|
// SEPs
|
||||||
|
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disk usage
|
||||||
|
type DiskUsage struct {
|
||||||
|
// Disk size
|
||||||
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Disk size max
|
||||||
|
DiskSizeMax float64 `json:"disksizemax"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access Control List
|
// Access Control List
|
||||||
@@ -138,12 +153,18 @@ type InfoAccount struct {
|
|||||||
// Resource limits
|
// Resource limits
|
||||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||||
|
|
||||||
|
// Resource types
|
||||||
|
ResourceTypes []string `json:"resourceTypes"`
|
||||||
|
|
||||||
// Send access emails
|
// Send access emails
|
||||||
SendAccessEmails bool `json:"sendAccessEmails"`
|
SendAccessEmails bool `json:"sendAccessEmails"`
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
|
// UniqPools
|
||||||
|
UniqPools []string `json:"uniqPools"`
|
||||||
|
|
||||||
// UpdatedTime
|
// UpdatedTime
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
@@ -258,6 +279,9 @@ type ItemDisk struct {
|
|||||||
// SepID
|
// SepID
|
||||||
SepID uint64 `json:"sepId"`
|
SepID uint64 `json:"sepId"`
|
||||||
|
|
||||||
|
// Shareable
|
||||||
|
Shareable bool `json:"shareable"`
|
||||||
|
|
||||||
// Size max
|
// Size max
|
||||||
SizeMax uint64 `json:"sizeMax"`
|
SizeMax uint64 `json:"sizeMax"`
|
||||||
|
|
||||||
@@ -351,6 +375,9 @@ type Consumed struct {
|
|||||||
// Disk size
|
// Disk size
|
||||||
DiskSize uint64 `json:"disksize"`
|
DiskSize uint64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Disk size max
|
||||||
|
DiskSizeMax int64 `json:"disksizemax"`
|
||||||
|
|
||||||
// External IPs
|
// External IPs
|
||||||
ExtIPs uint64 `json:"extips"`
|
ExtIPs uint64 `json:"extips"`
|
||||||
|
|
||||||
@@ -362,6 +389,9 @@ type Consumed struct {
|
|||||||
|
|
||||||
// Number of RAM
|
// Number of RAM
|
||||||
RAM uint64 `json:"ram"`
|
RAM uint64 `json:"ram"`
|
||||||
|
|
||||||
|
// SEPs
|
||||||
|
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
@@ -372,6 +402,9 @@ type Limits struct {
|
|||||||
// Disk size
|
// Disk size
|
||||||
DiskSize int64 `json:"disksize"`
|
DiskSize int64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Disk size max
|
||||||
|
DiskSizeMax int64 `json:"disksizemax"`
|
||||||
|
|
||||||
// External IPs
|
// External IPs
|
||||||
ExtIPs int64 `json:"extips"`
|
ExtIPs int64 `json:"extips"`
|
||||||
|
|
||||||
@@ -383,6 +416,9 @@ type Limits struct {
|
|||||||
|
|
||||||
// Number of RAM
|
// Number of RAM
|
||||||
RAM int64 `json:"ram"`
|
RAM int64 `json:"ram"`
|
||||||
|
|
||||||
|
// SEPs number
|
||||||
|
SEPs uint64 `json:"seps"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resources of resource group
|
// Resources of resource group
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for update account
|
// Request struct for update account
|
||||||
@@ -59,17 +57,6 @@ type UpdateRequest struct {
|
|||||||
// i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
|
// i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
|
||||||
// Required: false
|
// Required: false
|
||||||
UniqPools []string `url:"uniqPools,omitempty"`
|
UniqPools []string `url:"uniqPools,omitempty"`
|
||||||
|
|
||||||
// Resource types available to create in this account
|
|
||||||
// Each element in a resource type slice must be one of:
|
|
||||||
// - compute
|
|
||||||
// - vins
|
|
||||||
// - k8s
|
|
||||||
// - openshift
|
|
||||||
// - lb
|
|
||||||
// - flipgroup
|
|
||||||
// Required: false
|
|
||||||
ResTypes []string `url:"resourceTypes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (arq UpdateRequest) validate() error {
|
func (arq UpdateRequest) validate() error {
|
||||||
@@ -79,14 +66,6 @@ func (arq UpdateRequest) validate() error {
|
|||||||
if arq.Name == "" {
|
if arq.Name == "" {
|
||||||
return errors.New("validation-error: field Name must be set")
|
return errors.New("validation-error: field Name must be set")
|
||||||
}
|
}
|
||||||
if len(arq.ResTypes) > 0 {
|
|
||||||
for _, value := range arq.ResTypes {
|
|
||||||
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
|
||||||
if !validate {
|
|
||||||
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
65
pkg/cloudbroker/account/update_resource_types.go
Normal file
65
pkg/cloudbroker/account/update_resource_types.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package account
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for update resource types in account
|
||||||
|
type UpdateResourceTypesRequest struct {
|
||||||
|
// ID of account
|
||||||
|
// Required: true
|
||||||
|
AccountID uint64 `url:"accountId"`
|
||||||
|
|
||||||
|
// Resource types available to create in this account
|
||||||
|
// Each element in a resource type slice must be one of:
|
||||||
|
// - compute
|
||||||
|
// - vins
|
||||||
|
// - k8s
|
||||||
|
// - openshift
|
||||||
|
// - lb
|
||||||
|
// - flipgroup
|
||||||
|
// Required: true
|
||||||
|
ResTypes []string `url:"resourceTypes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (arq UpdateResourceTypesRequest) validate() error {
|
||||||
|
if arq.AccountID == 0 {
|
||||||
|
return errors.New("validation-error: field AccountID must be set")
|
||||||
|
}
|
||||||
|
if len(arq.ResTypes) > 0 {
|
||||||
|
for _, value := range arq.ResTypes {
|
||||||
|
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
||||||
|
if !validate {
|
||||||
|
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a Account) UpdateResourceTypes(ctx context.Context, req UpdateResourceTypesRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/account/updateResourceTypes"
|
||||||
|
|
||||||
|
res, err := a.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
|
||||||
|
}
|
||||||
@@ -27,7 +27,7 @@ func (crq ListGPURequest) validate() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListVGPU gets list GPU for compute
|
// ListVGPU gets list GPU for compute
|
||||||
func (c Compute) ListVGPU(ctx context.Context, req ListGPURequest) ([]interface{}, error) {
|
func (c Compute) ListGPU(ctx context.Context, req ListGPURequest) ([]interface{}, error) {
|
||||||
err := req.validate()
|
err := req.validate()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -401,6 +401,9 @@ type ItemDisk struct {
|
|||||||
// Pool
|
// Pool
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
|
// Present to
|
||||||
|
PresentTo []uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Purge attempts
|
// Purge attempts
|
||||||
PurgeAttempts uint64 `json:"purgeAttempts"`
|
PurgeAttempts uint64 `json:"purgeAttempts"`
|
||||||
|
|
||||||
@@ -425,11 +428,14 @@ type ItemDisk struct {
|
|||||||
// SEP ID
|
// SEP ID
|
||||||
SEPID uint64 `json:"sepId"`
|
SEPID uint64 `json:"sepId"`
|
||||||
|
|
||||||
|
// Shareable
|
||||||
|
Shareable bool `json:"shareable"`
|
||||||
|
|
||||||
// Size max
|
// Size max
|
||||||
SizeMax uint64 `json:"sizeMax"`
|
SizeMax uint64 `json:"sizeMax"`
|
||||||
|
|
||||||
// Size used
|
// Size used
|
||||||
SizeUsed uint64 `json:"sizeUsed"`
|
SizeUsed float64 `json:"sizeUsed"`
|
||||||
|
|
||||||
// List detailed snapshots
|
// List detailed snapshots
|
||||||
Snapshots ListDetailedSnapshots `json:"snapshots"`
|
Snapshots ListDetailedSnapshots `json:"snapshots"`
|
||||||
@@ -677,6 +683,9 @@ type InfoCompute struct {
|
|||||||
// Tech status
|
// Tech status
|
||||||
TechStatus string `json:"techStatus"`
|
TechStatus string `json:"techStatus"`
|
||||||
|
|
||||||
|
// Total disk size
|
||||||
|
TotalDiskSize uint64 `json:"totalDisksSize"`
|
||||||
|
|
||||||
// Updated by
|
// Updated by
|
||||||
UpdatedBy string `json:"updatedBy"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
|
||||||
@@ -692,6 +701,9 @@ type InfoCompute struct {
|
|||||||
// List VGPU IDs
|
// List VGPU IDs
|
||||||
VGPUs []uint64 `json:"vgpus"`
|
VGPUs []uint64 `json:"vgpus"`
|
||||||
|
|
||||||
|
// VINS connected
|
||||||
|
VINSConnected uint64 `json:"vinsConnected"`
|
||||||
|
|
||||||
// Virtual image ID
|
// Virtual image ID
|
||||||
VirtualImageID uint64 `json:"virtualImageId"`
|
VirtualImageID uint64 `json:"virtualImageId"`
|
||||||
}
|
}
|
||||||
@@ -708,7 +720,7 @@ type RecordCompute struct {
|
|||||||
// Main information about compute for list
|
// Main information about compute for list
|
||||||
type ItemCompute struct {
|
type ItemCompute struct {
|
||||||
// List of disk IDs
|
// List of disk IDs
|
||||||
Disks []uint64 `json:"disks"`
|
Disks []InfoDisk `json:"disks"`
|
||||||
|
|
||||||
// Main information about compute
|
// Main information about compute
|
||||||
InfoCompute
|
InfoCompute
|
||||||
@@ -720,6 +732,15 @@ type ItemCompute struct {
|
|||||||
VINSConnected uint64 `json:"vinsConnected"`
|
VINSConnected uint64 `json:"vinsConnected"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Information Disk
|
||||||
|
type InfoDisk struct {
|
||||||
|
// ID
|
||||||
|
ID uint64 `json:"id"`
|
||||||
|
|
||||||
|
// PCISlot
|
||||||
|
PCISlot uint64 `json:"pciSlot"`
|
||||||
|
}
|
||||||
|
|
||||||
// List computes
|
// List computes
|
||||||
type ListComputes []ItemCompute
|
type ListComputes []ItemCompute
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ type InfoDisk struct {
|
|||||||
// Boot partition
|
// Boot partition
|
||||||
BootPartition uint64 `json:"bootPartition"`
|
BootPartition uint64 `json:"bootPartition"`
|
||||||
|
|
||||||
|
// Computes
|
||||||
|
Computes map[string]string `json:"computes"`
|
||||||
|
|
||||||
// Created time
|
// Created time
|
||||||
CreatedTime uint64 `json:"createdTime"`
|
CreatedTime uint64 `json:"createdTime"`
|
||||||
|
|
||||||
@@ -119,6 +122,9 @@ type InfoDisk struct {
|
|||||||
// Pool
|
// Pool
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
|
// Present to
|
||||||
|
PresentTo []uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Purge attempts
|
// Purge attempts
|
||||||
PurgeAttempts uint64 `json:"purgeAttempts"`
|
PurgeAttempts uint64 `json:"purgeAttempts"`
|
||||||
|
|
||||||
@@ -143,11 +149,14 @@ type InfoDisk struct {
|
|||||||
// SEP ID
|
// SEP ID
|
||||||
SEPID uint64 `json:"sepId"`
|
SEPID uint64 `json:"sepId"`
|
||||||
|
|
||||||
|
// Shareable
|
||||||
|
Shareable bool `json:"shareable"`
|
||||||
|
|
||||||
// Size max
|
// Size max
|
||||||
SizeMax uint64 `json:"sizeMax"`
|
SizeMax uint64 `json:"sizeMax"`
|
||||||
|
|
||||||
// Size used
|
// Size used
|
||||||
SizeUsed uint64 `json:"sizeUsed"`
|
SizeUsed float64 `json:"sizeUsed"`
|
||||||
|
|
||||||
// List snapshots
|
// List snapshots
|
||||||
Snapshots ListSnapshots `json:"snapshots"`
|
Snapshots ListSnapshots `json:"snapshots"`
|
||||||
@@ -179,12 +188,6 @@ type RecordDisk struct {
|
|||||||
|
|
||||||
// Main information for list disks
|
// Main information for list disks
|
||||||
type ItemDisk struct {
|
type ItemDisk struct {
|
||||||
// Compute ID
|
|
||||||
ComputeID uint64 `json:"computeId"`
|
|
||||||
|
|
||||||
// Compute name
|
|
||||||
ComputeName string `json:"computeName"`
|
|
||||||
|
|
||||||
// Machine ID
|
// Machine ID
|
||||||
MachineID uint64 `json:"machineId"`
|
MachineID uint64 `json:"machineId"`
|
||||||
|
|
||||||
@@ -200,12 +203,6 @@ type ListDisks []ItemDisk
|
|||||||
|
|
||||||
// Main information about deleted disk
|
// Main information about deleted disk
|
||||||
type ItemDeletedDisk struct {
|
type ItemDeletedDisk struct {
|
||||||
// Compute ID
|
|
||||||
ComputeID uint64 `json:"computeId"`
|
|
||||||
|
|
||||||
// Compute name
|
|
||||||
ComputeName string `json:"computeName"`
|
|
||||||
|
|
||||||
// Machine ID
|
// Machine ID
|
||||||
MachineID uint64 `json:"machineId"`
|
MachineID uint64 `json:"machineId"`
|
||||||
|
|
||||||
@@ -254,6 +251,9 @@ type ItemSnapshot struct {
|
|||||||
// Label
|
// Label
|
||||||
Label string `json:"label"`
|
Label string `json:"label"`
|
||||||
|
|
||||||
|
// Reference ID
|
||||||
|
ReferenceID string `json:"referenceId"`
|
||||||
|
|
||||||
// Resource ID
|
// Resource ID
|
||||||
ResID string `json:"resId"`
|
ResID string `json:"resId"`
|
||||||
|
|
||||||
|
|||||||
45
pkg/cloudbroker/disks/share.go
Normal file
45
pkg/cloudbroker/disks/share.go
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for share data disk
|
||||||
|
type ShareRequest struct {
|
||||||
|
// ID of the disk to share
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (drq ShareRequest) validate() error {
|
||||||
|
if drq.DiskID == 0 {
|
||||||
|
return errors.New("validation-error: field DiskID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Share shares data disk
|
||||||
|
func (d Disks) Share(ctx context.Context, req ShareRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/disks/share"
|
||||||
|
|
||||||
|
res, err := d.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
|
||||||
|
}
|
||||||
45
pkg/cloudbroker/disks/unshare.go
Normal file
45
pkg/cloudbroker/disks/unshare.go
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package disks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for unshare data disk
|
||||||
|
type UnshareRequest struct {
|
||||||
|
// ID of the disk to unshare
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (drq UnshareRequest) validate() error {
|
||||||
|
if drq.DiskID == 0 {
|
||||||
|
return errors.New("validation-error: field DiskID can not be empty or equal to 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unshare unshares data disk
|
||||||
|
func (d Disks) Unshare(ctx context.Context, req UnshareRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/disks/unshare"
|
||||||
|
|
||||||
|
res, err := d.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
|
||||||
|
}
|
||||||
@@ -12,12 +12,18 @@ type DeviceMigrateRequest struct {
|
|||||||
// ID of external network
|
// ID of external network
|
||||||
// Required: true
|
// Required: true
|
||||||
NetID uint64 `url:"net_id"`
|
NetID uint64 `url:"net_id"`
|
||||||
|
|
||||||
|
// Target stack ID to migrate to
|
||||||
|
StackID uint64 `url:"stackId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (erq DeviceMigrateRequest) validate() error {
|
func (erq DeviceMigrateRequest) validate() error {
|
||||||
if erq.NetID == 0 {
|
if erq.NetID == 0 {
|
||||||
return errors.New("validation-error: field NetID must be set")
|
return errors.New("validation-error: field NetID must be set")
|
||||||
}
|
}
|
||||||
|
if erq.StackID == 0 {
|
||||||
|
return errors.New("validation-error: field StackID must be set")
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,6 +127,9 @@ type RecordExtNet struct {
|
|||||||
// CheckIPs
|
// CheckIPs
|
||||||
CheckIPs []string `json:"checkIPs"`
|
CheckIPs []string `json:"checkIPs"`
|
||||||
|
|
||||||
|
// CheckIps
|
||||||
|
CheckIps []string `json:"checkIps"`
|
||||||
|
|
||||||
// List DNS
|
// List DNS
|
||||||
DNS []string `json:"dns"`
|
DNS []string `json:"dns"`
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ type RecordResource struct {
|
|||||||
// Disk size
|
// Disk size
|
||||||
DiskSize uint64 `json:"disksize"`
|
DiskSize uint64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Disk size max
|
||||||
|
DiskSizeMax int64 `json:"disksizemax"`
|
||||||
|
|
||||||
// External IPs
|
// External IPs
|
||||||
ExtIPs uint64 `json:"extips"`
|
ExtIPs uint64 `json:"extips"`
|
||||||
|
|
||||||
@@ -28,6 +31,18 @@ type RecordResource struct {
|
|||||||
|
|
||||||
// Number of RAM
|
// Number of RAM
|
||||||
RAM uint64 `json:"ram"`
|
RAM uint64 `json:"ram"`
|
||||||
|
|
||||||
|
// SEPs
|
||||||
|
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disk usage
|
||||||
|
type DiskUsage struct {
|
||||||
|
// Disk size
|
||||||
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Disk size max
|
||||||
|
DiskSizeMax float64 `json:"disksizemax"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detailed information about grid
|
// Detailed information about grid
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ type RecordImage struct {
|
|||||||
// Pool
|
// Pool
|
||||||
Pool string `json:"pool"`
|
Pool string `json:"pool"`
|
||||||
|
|
||||||
|
// Present to
|
||||||
|
PresentTo []uint64 `json:"presentTo"`
|
||||||
|
|
||||||
// Provider name
|
// Provider name
|
||||||
ProviderName string `json:"provider_name"`
|
ProviderName string `json:"provider_name"`
|
||||||
|
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ type MassCreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
NetID uint64 `url:"netId,omitempty"`
|
NetID uint64 `url:"netId,omitempty"`
|
||||||
|
|
||||||
// IP address to assign to this VM when connecting to the specified network
|
// Input data for cloud-init facility
|
||||||
// Required: false
|
// Required: false
|
||||||
IPAddr string `url:"ipAddr,omitempty"`
|
UserData string `url:"userdata,omitempty"`
|
||||||
|
|
||||||
// Text description of this VM
|
// Text description of this VM
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ type MassCreateRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
IPAddr string `url:"ipAddr,omitempty"`
|
IPAddr string `url:"ipAddr,omitempty"`
|
||||||
|
|
||||||
// User data
|
// Input data for cloud-init facility
|
||||||
// Required: false
|
// Required: false
|
||||||
UserData string `url:"userdata,omitempty"`
|
UserData string `url:"userdata,omitempty"`
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for create resource group
|
// Request struct for create resource group
|
||||||
@@ -84,17 +82,6 @@ type CreateRequest struct {
|
|||||||
// List of strings with pools i.e.: ["sep1_poolName1", "sep2_poolName2"]
|
// List of strings with pools i.e.: ["sep1_poolName1", "sep2_poolName2"]
|
||||||
// Required: false
|
// Required: false
|
||||||
UniqPools []string `url:"unuqPools,omitempty"`
|
UniqPools []string `url:"unuqPools,omitempty"`
|
||||||
|
|
||||||
// Resource types available to create in this account
|
|
||||||
// Each element in a resource type slice should be one of:
|
|
||||||
// - compute
|
|
||||||
// - vins
|
|
||||||
// - k8s
|
|
||||||
// - openshift
|
|
||||||
// - lb
|
|
||||||
// - flipgroup
|
|
||||||
// Required: false
|
|
||||||
ResTypes []string `url:"resourceTypes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rgrq CreateRequest) validate() error {
|
func (rgrq CreateRequest) validate() error {
|
||||||
@@ -107,14 +94,6 @@ func (rgrq CreateRequest) validate() error {
|
|||||||
if len(rgrq.Name) < 2 {
|
if len(rgrq.Name) < 2 {
|
||||||
return errors.New("field Name can not be shorter than two bytes")
|
return errors.New("field Name can not be shorter than two bytes")
|
||||||
}
|
}
|
||||||
if len(rgrq.ResTypes) > 0 {
|
|
||||||
for _, value := range rgrq.ResTypes {
|
|
||||||
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
|
||||||
if !validate {
|
|
||||||
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ type Reservation struct {
|
|||||||
// Disk size
|
// Disk size
|
||||||
DiskSize uint64 `json:"disksize"`
|
DiskSize uint64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Max disk size
|
||||||
|
DiskSizeMax int64 `json:"disksizemax"`
|
||||||
|
|
||||||
// External IPs
|
// External IPs
|
||||||
ExtIPs uint64 `json:"extips"`
|
ExtIPs uint64 `json:"extips"`
|
||||||
|
|
||||||
@@ -40,6 +43,18 @@ type Reservation struct {
|
|||||||
|
|
||||||
// Number of RAM
|
// Number of RAM
|
||||||
RAM uint64 `json:"ram"`
|
RAM uint64 `json:"ram"`
|
||||||
|
|
||||||
|
// SEPs
|
||||||
|
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disk usage
|
||||||
|
type DiskUsage struct {
|
||||||
|
// Disk size
|
||||||
|
DiskSize float64 `json:"disksize"`
|
||||||
|
|
||||||
|
// Disk size max
|
||||||
|
DiskSizeMax float64 `json:"disksizemax"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resources usage information
|
// Resources usage information
|
||||||
@@ -180,7 +195,7 @@ type ItemRG struct {
|
|||||||
VMs []uint64 `json:"vms"`
|
VMs []uint64 `json:"vms"`
|
||||||
|
|
||||||
// Resource types list
|
// Resource types list
|
||||||
ResTypes []string `json:"resTypes"`
|
ResTypes []string `json:"resourceTypes"`
|
||||||
|
|
||||||
// Uniq pools
|
// Uniq pools
|
||||||
UniqPools []string `json:"uniqPools"`
|
UniqPools []string `json:"uniqPools"`
|
||||||
@@ -217,7 +232,7 @@ type ItemAffinityGroupCompute struct {
|
|||||||
type ListAffinityGroupCompute []ItemAffinityGroupCompute
|
type ListAffinityGroupCompute []ItemAffinityGroupCompute
|
||||||
|
|
||||||
// Main information about affinity rule
|
// Main information about affinity rule
|
||||||
type ItemAffinityRule struct {
|
type ItemRule struct {
|
||||||
// GUID
|
// GUID
|
||||||
GUID string `json:"guid"`
|
GUID string `json:"guid"`
|
||||||
|
|
||||||
@@ -237,8 +252,8 @@ type ItemAffinityRule struct {
|
|||||||
Value string `json:"value"`
|
Value string `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// List affinity rules
|
// List rules
|
||||||
type ListAffinityRules []ItemAffinityRule
|
type ListRules []ItemRule
|
||||||
|
|
||||||
// Main information about compute
|
// Main information about compute
|
||||||
type ItemCompute struct {
|
type ItemCompute struct {
|
||||||
@@ -252,13 +267,13 @@ type ItemCompute struct {
|
|||||||
AffinityLabel string `json:"affinityLabel"`
|
AffinityLabel string `json:"affinityLabel"`
|
||||||
|
|
||||||
// List affinity rules
|
// List affinity rules
|
||||||
AffinityRules ListAffinityRules `json:"affinityRules"`
|
AffinityRules ListRules `json:"affinityRules"`
|
||||||
|
|
||||||
// Affinity weight
|
// Affinity weight
|
||||||
AffinityWeight uint64 `json:"affinityWeight"`
|
AffinityWeight uint64 `json:"affinityWeight"`
|
||||||
|
|
||||||
// Anti affinity rules
|
// Anti affinity rules
|
||||||
AntiAffinityRules []interface{} `json:"antiAffinityRules"`
|
AntiAffinityRules ListRules `json:"antiAffinityRules"`
|
||||||
|
|
||||||
// Number of CPU
|
// Number of CPU
|
||||||
CPUs uint64 `json:"cpus"`
|
CPUs uint64 `json:"cpus"`
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/rudecs/decort-sdk/internal/validators"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for update resource group
|
// Request struct for update resource group
|
||||||
@@ -54,31 +52,13 @@ type UpdateRequest struct {
|
|||||||
// List of strings with pools i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
|
// List of strings with pools i.e.: ["sep1_poolName1", "sep2_poolName2", etc]
|
||||||
// Required: false
|
// Required: false
|
||||||
UniqPools []string `url:"uniqPools,omitempty"`
|
UniqPools []string `url:"uniqPools,omitempty"`
|
||||||
|
|
||||||
// Resource types available to create in this account
|
|
||||||
// Each element in a resource type slice should be one of:
|
|
||||||
// - compute
|
|
||||||
// - vins
|
|
||||||
// - k8s
|
|
||||||
// - openshift
|
|
||||||
// - lb
|
|
||||||
// - flipgroup
|
|
||||||
// Required: false
|
|
||||||
ResTypes []string `url:"resourceTypes,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rgrq UpdateRequest) validate() error {
|
func (rgrq UpdateRequest) validate() error {
|
||||||
if rgrq.RGID == 0 {
|
if rgrq.RGID == 0 {
|
||||||
return errors.New("validation-error: field RGID must be set")
|
return errors.New("validation-error: field RGID must be set")
|
||||||
}
|
}
|
||||||
if len(rgrq.ResTypes) > 0 {
|
|
||||||
for _, value := range rgrq.ResTypes {
|
|
||||||
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
|
||||||
if !validate {
|
|
||||||
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
pkg/cloudbroker/rg/update_resource_types.go
Normal file
65
pkg/cloudbroker/rg/update_resource_types.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package rg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/rudecs/decort-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for update resource types in account
|
||||||
|
type UpdateResourceTypesRequest struct {
|
||||||
|
// ID of resource group
|
||||||
|
// Required: true
|
||||||
|
RGID uint64 `url:"rgId"`
|
||||||
|
|
||||||
|
// Resource types available to create in this resource group
|
||||||
|
// Each element in a resource type slice must be one of:
|
||||||
|
// - compute
|
||||||
|
// - vins
|
||||||
|
// - k8s
|
||||||
|
// - openshift
|
||||||
|
// - lb
|
||||||
|
// - flipgroup
|
||||||
|
// Required: true
|
||||||
|
ResTypes []string `url:"resourceTypes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rgrq UpdateResourceTypesRequest) validate() error {
|
||||||
|
if rgrq.RGID == 0 {
|
||||||
|
return errors.New("validation-error: field RGID must be set")
|
||||||
|
}
|
||||||
|
if len(rgrq.ResTypes) > 0 {
|
||||||
|
for _, value := range rgrq.ResTypes {
|
||||||
|
validate := validators.StringInSlice(value, []string{"compute", "vins", "k8s", "openshift", "lb", "flipgroup"})
|
||||||
|
if !validate {
|
||||||
|
return errors.New("validation-error: Every resource type specified should be one of [compute, vins, k8s, openshift, lb, flipgroup]")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r RG) UpdateResourceTypes(ctx context.Context, req UpdateResourceTypesRequest) (bool, error) {
|
||||||
|
err := req.validate()
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/rg/updateResourceTypes"
|
||||||
|
|
||||||
|
res, err := r.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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user