diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6f3996f..7f97c9f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,4 @@
-## Version 14.4.0
+## Version 14.5.0
Методы `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 и в следующих версиях будут удалены
@@ -9,26 +9,41 @@
### Добавлено
-#### image
-| Идентификатор
задачи | Описание |
-| --- | --- |
-| BGOS-812 | Методы `CreateMultiImage`, `MultiImageAddLinks`, `MultiImageDelLinks` и `MultiImageExport` в cloudbroker/image |
-| BGOS-812 | Структуры запросов `CreateMultiImageRequest`, `MultiImageAddLinksRequest`, `MultiImageDelLinksRequest` и `MultiImageExportRequest` в cloudbroker/image |
-| BGOS-813 | Вычисляемое поле `LinksTo` в структуры ответа `RecordImage` и `ItemImage` в cloudbroker/image и в структуру ответа `RecordImage` в cloudapi/image |
-
-### node
-| Идентификатор
задачи | Описание |
-| --- | --- |
-| BGOS-811 | Вычисляемое поле `ThreadCount` в структуру ответа `CpuInfo` в cloudbroker/node |
-
-### Изменено
-
#### compute
| Идентификатор
задачи | Описание |
| --- | --- |
-| BGOS-814 | Тип возвращаемого значения метода `CheckComputePlacement` с `map[string]CheckComputePlacementItem` на `map[uint64]CheckComputePlacementItem` в cloudbroker/compute |
+| BGOS-360 | Валидация поля `Label` в структуре запроса `SnapshotCreateRequest` в cloudapi/compute и cloudbroker/compute |
-#### rg
+#### image
| Идентификатор
задачи | Описание |
| --- | --- |
-| BGOS-815 | JSON-тэг у поля `RGID` в структуре ответа `ItemResourceConsumption` с `rgid` на `id` в cloudbroker/rg |
\ No newline at end of file
+| BGOS-820 | Обязательное поле `SEPID` в структуру запроса `MultiImageExportRequest` в cloudbroker/image |
+
+#### locations
+| Идентификатор
задачи | Описание |
+| --- | --- |
+| BGOS-823 | Вычисляемое поле `ZeroAccessEnabled` в структуру ответа `ItemLocation` в cloudapi/locations |
+
+#### resource_optimizer
+| Идентификатор
задачи | Описание |
+| --- | --- |
+| BGOS-818 | Группа методов `cloudbroker/resource_optimizer` для управления инструментом оптимизации ресурсов (DRS) |
+
+### zone
+| Идентификатор
задачи | Описание |
+| --- | --- |
+| BGOS-819 | Вычисляемые поля `DRS`, `DRSUID`, `AppID`, `DecortURL`, `DRSName` и `SSOURL` в структуру ответа `RecordZone` в cloudapi/zone и в cloudbroker/zone |
+| BGOS-819 | Структура ответа `ItemZone` в cloudapi/zone и в cloudbroker/zone |
+| BGOS-819 | Опциональное поле `DRS` в структуру запроса `CreateRequest` в cloudbroker/zone |
+
+### Изменено
+
+#### image
+| Идентификатор
задачи | Описание |
+| --- | --- |
+| BGOS-822 | Тип полей `HotResize` и `Bootable` в структуре запроса `EditRequest` с bool на interface в cloudbroker/image |
+
+#### node
+| Идентификатор
задачи | Описание |
+| --- | --- |
+| BGOS-821 | Тип вычисляемого поля `VCPU` с `uint64` на `float64` в структуре ответа `FreeResourcesInfo` в cloudbroker/node |
\ No newline at end of file
diff --git a/README.md b/README.md
index 3e67f73..88e8ae7 100644
--- a/README.md
+++ b/README.md
@@ -151,6 +151,7 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v14
- `PCIDevice` - управление устройствами;
- `Prometheus` - получение статистики prometheus;
- `Resmon` - получение статистики resource monitoring;
+- `ResourceOptimizer` - управление инструментом оптимизации ресурсов (DRS);
- `RG` - управление ресурсными группами аккаунта;
- `Security group` – управление группами безопасности;
- `SEP` - управление storage endpoint (sep);
@@ -356,6 +357,7 @@ func main() {
- `pkg/cloudbroker/pcidevice` - для `PCIDevice`
- `pkg/cloudbroker/prometheus` - для `Prometheus`
- `pkg/cloudbroker/resmon` - для `Resmon`
+ - `pkg/cloudbroker/resource_optimizer` - для `ResourceOptimizer`
- `pkg/cloudbroker/rg` - для `RG`
- `pkg/cloudbroker/secgroup` - для `Security group`
- `pkg/cloudbroker/sep` - для `SEP`
@@ -554,6 +556,7 @@ func main() {
- `.PCIDevice()` - для работы с `PCIDevice`
- `.Prometheus()` - для работы с `Prometheus`
- `.Resmon()` - для работы с `Resmon`
+ - `.ResourceOptimizer()` - для работы с `ResourceOptimizer`
- `.RG()` - для работы с `RG`
- `.SecurityGroup()` - для работы с `Security Group`
- `.SEP()` - для работы с `SEP`
@@ -1661,7 +1664,7 @@ func main() {
## Проверка соответствия версии платформы и версии dynamix
-С версии v1.11.0 для каждого клиента добавлен метод `Check` для проверки соответствия decort-sdk и платформы dynamix.
+С версии v11.0.0 для каждого клиента добавлен метод `Check` для проверки соответствия decort-sdk и платформы dynamix.
В случае соответсвия decort-sdk и платформы dynamix возвращается структура, содержащая информацию о версии и актуальном билде платформы.
#### Пример выполнения запроса
diff --git a/pkg/cloudapi/compute/snapshot_create.go b/pkg/cloudapi/compute/snapshot_create.go
index 99d7fe7..fe60897 100644
--- a/pkg/cloudapi/compute/snapshot_create.go
+++ b/pkg/cloudapi/compute/snapshot_create.go
@@ -16,8 +16,10 @@ type SnapshotCreateRequest struct {
// Text label for snapshot.
// Must be unique among this compute snapshots
+ // Allowed characters: a-z, 0-9, spaces, punctuation except '<' and '>'
+ // Maximum length: 36 characters
// Required: true
- Label string `url:"label" json:"label" validate:"required"`
+ Label string `url:"label" json:"label" validate:"required,max=36,excludesall=<>"`
}
// SnapshotCreate create compute snapshot
diff --git a/pkg/cloudapi/locations/models.go b/pkg/cloudapi/locations/models.go
index adc5ea6..42a0b24 100644
--- a/pkg/cloudapi/locations/models.go
+++ b/pkg/cloudapi/locations/models.go
@@ -34,6 +34,9 @@ type ItemLocation struct {
// Support of SDN
SDNSupport bool `json:"sdn_support"`
+
+ // Is Zero Access enabled
+ ZeroAccessEnabled bool `json:"zeroaccess_enabled"`
}
// List of locations
diff --git a/pkg/cloudapi/zone/filter.go b/pkg/cloudapi/zone/filter.go
index ec55a7a..365108c 100644
--- a/pkg/cloudapi/zone/filter.go
+++ b/pkg/cloudapi/zone/filter.go
@@ -2,7 +2,7 @@ package zone
// FilterByID returns ListZones with specified ID.
func (list ListZones) FilterByID(id uint64) ListZones {
- predicate := func(izone RecordZone) bool {
+ predicate := func(izone ItemZone) bool {
return izone.ID == id
}
@@ -11,7 +11,7 @@ func (list ListZones) FilterByID(id uint64) ListZones {
// FilterByName returns ListZones with specified Name.
func (list ListZones) FilterByName(name string) ListZones {
- predicate := func(izone RecordZone) bool {
+ predicate := func(izone ItemZone) bool {
return izone.Name == name
}
@@ -20,7 +20,7 @@ func (list ListZones) FilterByName(name string) ListZones {
// FilterByStatus returns ListZones with specified Status.
func (list ListZones) FilterByStatus(status string) ListZones {
- predicate := func(izone RecordZone) bool {
+ predicate := func(izone ItemZone) bool {
return izone.Status == status
}
@@ -28,7 +28,7 @@ func (list ListZones) FilterByStatus(status string) ListZones {
}
// FilterFunc allows filtering ListZones based on a user-specified predicate.
-func (list ListZones) FilterFunc(predicate func(RecordZone) bool) ListZones {
+func (list ListZones) FilterFunc(predicate func(ItemZone) bool) ListZones {
var result ListZones
for _, item := range list.Data {
@@ -42,11 +42,11 @@ func (list ListZones) FilterFunc(predicate func(RecordZone) bool) ListZones {
return result
}
-// FindOne returns first found RecordZone
+// FindOne returns first found ItemZone
// If none was found, returns an empty struct.
-func (list ListZones) FindOne() RecordZone {
+func (list ListZones) FindOne() ItemZone {
if list.EntryCount == 0 {
- return RecordZone{}
+ return ItemZone{}
}
return list.Data[0]
diff --git a/pkg/cloudapi/zone/filter_test.go b/pkg/cloudapi/zone/filter_test.go
index 5966796..973c638 100644
--- a/pkg/cloudapi/zone/filter_test.go
+++ b/pkg/cloudapi/zone/filter_test.go
@@ -3,7 +3,7 @@ package zone
import "testing"
var zones = ListZones{
- Data: []RecordZone{
+ Data: []ItemZone{
{
ID: 2,
@@ -76,7 +76,7 @@ func TestFilterByStatus(t *testing.T) {
}
func TestFilterFunc(t *testing.T) {
- actual := zones.FilterFunc(func(ien RecordZone) bool {
+ actual := zones.FilterFunc(func(ien ItemZone) bool {
return ien.Deletable == true
})
diff --git a/pkg/cloudapi/zone/models.go b/pkg/cloudapi/zone/models.go
index bbf5dda..25a6b19 100644
--- a/pkg/cloudapi/zone/models.go
+++ b/pkg/cloudapi/zone/models.go
@@ -5,7 +5,7 @@ type ListZones struct {
EntryCount uint64 `json:"entryCount"`
// Data
- Data []RecordZone `json:"data"`
+ Data []ItemZone `json:"data"`
}
// Detailed information about the zone record
@@ -63,4 +63,76 @@ type RecordZone struct {
// List of associated VINS IDs
VinsIDs []uint64 `json:"vinsIds"`
+
+ // DRS
+ DRS bool `json:"drs"`
+
+ // DRS UID
+ DRSUID string `json:"drs_uid"`
+
+ // App ID
+ AppID string `json:"app_id"`
+
+ // Decort URL
+ DecortURL string `json:"decort_url"`
+
+ // DRS Name
+ DRSName string `json:"drs_name"`
+
+ // SSO URL
+ SSOURL string `json:"sso_url"`
+}
+
+// A zone item from a list
+type ItemZone struct {
+ // App ID
+ AppID string `json:"app_id"`
+
+ // If true, all nodes belonging to the given zone will be marked for autostart
+ AutoStart bool `json:"autostart"`
+
+ // Created timestamp
+ CreatedTime uint64 `json:"createdTime"`
+
+ // Decort URL
+ DecortURL string `json:"decort_url"`
+
+ // Deletable flag
+ Deletable bool `json:"deletable"`
+
+ // Description
+ Description string `json:"description"`
+
+ // DRS
+ DRS bool `json:"drs"`
+
+ // DRS Name
+ DRSName string `json:"drs_name"`
+
+ // DRS UID
+ DRSUID string `json:"drs_uid"`
+
+ // GID
+ GID uint64 `json:"gid"`
+
+ // GUID
+ GUID uint64 `json:"guid"`
+
+ // ID
+ ID uint64 `json:"id"`
+
+ // Name
+ Name string `json:"name"`
+
+ // List of associated Node IDs
+ NodeIDs []uint64 `json:"nodeIds"`
+
+ // SSO URL
+ SSOURL string `json:"sso_url"`
+
+ // Status
+ Status string `json:"status"`
+
+ // Updated timestamp
+ UpdatedTime uint64 `json:"updatedTime"`
}
diff --git a/pkg/cloudbroker/compute/snapshot_create.go b/pkg/cloudbroker/compute/snapshot_create.go
index 454706e..24532e9 100644
--- a/pkg/cloudbroker/compute/snapshot_create.go
+++ b/pkg/cloudbroker/compute/snapshot_create.go
@@ -16,8 +16,10 @@ type SnapshotCreateRequest struct {
// Text label for snapshot.
// Must be unique among this compute snapshots
+ // Allowed characters: a-z, 0-9, spaces, punctuation except '<' and '>'
+ // Maximum length: 36 characters
// Required: true
- Label string `url:"label" json:"label" validate:"required"`
+ Label string `url:"label" json:"label" validate:"required,max=36,excludesall=<>"`
}
// SnapshotCreate creates compute snapshot
diff --git a/pkg/cloudbroker/image/edit.go b/pkg/cloudbroker/image/edit.go
index 4913aac..4c4f5a7 100644
--- a/pkg/cloudbroker/image/edit.go
+++ b/pkg/cloudbroker/image/edit.go
@@ -39,11 +39,11 @@ type EditRequest struct {
// Does this machine supports hot resize
// Required: false
- HotResize bool `url:"hotresize,omitempty" json:"hotresize,omitempty"`
+ HotResize interface{} `url:"hotresize,omitempty" json:"hotresize,omitempty" validate:"omitempty,isBool"`
// Does this image boot OS
// Required: false
- Bootable bool `url:"bootable,omitempty" json:"bootable,omitempty"`
+ Bootable interface{} `url:"bootable,omitempty" json:"bootable,omitempty" validate:"omitempty,isBool"`
}
// Edit edits an existing image
diff --git a/pkg/cloudbroker/image/multi_image_export.go b/pkg/cloudbroker/image/multi_image_export.go
index 7bbc0a3..9f8b233 100644
--- a/pkg/cloudbroker/image/multi_image_export.go
+++ b/pkg/cloudbroker/image/multi_image_export.go
@@ -17,6 +17,10 @@ type MultiImageExportRequest struct {
// Name of the target pool
// Required: true
PoolName string `url:"pool_name" json:"pool_name" validate:"required"`
+
+ // Target SEP ID
+ // Required: true
+ SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
}
// MultiImageExport copies a physical image from multi image to the specified pool
diff --git a/pkg/cloudbroker/node/models.go b/pkg/cloudbroker/node/models.go
index fde5f26..1185041 100644
--- a/pkg/cloudbroker/node/models.go
+++ b/pkg/cloudbroker/node/models.go
@@ -120,7 +120,7 @@ type FreeResourcesInfo struct {
RAM float64 `json:"RAM"`
// VCPU
- VCPU uint64 `json:"vCPUs"`
+ VCPU float64 `json:"vCPUs"`
}
// Resources Info
diff --git a/pkg/cloudbroker/resource_optimizer.go b/pkg/cloudbroker/resource_optimizer.go
new file mode 100644
index 0000000..19ea5f8
--- /dev/null
+++ b/pkg/cloudbroker/resource_optimizer.go
@@ -0,0 +1,10 @@
+package cloudbroker
+
+import (
+ "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/pkg/cloudbroker/resource_optimizer"
+)
+
+// Accessing the ResourceOptimizer method group
+func (cb *CloudBroker) ResourceOptimizer() *resource_optimizer.ResourceOptimizer {
+ return resource_optimizer.New(cb.client)
+}
diff --git a/pkg/cloudbroker/resource_optimizer/drs_add_nodes.go b/pkg/cloudbroker/resource_optimizer/drs_add_nodes.go
new file mode 100644
index 0000000..4379b53
--- /dev/null
+++ b/pkg/cloudbroker/resource_optimizer/drs_add_nodes.go
@@ -0,0 +1,42 @@
+package resource_optimizer
+
+import (
+ "context"
+ "net/http"
+ "strconv"
+
+ "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
+)
+
+// DRSAddNodesRequest struct to add nodes to DRS
+type DRSAddNodesRequest struct {
+ // ID of the zone
+ // Required: true
+ ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
+
+ // IDs of the nodes to add
+ // Required: true
+ NodeIDs []uint64 `url:"node_ids" json:"node_ids" validate:"required"`
+}
+
+// DRSAddNodes adds nodes to DRS in the specified zone
+func (ro ResourceOptimizer) DRSAddNodes(ctx context.Context, req DRSAddNodesRequest) (bool, error) {
+ err := validators.ValidateRequest(req)
+ if err != nil {
+ return false, validators.ValidationErrors(validators.GetErrors(err))
+ }
+
+ url := "/cloudbroker/resource_optimizer/drs_add_nodes"
+
+ res, err := ro.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
+}
diff --git a/pkg/cloudbroker/resource_optimizer/drs_create.go b/pkg/cloudbroker/resource_optimizer/drs_create.go
new file mode 100644
index 0000000..194d273
--- /dev/null
+++ b/pkg/cloudbroker/resource_optimizer/drs_create.go
@@ -0,0 +1,58 @@
+package resource_optimizer
+
+import (
+ "context"
+ "net/http"
+ "strconv"
+
+ "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
+)
+
+// DRSCreateRequest struct to create DRS
+type DRSCreateRequest struct {
+ // ID of the zone
+ // Required: true
+ ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
+
+ // Application ID
+ // Required: true
+ AppID string `url:"app_id" json:"app_id" validate:"required"`
+
+ // Application secret
+ // Required: true
+ AppSecret string `url:"app_secret" json:"app_secret" validate:"required"`
+
+ // Decort URL
+ // Required: true
+ DecortURL string `url:"decort_url" json:"decort_url" validate:"required"`
+
+ // SSO URL
+ // Required: true
+ SSOURL string `url:"sso_url" json:"sso_url" validate:"required"`
+
+ // DRS name
+ // Required: true
+ DRSName string `url:"drs_name" json:"drs_name" validate:"required"`
+}
+
+// DRSCreate creates a new DRS in the specified zone
+func (ro ResourceOptimizer) DRSCreate(ctx context.Context, req DRSCreateRequest) (bool, error) {
+ err := validators.ValidateRequest(req)
+ if err != nil {
+ return false, validators.ValidationErrors(validators.GetErrors(err))
+ }
+
+ url := "/cloudbroker/resource_optimizer/drs_create"
+
+ res, err := ro.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
+}
diff --git a/pkg/cloudbroker/resource_optimizer/drs_del_nodes.go b/pkg/cloudbroker/resource_optimizer/drs_del_nodes.go
new file mode 100644
index 0000000..bf1d7d3
--- /dev/null
+++ b/pkg/cloudbroker/resource_optimizer/drs_del_nodes.go
@@ -0,0 +1,42 @@
+package resource_optimizer
+
+import (
+ "context"
+ "net/http"
+ "strconv"
+
+ "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
+)
+
+// DRSDelNodesRequest struct to delete nodes from DRS
+type DRSDelNodesRequest struct {
+ // ID of the zone
+ // Required: true
+ ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
+
+ // IDs of the nodes to delete
+ // Required: true
+ NodeIDs []uint64 `url:"node_ids" json:"node_ids" validate:"required"`
+}
+
+// DRSDelNodes removes nodes from DRS in the specified zone
+func (ro ResourceOptimizer) DRSDelNodes(ctx context.Context, req DRSDelNodesRequest) (bool, error) {
+ err := validators.ValidateRequest(req)
+ if err != nil {
+ return false, validators.ValidationErrors(validators.GetErrors(err))
+ }
+
+ url := "/cloudbroker/resource_optimizer/drs_del_nodes"
+
+ res, err := ro.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
+}
diff --git a/pkg/cloudbroker/resource_optimizer/drs_remove.go b/pkg/cloudbroker/resource_optimizer/drs_remove.go
new file mode 100644
index 0000000..64d8f1f
--- /dev/null
+++ b/pkg/cloudbroker/resource_optimizer/drs_remove.go
@@ -0,0 +1,38 @@
+package resource_optimizer
+
+import (
+ "context"
+ "net/http"
+ "strconv"
+
+ "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
+)
+
+// DRSRemoveRequest struct to remove DRS
+type DRSRemoveRequest struct {
+ // ID of the zone
+ // Required: true
+ ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
+}
+
+// DRSRemove removes DRS from the specified zone
+func (ro ResourceOptimizer) DRSRemove(ctx context.Context, req DRSRemoveRequest) (bool, error) {
+ err := validators.ValidateRequest(req)
+ if err != nil {
+ return false, validators.ValidationErrors(validators.GetErrors(err))
+ }
+
+ url := "/cloudbroker/resource_optimizer/drs_remove"
+
+ res, err := ro.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
+}
diff --git a/pkg/cloudbroker/resource_optimizer/drs_start.go b/pkg/cloudbroker/resource_optimizer/drs_start.go
new file mode 100644
index 0000000..c0a249d
--- /dev/null
+++ b/pkg/cloudbroker/resource_optimizer/drs_start.go
@@ -0,0 +1,38 @@
+package resource_optimizer
+
+import (
+ "context"
+ "net/http"
+ "strconv"
+
+ "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
+)
+
+// DRSStartRequest struct to start DRS
+type DRSStartRequest struct {
+ // ID of the zone
+ // Required: true
+ ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
+}
+
+// DRSStart starts DRS in the specified zone
+func (ro ResourceOptimizer) DRSStart(ctx context.Context, req DRSStartRequest) (bool, error) {
+ err := validators.ValidateRequest(req)
+ if err != nil {
+ return false, validators.ValidationErrors(validators.GetErrors(err))
+ }
+
+ url := "/cloudbroker/resource_optimizer/drs_start"
+
+ res, err := ro.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
+}
diff --git a/pkg/cloudbroker/resource_optimizer/drs_stop.go b/pkg/cloudbroker/resource_optimizer/drs_stop.go
new file mode 100644
index 0000000..d0345b7
--- /dev/null
+++ b/pkg/cloudbroker/resource_optimizer/drs_stop.go
@@ -0,0 +1,38 @@
+package resource_optimizer
+
+import (
+ "context"
+ "net/http"
+ "strconv"
+
+ "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
+)
+
+// DRSStopRequest struct to stop DRS
+type DRSStopRequest struct {
+ // ID of the zone
+ // Required: true
+ ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
+}
+
+// DRSStop stops DRS in the specified zone
+func (ro ResourceOptimizer) DRSStop(ctx context.Context, req DRSStopRequest) (bool, error) {
+ err := validators.ValidateRequest(req)
+ if err != nil {
+ return false, validators.ValidationErrors(validators.GetErrors(err))
+ }
+
+ url := "/cloudbroker/resource_optimizer/drs_stop"
+
+ res, err := ro.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
+}
diff --git a/pkg/cloudbroker/resource_optimizer/drs_update.go b/pkg/cloudbroker/resource_optimizer/drs_update.go
new file mode 100644
index 0000000..06b8ee8
--- /dev/null
+++ b/pkg/cloudbroker/resource_optimizer/drs_update.go
@@ -0,0 +1,58 @@
+package resource_optimizer
+
+import (
+ "context"
+ "net/http"
+ "strconv"
+
+ "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/internal/validators"
+)
+
+// DRSUpdateRequest struct to update DRS
+type DRSUpdateRequest struct {
+ // ID of the zone
+ // Required: true
+ ZoneID uint64 `url:"zone_id" json:"zone_id" validate:"required"`
+
+ // Application ID
+ // Required: false
+ AppID string `url:"app_id,omitempty" json:"app_id,omitempty"`
+
+ // Application secret
+ // Required: false
+ AppSecret string `url:"app_secret,omitempty" json:"app_secret,omitempty"`
+
+ // Decort URL
+ // Required: false
+ DecortURL string `url:"decort_url,omitempty" json:"decort_url,omitempty"`
+
+ // SSO URL
+ // Required: false
+ SSOURL string `url:"sso_url,omitempty" json:"sso_url,omitempty"`
+
+ // DRS name
+ // Required: false
+ DRSName string `url:"drs_name,omitempty" json:"drs_name,omitempty"`
+}
+
+// DRSUpdate updates DRS configuration in the specified zone
+func (ro ResourceOptimizer) DRSUpdate(ctx context.Context, req DRSUpdateRequest) (bool, error) {
+ err := validators.ValidateRequest(req)
+ if err != nil {
+ return false, validators.ValidationErrors(validators.GetErrors(err))
+ }
+
+ url := "/cloudbroker/resource_optimizer/drs_update"
+
+ res, err := ro.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
+}
diff --git a/pkg/cloudbroker/resource_optimizer/resource_optimizer.go b/pkg/cloudbroker/resource_optimizer/resource_optimizer.go
new file mode 100644
index 0000000..cccdee8
--- /dev/null
+++ b/pkg/cloudbroker/resource_optimizer/resource_optimizer.go
@@ -0,0 +1,16 @@
+// API Actor API for managing resource optimizer
+package resource_optimizer
+
+import "repository.basistech.ru/BASIS/dynamix-golang-sdk/v14/interfaces"
+
+// Structure for creating request to resource_optimizer
+type ResourceOptimizer struct {
+ client interfaces.Caller
+}
+
+// Builder for resource_optimizer endpoints
+func New(client interfaces.Caller) *ResourceOptimizer {
+ return &ResourceOptimizer{
+ client: client,
+ }
+}
diff --git a/pkg/cloudbroker/zone/create.go b/pkg/cloudbroker/zone/create.go
index 6b1ec9b..8d97d29 100644
--- a/pkg/cloudbroker/zone/create.go
+++ b/pkg/cloudbroker/zone/create.go
@@ -21,6 +21,10 @@ type CreateRequest struct {
// If true, all nodes belonging to the given zone will be marked for autostart
// Required: false
AutoStart interface{} `url:"autostart,omitempty" json:"autostart,omitempty" validate:"omitempty,isBool"`
+
+ // Enables Distributed Resource Scheduler (DRS) functionality for the zone
+ // Required: false
+ DRS interface{} `url:"drs,omitempty" json:"drs,omitempty" validate:"omitempty,isBool"`
}
// Create creates zone object
diff --git a/pkg/cloudbroker/zone/filter.go b/pkg/cloudbroker/zone/filter.go
index ec55a7a..365108c 100644
--- a/pkg/cloudbroker/zone/filter.go
+++ b/pkg/cloudbroker/zone/filter.go
@@ -2,7 +2,7 @@ package zone
// FilterByID returns ListZones with specified ID.
func (list ListZones) FilterByID(id uint64) ListZones {
- predicate := func(izone RecordZone) bool {
+ predicate := func(izone ItemZone) bool {
return izone.ID == id
}
@@ -11,7 +11,7 @@ func (list ListZones) FilterByID(id uint64) ListZones {
// FilterByName returns ListZones with specified Name.
func (list ListZones) FilterByName(name string) ListZones {
- predicate := func(izone RecordZone) bool {
+ predicate := func(izone ItemZone) bool {
return izone.Name == name
}
@@ -20,7 +20,7 @@ func (list ListZones) FilterByName(name string) ListZones {
// FilterByStatus returns ListZones with specified Status.
func (list ListZones) FilterByStatus(status string) ListZones {
- predicate := func(izone RecordZone) bool {
+ predicate := func(izone ItemZone) bool {
return izone.Status == status
}
@@ -28,7 +28,7 @@ func (list ListZones) FilterByStatus(status string) ListZones {
}
// FilterFunc allows filtering ListZones based on a user-specified predicate.
-func (list ListZones) FilterFunc(predicate func(RecordZone) bool) ListZones {
+func (list ListZones) FilterFunc(predicate func(ItemZone) bool) ListZones {
var result ListZones
for _, item := range list.Data {
@@ -42,11 +42,11 @@ func (list ListZones) FilterFunc(predicate func(RecordZone) bool) ListZones {
return result
}
-// FindOne returns first found RecordZone
+// FindOne returns first found ItemZone
// If none was found, returns an empty struct.
-func (list ListZones) FindOne() RecordZone {
+func (list ListZones) FindOne() ItemZone {
if list.EntryCount == 0 {
- return RecordZone{}
+ return ItemZone{}
}
return list.Data[0]
diff --git a/pkg/cloudbroker/zone/filter_test.go b/pkg/cloudbroker/zone/filter_test.go
index 5966796..973c638 100644
--- a/pkg/cloudbroker/zone/filter_test.go
+++ b/pkg/cloudbroker/zone/filter_test.go
@@ -3,7 +3,7 @@ package zone
import "testing"
var zones = ListZones{
- Data: []RecordZone{
+ Data: []ItemZone{
{
ID: 2,
@@ -76,7 +76,7 @@ func TestFilterByStatus(t *testing.T) {
}
func TestFilterFunc(t *testing.T) {
- actual := zones.FilterFunc(func(ien RecordZone) bool {
+ actual := zones.FilterFunc(func(ien ItemZone) bool {
return ien.Deletable == true
})
diff --git a/pkg/cloudbroker/zone/models.go b/pkg/cloudbroker/zone/models.go
index 3c22c6b..ce35518 100644
--- a/pkg/cloudbroker/zone/models.go
+++ b/pkg/cloudbroker/zone/models.go
@@ -5,7 +5,7 @@ type ListZones struct {
EntryCount uint64 `json:"entryCount"`
// Data
- Data []RecordZone `json:"data"`
+ Data []ItemZone `json:"data"`
}
// Detailed information about the zone record
@@ -63,4 +63,76 @@ type RecordZone struct {
// List of associated VINS IDs
VinsIDs []uint64 `json:"vinsIds"`
+
+ // DRS
+ DRS bool `json:"drs"`
+
+ // DRS UID
+ DRSUID string `json:"drs_uid"`
+
+ // App ID
+ AppID string `json:"app_id"`
+
+ // Decort URL
+ DecortURL string `json:"decort_url"`
+
+ // DRS Name
+ DRSName string `json:"drs_name"`
+
+ // SSO URL
+ SSOURL string `json:"sso_url"`
+}
+
+// A zone item from a list
+type ItemZone struct {
+ // App ID
+ AppID string `json:"app_id"`
+
+ // If true, all nodes belonging to the given zone will be marked for autostart
+ AutoStart bool `json:"autostart"`
+
+ // Created timestamp
+ CreatedTime uint64 `json:"createdTime"`
+
+ // Decort URL
+ DecortURL string `json:"decort_url"`
+
+ // Deletable flag
+ Deletable bool `json:"deletable"`
+
+ // Description
+ Description string `json:"description"`
+
+ // DRS
+ DRS bool `json:"drs"`
+
+ // DRS Name
+ DRSName string `json:"drs_name"`
+
+ // DRS UID
+ DRSUID string `json:"drs_uid"`
+
+ // GID
+ GID uint64 `json:"gid"`
+
+ // GUID
+ GUID uint64 `json:"guid"`
+
+ // ID
+ ID uint64 `json:"id"`
+
+ // Name
+ Name string `json:"name"`
+
+ // List of associated Node IDs
+ NodeIDs []uint64 `json:"nodeIds"`
+
+ // SSO URL
+ SSOURL string `json:"sso_url"`
+
+ // Status
+ Status string `json:"status"`
+
+ // Updated timestamp
+ UpdatedTime uint64 `json:"updatedTime"`
}