Compare commits

...

1 Commits

Author SHA1 Message Date
dayterr
cd5d1c9d0b v1.15.2
v1.15.2
2026-06-19 16:40:41 +03:00
10 changed files with 72 additions and 48 deletions

View File

@@ -1,4 +1,4 @@
## Version 1.15.1 ## Version 1.15.2
Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и в следующих версиях будут удалены, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами Методы `Audits` в cloudapi/compute, cloudbroker/compute, cloudapi/account, cloudbroker/account, cloudapi/vins, cloudbroker/vins, cloudapi/rg и cloudbroker/rg стали deprecated и в следующих версиях будут удалены, вместо них необходимо использовать метод `List` в cloudapi/audit и cloudbroker/audit с соответствующими фильтрами
Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены Методы `AccessGrant`, `AccessGrantToPool`, `AccessRevoke`, `AccessRevokeToPool` в cloudbroker/sep стали deprecated и в следующих версиях будут удалены
@@ -7,52 +7,35 @@
Все методы группы `.SDN()` находятся в альфа-версии. Все методы группы `.SDN()` находятся в альфа-версии.
### Добавлено ### Добавлено
#### Общее #### image
| Идентификатор задачи | Описание | | Идентификатор задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-899 | Добавлена валидация полей `ssoUrl` и `decortUrl` в конфигах `Config`, `BVSConfig` и `LegacyConfig`, а также поля `domain` в конфиге `BVSConfig` при вызове конструкторов `New`, `NewBVS`, `NewLegacy` | | BGOS-916 | Вычисляемые поля `Compute` и `MemoryDumpImage` в структуру ответа `ItemSnapSet` в cloudapi/image |
#### kvmx86
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-903 | Структура ответа `MassCreateError` в cloudbroker/kvmx86 |
#### node #### node
| Идентификатор задачи | Описание | | Идентификатор задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-906 | Метод `Install` и структура запроса `InstallRequest` в cloudbroker/node | | BGOS-919 | Вычисляемое поле `MaxSupportedGeneration` в структуру ответа `CpuInfo` в cloudbroker/node |
#### zone #### zone
| Идентификатор задачи | Описание | | Идентификатор задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-902 | Вычисляемое поле `SupportedCpuModels` в структуру ответа `TestCPUAlignmentProfileResult` в cloudbroker/zone | | BGOS-914 | Вычисляемые поля `ID`, `Name` и `ConsumedBy` в структуру ответа `RecordConsumption` в cloudbroker/sep |
| BGOS-902 | Структура ответа `SupportedCpuModel` в cloudbroker/zone | | BGOS-914 | Структура ответа `ListConsumption` в cloudbroker/sep |
### Изменено ### Изменено
#### compute #### account
| Идентификатор задачи | Описание | | Идентификатор задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-905 | Тип полей `Login` и `Password` с опциональных на обязательные в структуре `OSUser` в cloudbroker/compute | | BGOS-918 | Тип обязательного поля `Ratio` с `float64` на `uint64` в структуре запроса `SetCPUAllocationRatioRequest` в cloudbroker/account |
#### zone #### SEP
| Идентификатор<br>задачи | Описание |
| --- | --- |
| BGOS-902 | Тип поля `Percentage` с `uint64` на `float64` в структуре ответа `CpuAlignmentProfileCandidate` в cloudbroker/zone |
#### SDN logicalports
| Идентификатор задачи | Описание | | Идентификатор задачи | Описание |
| --- | --- | | --- | --- |
| BGOS-907 | Тип поля `MAC` с опционального на обязательное в структуре `AddAddress` в sdn/logicalports | | BGOS-914 | Тип поля `SEPID` с обязательного на опциональный в структуре запроса `ConsumptionRequest` в cloudbroker/sep |
| BGOS-914 | Тип ответа метода `Consumption` с `RecordConsumption` на `ListConsumption` в cloudbroker/sep |
### Удалено
#### compute
| Идентификатор задачи | Описание |
| --- | --- |
| BGOS-904 | Опциональное поле `Force` из структуры запроса `MigrateRequest` в cloudbroker/compute |

View File

