Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f1529c9aac | |||
| 040235f92f |
172
CHANGELOG.md
172
CHANGELOG.md
@@ -1,162 +1,14 @@
|
|||||||
## Version 1.5.0
|
## Version 1.5.2
|
||||||
|
|
||||||
### Feature
|
|
||||||
|
|
||||||
- Updated lists responses models in:
|
|
||||||
- - cloudapi/account/list
|
|
||||||
- - cloudbroker/account/list
|
|
||||||
- - cloudapi/bservice/list
|
|
||||||
- - cloudapi/compute/list
|
|
||||||
- - cloudbroker/compute/list
|
|
||||||
- - cloudapi/computeci/list
|
|
||||||
- - cloudapi/disks/list
|
|
||||||
- - cloudbroker/disks/list
|
|
||||||
- - cloudapi/extnet/list
|
|
||||||
- - cloudbroker/extnet/list
|
|
||||||
- - cloudapi/flipgroup/list
|
|
||||||
- - cloudapi/image/list
|
|
||||||
- - cloudbroker/image/list
|
|
||||||
- - cloudapi/k8ci/list
|
|
||||||
- - cloudbroker/k8ci/list
|
|
||||||
- - cloudapi/k8s/list
|
|
||||||
- - cloudapi/k8s/listDeleted
|
|
||||||
- - cloudbroker/k8s/list
|
|
||||||
- - cloudbroker/k8s/listDeleted
|
|
||||||
- - cloudapi/tasks/list
|
|
||||||
- - cloudbroker/tasks/list
|
|
||||||
- - cloudapi/rg/list
|
|
||||||
- - cloudbroker/rg/list
|
|
||||||
- - cloudapi/vins/list
|
|
||||||
- - cloudbroker/vins/list
|
|
||||||
- - cloudapi/account/listDeleted
|
|
||||||
- - cloudapi/account/listCompute
|
|
||||||
- - cloudapi/account/listDisks
|
|
||||||
- - cloudapi/account/listFlipGroups
|
|
||||||
- - cloudapi/account/listRG
|
|
||||||
- - cloudapi/account/listVINS
|
|
||||||
- - cloudapi/compute/listDeleted
|
|
||||||
- - cloudapi/disks/listDeleted
|
|
||||||
- - cloudapi/disks/listTypes
|
|
||||||
- - cloudapi/k8ci/listDeleted
|
|
||||||
- - cloudapi/lb/list
|
|
||||||
- - cloudapi/lb/listDeleted
|
|
||||||
- - cloudbroker/lb/list
|
|
||||||
- - cloudbroker/lb/listDeleted
|
|
||||||
- - cloudapi/rg/listComputes
|
|
||||||
- - cloudapi/rg/listDeleted
|
|
||||||
- - cloudapi/rg/listLb
|
|
||||||
- - cloudapi/rg/listPFW
|
|
||||||
- - cloudapi/rg/listVins
|
|
||||||
- - cloudapi/vins/listDeleted
|
|
||||||
- - cloudbroker/account/listComputes
|
|
||||||
- - cloudbroker/account/listDeleted
|
|
||||||
- - cloudbroker/account/listDisks
|
|
||||||
- - cloudbroker/account/listFlipGroups
|
|
||||||
- - cloudbroker/account/listRG
|
|
||||||
- - cloudbroker/account/listVINS
|
|
||||||
- - cloudbroker/compute/listDeleted
|
|
||||||
- - cloudapi/compute/listPciDevice
|
|
||||||
- - cloudbroker/compute/listPciDevice
|
|
||||||
- - cloudapi/compute/listVGpu
|
|
||||||
- - cloudbroker/compute/listVGpu
|
|
||||||
- - cloudbroker/disks/listTypes
|
|
||||||
- - cloudbroker/grid/list
|
|
||||||
- - cloudbroker/grid/listEmails
|
|
||||||
- - cloudbroker/k8ci/listDeleted
|
|
||||||
- - cloudbroker/pcidevice/list
|
|
||||||
- - cloudbroker/rg/affinityGroupsList
|
|
||||||
- - cloudbroker/rg/listDeleted
|
|
||||||
- - cloudbroker/rg/listComputes
|
|
||||||
- - cloudbroker/rg/listLB
|
|
||||||
- - cloudbroker/rg/listPfw
|
|
||||||
- - cloudbroker/rg/listResourceConsumption
|
|
||||||
- - cloudbroker/rg/listVins
|
|
||||||
- - cloudbroker/sep/list
|
|
||||||
- - cloudbroker/vgpu/list
|
|
||||||
- - cloudbroker/vins/extnetList
|
|
||||||
- - cloudbroker/vins/IpList
|
|
||||||
- - cloudbroker/vins/natRuleList
|
|
||||||
- - cloudapi/account/listTemplates
|
|
||||||
- - cloudapi/compute/pfwList
|
|
||||||
- - cloudapi/compute/sanpshotList
|
|
||||||
- - cloudapi/compute/userList
|
|
||||||
- - cloudapi/vins/extnetList
|
|
||||||
- - cloudapi/vins/ipList
|
|
||||||
- - cloudapi/vins/natRuleList
|
|
||||||
- - cloudapi/sizes/list
|
|
||||||
- - cloudapi/rg/affinityGroupsList
|
|
||||||
- - cloudapi/extnet/listComputes
|
|
||||||
|
|
||||||
- Added new endpoints:
|
|
||||||
- - cloudapi/rg/getResourceConsumption
|
|
||||||
- - cloudapi/rg/listResourceConsumption
|
|
||||||
- - cloudbroker/rg/getResourceConsumption
|
|
||||||
- - cloudbroker/rg/listResourceConsumption
|
|
||||||
- - cloudapi/account/getResourceConsumption
|
|
||||||
- - cloudapi/account/listResourceConsumption
|
|
||||||
- - cloudbroker/account/getResourceConsumption
|
|
||||||
- - cloudbroker/account/listResourceConsumption
|
|
||||||
- - cloudbroker/grid/getResourceConsumption
|
|
||||||
- - cloudbroker/grid/listResourceConsumption
|
|
||||||
- - cloudapi/compute/getCustomFields
|
|
||||||
- - cloudapi/compute/deleteCustomFields
|
|
||||||
- - cloudapi/compute/setCustomFields
|
|
||||||
|
|
||||||
- Added field CU_DM to ResourceLimits model (account, rg)
|
|
||||||
|
|
||||||
- Added field ReferenceID to SnapshotExtended model in cloudapi/compute/get
|
|
||||||
|
|
||||||
- Added field Interfaces in requests:
|
|
||||||
- - cloudapi/kvmppc/create
|
|
||||||
- - cloudapi/kvmppc/createBlank
|
|
||||||
- - cloudapi/kvmx86/create
|
|
||||||
- - cloudapi/kvmx86/createBlank
|
|
||||||
- - cloudbroker/kvmppc/create
|
|
||||||
- - cloudbroker/kvmppc/createBlank
|
|
||||||
- - cloudbroker/kvmx86/create
|
|
||||||
- - cloudbroker/kvmx86/createBlank
|
|
||||||
|
|
||||||
- Added UpdatedBy field to task model in cloudbroker/task/get
|
|
||||||
|
|
||||||
- Made optional fields in requests:
|
|
||||||
- - Reason (cloudbroker/account/delete)
|
|
||||||
- - Reason (cloudbroker/account/restore)
|
|
||||||
- - Gateway (cloudbroker/extnet/create)
|
|
||||||
- - Reason (cloudbroker/image/delete)
|
|
||||||
- - Num (cloudapi/k8s/workerAdd)
|
|
||||||
- - NetID (cloudbroker/vins/extnetConnect)
|
|
||||||
|
|
||||||
- Updated cloudapi/rg/get model
|
|
||||||
|
|
||||||
- Deleted field Username from cloudbroker/account/update request
|
|
||||||
|
|
||||||
- Deleted field EmailAddress from cloudbroker/account/update request
|
|
||||||
|
|
||||||
- Added field DiskType to cloudbroker/compute/diskAttach request
|
|
||||||
|
|
||||||
- Added field Reason to cloudbroker/compute/diskQos request
|
|
||||||
|
|
||||||
- Added field Enabled to cloudbroker/compute/netAttach response model
|
|
||||||
|
|
||||||
- Added field CPUAllocationRatio to cloudbroker/image/listStacks response model
|
|
||||||
|
|
||||||
- Added field Descr to cloudbroker/image/listStacks response model
|
|
||||||
|
|
||||||
- Added field MemAllocationRatio to cloudbroker/image/listStacks response model
|
|
||||||
|
|
||||||
- Updated cloudapi/k8s/workersGroupByName response model
|
|
||||||
|
|
||||||
- Deleted field LBImageID from cloudbroker/k8ci/create request
|
|
||||||
|
|
||||||
- Deleted field ImageID from cloudbroker/lb/create request
|
|
||||||
|
|
||||||
- Deleted field Reason from cloudbroker/vins/extnetList request
|
|
||||||
|
|
||||||
- Added field CustomFields to cloudapi/kvmx86/create request
|
|
||||||
|
|
||||||
- Added field Driver to cloudapi/kvmx86/create request
|
|
||||||
|
|
||||||
- Added field Driver to cloudapi/kvmx86/createBlank request
|
|
||||||
|
|
||||||
### Bugfix
|
### Bugfix
|
||||||
- Changed the Excluded field type in cloudbroker/extnet/get response model
|
- Fix tag 'url' VINSID field in cloudbroker/account/list_vins
|
||||||
|
|
||||||
|
- Made the field Reason not required in cloudbroker/account/enable and cloudbroker/account/disable
|
||||||
|
|
||||||
|
- Made the field RecursiveDelete required in cloudbroker/account/deleteUser
|
||||||
|
|
||||||
|
- Add a validator function to a workersGroupName field - must be 3 or more symbol
|
||||||
|
|
||||||
|
- Add a token actuality check, add an error handler in client/client-transport and client/http-client
|
||||||
|
|
||||||
|
- Add a fields SEPID and Pool in ListRequest struct in cloudbroker/disks/list and cloudapi/disks/list
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"time"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
)
|
)
|
||||||
@@ -17,14 +18,21 @@ func NewLegacyHttpClient(cfg config.LegacyConfig) *http.Client {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var expiredTime time.Time
|
||||||
|
|
||||||
|
if cfg.Token != "" {
|
||||||
|
expiredTime = time.Now().AddDate(0, 0, 1)
|
||||||
|
}
|
||||||
|
|
||||||
return &http.Client{
|
return &http.Client{
|
||||||
Transport: &transportLegacy{
|
Transport: &transportLegacy{
|
||||||
base: transCfg,
|
base: transCfg,
|
||||||
username: url.QueryEscape(cfg.Username),
|
username: url.QueryEscape(cfg.Username),
|
||||||
password: url.QueryEscape(cfg.Password),
|
password: url.QueryEscape(cfg.Password),
|
||||||
retries: cfg.Retries,
|
retries: cfg.Retries,
|
||||||
token: cfg.Token,
|
token: cfg.Token,
|
||||||
decortURL: cfg.DecortURL,
|
decortURL: cfg.DecortURL,
|
||||||
|
expiryTime: expiredTime,
|
||||||
},
|
},
|
||||||
|
|
||||||
Timeout: cfg.Timeout.Get(),
|
Timeout: cfg.Timeout.Get(),
|
||||||
|
|||||||
@@ -9,16 +9,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type transportLegacy struct {
|
type transportLegacy struct {
|
||||||
base http.RoundTripper
|
base http.RoundTripper
|
||||||
username string
|
username string
|
||||||
password string
|
password string
|
||||||
retries uint64
|
retries uint64
|
||||||
token string
|
token string
|
||||||
decortURL string
|
decortURL string
|
||||||
|
expiryTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *transportLegacy) RoundTrip(request *http.Request) (*http.Response, error) {
|
func (t *transportLegacy) RoundTrip(request *http.Request) (*http.Response, error) {
|
||||||
if t.token == "" {
|
if t.token == "" || time.Now().After(t.expiryTime) {
|
||||||
body := fmt.Sprintf("username=%s&password=%s", t.username, t.password)
|
body := fmt.Sprintf("username=%s&password=%s", t.username, t.password)
|
||||||
bodyReader := strings.NewReader(body)
|
bodyReader := strings.NewReader(body)
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ func (t *transportLegacy) RoundTrip(request *http.Request) (*http.Response, erro
|
|||||||
|
|
||||||
token := string(tokenBytes)
|
token := string(tokenBytes)
|
||||||
t.token = token
|
t.token = token
|
||||||
|
t.expiryTime = time.Now().AddDate(0, 0, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenValue := fmt.Sprintf("&authkey=%s", t.token)
|
tokenValue := fmt.Sprintf("&authkey=%s", t.token)
|
||||||
@@ -63,7 +65,9 @@ func (t *transportLegacy) RoundTrip(request *http.Request) (*http.Response, erro
|
|||||||
err = fmt.Errorf("%s", respBytes)
|
err = fmt.Errorf("%s", respBytes)
|
||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||||
|
}
|
||||||
time.Sleep(time.Second * 5)
|
time.Sleep(time.Second * 5)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package validators
|
package validators
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-playground/validator/v10"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/go-playground/validator/v10"
|
||||||
)
|
)
|
||||||
|
|
||||||
// computeDriverValidator is used to validate Driver field in kvmx86/kvmppc create.
|
// computeDriverValidator is used to validate Driver field in kvmx86/kvmppc create.
|
||||||
@@ -263,3 +264,11 @@ func strictLooseValidator(fe validator.FieldLevel) bool {
|
|||||||
|
|
||||||
return StringInSlice(fieldValue, strictLooseValues)
|
return StringInSlice(fieldValue, strictLooseValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// name workerGroup must be more 3 symbol
|
||||||
|
func workerGroupNameValidator(fe validator.FieldLevel) bool {
|
||||||
|
fieldValue := fe.Field().String()
|
||||||
|
fieldValue = strings.Trim(fieldValue, " ")
|
||||||
|
|
||||||
|
return len(fieldValue) >= 3
|
||||||
|
}
|
||||||
|
|||||||
@@ -127,6 +127,12 @@ func errorMessage(fe validator.FieldError) string {
|
|||||||
fe.Field(),
|
fe.Field(),
|
||||||
joinValues(flipgroupClientTypeValues))
|
joinValues(flipgroupClientTypeValues))
|
||||||
|
|
||||||
|
// k8s Validators
|
||||||
|
case "workerGroupName":
|
||||||
|
return fmt.Sprintf("%s %s must be more 3 symbol",
|
||||||
|
prefix,
|
||||||
|
fe.Field())
|
||||||
|
|
||||||
// KVM_X86/KVM_PPC Validators
|
// KVM_X86/KVM_PPC Validators
|
||||||
case "kvmNetType":
|
case "kvmNetType":
|
||||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||||
|
|||||||
@@ -180,5 +180,10 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = validate.RegisterValidation("workerGroupName", workerGroupNameValidator)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||||
|
|
||||||
|
// Find by sep ID
|
||||||
|
// Required: false
|
||||||
|
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||||
|
|
||||||
|
// Find by pool name
|
||||||
|
// Required: false
|
||||||
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type CreateRequest struct {
|
|||||||
|
|
||||||
// Name for first worker group created with cluster
|
// Name for first worker group created with cluster
|
||||||
// Required: true
|
// Required: true
|
||||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required"`
|
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required,workerGroupName"`
|
||||||
|
|
||||||
// Network plugin
|
// Network plugin
|
||||||
// Must be one of these values: flannel, weawenet, calico
|
// Must be one of these values: flannel, weawenet, calico
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type DeleteUserRequest struct {
|
|||||||
|
|
||||||
// Recursively revoke access rights from owned cloudspaces and vmachines
|
// Recursively revoke access rights from owned cloudspaces and vmachines
|
||||||
// Required: false
|
// Required: false
|
||||||
RecursiveDelete bool `url:"recursivedelete,omitempty" json:"recursivedelete,omitempty"`
|
RecursiveDelete bool `url:"recursivedelete" json:"recursivedelete" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteUser revokes user access from the account
|
// DeleteUser revokes user access from the account
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type DisableRequest struct {
|
|||||||
|
|
||||||
// Reason to disable
|
// Reason to disable
|
||||||
// Required: true
|
// Required: true
|
||||||
Reason string `url:"reason" json:"reason" validate:"required"`
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable disables an account
|
// Disable disables an account
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type EnableRequest struct {
|
|||||||
|
|
||||||
// Reason to enable
|
// Reason to enable
|
||||||
// Required: true
|
// Required: true
|
||||||
Reason string `url:"reason" json:"reason" validate:"required"`
|
Reason string `url:"reason,omitempty" json:"reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable enables an account
|
// Enable enables an account
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ type ListVINSRequest struct {
|
|||||||
|
|
||||||
// Find by VINS ID
|
// Find by VINS ID
|
||||||
// Required: false
|
// Required: false
|
||||||
VINSID uint64 `url:"vins,omitempty" json:"vinsId,omitempty"`
|
VINSID uint64 `url:"vinsId,omitempty" json:"vinsId,omitempty"`
|
||||||
|
|
||||||
// Find by name
|
// Find by name
|
||||||
// Required: false
|
// Required: false
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ type ListRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||||
|
|
||||||
|
// Find by sep ID
|
||||||
|
// Required: false
|
||||||
|
SEPID uint64 `url:"sepId,omitempty" json:"sepId,omitempty"`
|
||||||
|
|
||||||
|
// Find by pool name
|
||||||
|
// Required: false
|
||||||
|
Pool string `url:"pool,omitempty" json:"pool,omitempty"`
|
||||||
|
|
||||||
// Page number
|
// Page number
|
||||||
// Required: false
|
// Required: false
|
||||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type CreateRequest struct {
|
|||||||
|
|
||||||
// Name for first worker group created with cluster
|
// Name for first worker group created with cluster
|
||||||
// Required: true
|
// Required: true
|
||||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required"`
|
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required, workerGroupName"`
|
||||||
|
|
||||||
// Network plugin
|
// Network plugin
|
||||||
// Must be one of these values: flunnel, weawenet, calico
|
// Must be one of these values: flunnel, weawenet, calico
|
||||||
|
|||||||
Reference in New Issue
Block a user