@@ -86,7 +86,7 @@ type ItemSnapshot struct {
// Compute info // Compute info
Compute RecordCompute `json:"compute"` Compute RecordCompute `json:"compute"`
// List disk ID // List of disk IDs
Disks []uint64 `json:"disks"` Disks []uint64 `json:"disks"`
// GUID // GUID
@@ -690,7 +690,10 @@ type ListOSUser []ItemOSUser
// Main information about snapsets // Main information about snapsets
type ItemSnapSet struct { type ItemSnapSet struct {
// List disk IDs // Compute info
Compute RecordCompute `json:"compute"`
// List disk ID
Disks []uint64 `json:"disks"` Disks []uint64 `json:"disks"`
// GUID // GUID
@@ -699,6 +702,9 @@ type ItemSnapSet struct {
// Label // Label
Label string `json:"label"` Label string `json:"label"`
// Memory dump image ID
MemoryDumpImage uint64 `json:"memory_dump_image"`
// Timestamp // Timestamp
Timestamp uint64 `json:"timestamp"` Timestamp uint64 `json:"timestamp"`
} }

View File

@@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"net/http" "net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
@@ -102,6 +103,6 @@ func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudapi/image/list" url := "/cloudapi/image/list"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req) res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
return res, err return res, err
} }

View File

@@ -16,7 +16,7 @@ type SetCPUAllocationRatioRequest struct {
// CPU allocation ratio, i.e. one pCPU = ratio*vCPU // CPU allocation ratio, i.e. one pCPU = ratio*vCPU
// Required: true // Required: true
Ratio float64 `url:"ratio" json:"ratio" validate:"required"` Ratio uint64 `url:"ratio" json:"ratio" validate:"required"`
} }
// SetCPUAllocationRatio sets CPU allocation ratio // SetCPUAllocationRatio sets CPU allocation ratio

View File

@@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"net/http" "net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators" "repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
) )
@@ -102,6 +103,6 @@ func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudbroker/image/list" url := "/cloudbroker/image/list"
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req) res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
return res, err return res, err
} }

View File

@@ -161,8 +161,11 @@ type CpuInfo struct {
// Flags // Flags
Flags []string `json:"flags"` Flags []string `json:"flags"`
// Mddel name // Model name
ModelName string `json:"model_name"` ModelName string `json:"model_name"`
// Max supported generation
MaxSupportedGeneration string `json:"max_supported_generation"`
} }
// Main information about node // Main information about node

View File

@@ -11,12 +11,12 @@ import (
// ConsumptionRequest struct to get consumption info // ConsumptionRequest struct to get consumption info
type ConsumptionRequest struct { type ConsumptionRequest struct {
// Storage endpoint provider ID // Storage endpoint provider ID
// Required: true // Required: false
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"` SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"`
} }
// Consumption gets SEP consumption info // Consumption gets SEP consumption info
func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*RecordConsumption, error) { func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*ListConsumption, error) {
err := validators.ValidateRequest(req) err := validators.ValidateRequest(req)
if err != nil { if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err)) return nil, validators.ValidationErrors(validators.GetErrors(err))
@@ -29,7 +29,7 @@ func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*RecordCo
return nil, err return nil, err
} }
info := RecordConsumption{} info := ListConsumption{}
err = json.Unmarshal(res, &info) err = json.Unmarshal(res, &info)
if err != nil { if err != nil {

View File

@@ -47,8 +47,22 @@ type ByPool struct {
UsageLimit uint64 `json:"usage_limit"` UsageLimit uint64 `json:"usage_limit"`
} }
// List of Resource groups
type ListConsumption struct {
// Data
Data []RecordConsumption `json:"data"`
// Enrtry count
EntryCount uint64 `json:"entryCount"`
}
// Main information about consumption // Main information about consumption
type RecordConsumption struct { type RecordConsumption struct {
// ID
ID uint64 `json:"id"`
// Name
Name string `json:"name"`
// By pool // By pool
ByPool map[string]ByPool `json:"byPool"` ByPool map[string]ByPool `json:"byPool"`
@@ -57,6 +71,9 @@ type RecordConsumption struct {
// Type // Type
Type string `json:"type"` Type string `json:"type"`
// Consumed by
ConsumedBy []uint64 `json:"consumedBy"`
} }
// Main information about URI // Main information about URI

View File

@@ -711,7 +711,7 @@ func TestGetListCloudbroker(t *testing.T) {
getResult("Node list", bytes, node_cb.ListNodes{}, t) getResult("Node list", bytes, node_cb.ListNodes{}, t)
// Get // Get
listNode, _ := client.CloudBroker().Node().List(context.Background(), node_cb.ListRequest{}) listNode, _ := client.CloudBroker().Node().List(context.Background(), node_cb.ListRequest{})
if len(listLB.Data) > 0 { if listNode != nil && len(listNode.Data) > 0 {
id := listNode.Data[0].ID id := listNode.Data[0].ID
bytes, err = client.CloudBroker().Node().GetRaw(context.Background(), node_cb.GetRequest{NID: id}) bytes, err = client.CloudBroker().Node().GetRaw(context.Background(), node_cb.GetRequest{NID: id})
if err != nil { if err != nil {
@@ -725,11 +725,11 @@ func TestGetListCloudbroker(t *testing.T) {
} }
getResult("Node get_network_info", bytes, node_cb.RecordNodeNetworkInfo{}, t) getResult("Node get_network_info", bytes, node_cb.RecordNodeNetworkInfo{}, t)
} else { } else {
t.Errorf("Can not test Node get because LB list is empty") t.Errorf("Can not test Node get because node list is empty")
} }
// Node GetPCIDevices // Node GetPCIDevices
if len(listNode.Data) > 0 { if listNode != nil && len(listNode.Data) > 0 {
id := listNode.Data[0].ID id := listNode.Data[0].ID
bytes, err = client.CloudBroker().Node().GetPCIDevicesRaw(context.Background(), node_cb.GetPCIDevicesRequest{NodeID: id}) bytes, err = client.CloudBroker().Node().GetPCIDevicesRaw(context.Background(), node_cb.GetPCIDevicesRequest{NodeID: id})
if err != nil { if err != nil {

View File

@@ -183,6 +183,9 @@ func GetMapFromBytes(bytes []byte) (map[string]interface{}, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(unmarshalSlice) == 0 {
return map[string]interface{}{}, nil
}
t, ok := unmarshalSlice[0].(map[string]interface{}) t, ok := unmarshalSlice[0].(map[string]interface{})
if !ok { if !ok {
return nil, err return nil, err
@@ -228,10 +231,20 @@ func getMapBytes(value map[string]interface{}) map[string]interface{} {
func GetMapFromStructure(structure any) map[string]interface{} { func GetMapFromStructure(structure any) map[string]interface{} {
typ := reflect.TypeOf(structure) typ := reflect.TypeOf(structure)
return getMapStruct(typ) for typ.Kind() == reflect.Slice || typ.Kind() == reflect.Ptr {
typ = typ.Elem()
}
return getMapStruct(typ, make(map[reflect.Type]bool))
} }
func getMapStruct(t reflect.Type) map[string]interface{} { func getMapStruct(t reflect.Type, visited map[reflect.Type]bool) map[string]interface{} {
if visited[t] {
return map[string]interface{}{}
}
visited[t] = true
defer func() { visited[t] = false }()
temporary := make(map[string]interface{}) temporary := make(map[string]interface{})
for i := 0; i < t.NumField(); i++ { for i := 0; i < t.NumField(); i++ {
tag := t.Field(i).Tag.Get("json") tag := t.Field(i).Tag.Get("json")
@@ -243,16 +256,16 @@ func getMapStruct(t reflect.Type) map[string]interface{} {
elem := t.Field(i).Type.Elem() elem := t.Field(i).Type.Elem()
switch elem.Kind() { switch elem.Kind() {
case reflect.Struct: case reflect.Struct:
temporary[tag] = getMapStruct(elem) temporary[tag] = getMapStruct(elem, visited)
default: default:
temporary[tag] = map[string]interface{}{} temporary[tag] = map[string]interface{}{}
} }
case reflect.Struct: case reflect.Struct:
if tag == "" { if tag == "" {
return getMapStruct(t.Field(i).Type) return getMapStruct(t.Field(i).Type, visited)
} else { } else {
temporary[tag] = getMapStruct(t.Field(i).Type) temporary[tag] = getMapStruct(t.Field(i).Type, visited)
} }
// в этом месте работает некорректно для вложенных структур без json тегов (scope - все в cloudbroker) // в этом месте работает некорректно для вложенных структур без json тегов (scope - все в cloudbroker)