Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d17241c460 |
34
CHANGELOG.md
34
CHANGELOG.md
@@ -1,4 +1,4 @@
|
|||||||
## Version 1.15.2
|
## Version 1.14.12
|
||||||
|
|
||||||
Методы `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,35 +7,9 @@
|
|||||||
|
|
||||||
Все методы группы `.SDN()` находятся в альфа-версии.
|
Все методы группы `.SDN()` находятся в альфа-версии.
|
||||||
|
|
||||||
|
### Исправлено
|
||||||
|
|
||||||
### Добавлено
|
#### sep
|
||||||
|
|
||||||
#### image
|
|
||||||
| Идентификатор задачи | Описание |
|
| Идентификатор задачи | Описание |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| BGOS-916 | Вычисляемые поля `Compute` и `MemoryDumpImage` в структуру ответа `ItemSnapSet` в cloudapi/image |
|
| BGOS-949 | Тип возвращаемого значения в методе `AddConsumerNodes` с `uint64` на `[]uint64` в cloudbroker/sep |
|
||||||
|
|
||||||
#### node
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-919 | Вычисляемое поле `MaxSupportedGeneration` в структуру ответа `CpuInfo` в cloudbroker/node |
|
|
||||||
|
|
||||||
#### zone
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-914 | Вычисляемые поля `ID`, `Name` и `ConsumedBy` в структуру ответа `RecordConsumption` в cloudbroker/sep |
|
|
||||||
| BGOS-914 | Структура ответа `ListConsumption` в cloudbroker/sep |
|
|
||||||
|
|
||||||
|
|
||||||
### Изменено
|
|
||||||
|
|
||||||
#### account
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-918 | Тип обязательного поля `Ratio` с `float64` на `uint64` в структуре запроса `SetCPUAllocationRatioRequest` в cloudbroker/account |
|
|
||||||
|
|
||||||
#### SEP
|
|
||||||
| Идентификатор задачи | Описание |
|
|
||||||
| --- | --- |
|
|
||||||
| BGOS-914 | Тип поля `SEPID` с обязательного на опциональный в структуре запроса `ConsumptionRequest` в cloudbroker/sep |
|
|
||||||
| BGOS-914 | Тип ответа метода `Consumption` с `RecordConsumption` на `ListConsumption` в cloudbroker/sep |
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ Decort SDK - это библиотека, написанная на языке G
|
|||||||
- Версия 1.12.х Decort-SDK соответствует 4.4.0 версии платформы
|
- Версия 1.12.х Decort-SDK соответствует 4.4.0 версии платформы
|
||||||
- Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы
|
- Версия 1.13.х Decort-SDK соответствует 4.5.0 версии платформы
|
||||||
- Версия 1.14.х Decort-SDK соответствует 4.6.0 версии платформы
|
- Версия 1.14.х Decort-SDK соответствует 4.6.0 версии платформы
|
||||||
- Версия 1.15.х Decort-SDK соответствует 4.7.0 версии платформы
|
|
||||||
|
|
||||||
## Оглавление
|
## Оглавление
|
||||||
|
|
||||||
@@ -571,6 +570,7 @@ func main() {
|
|||||||
- `.PCIDevice()` - для работы с `PCIDevice`
|
- `.PCIDevice()` - для работы с `PCIDevice`
|
||||||
- `.Prometheus()` - для работы с `Prometheus`
|
- `.Prometheus()` - для работы с `Prometheus`
|
||||||
- `.Resmon()` - для работы с `Resmon`
|
- `.Resmon()` - для работы с `Resmon`
|
||||||
|
- `.ResourceOptimizer()` - для работы с `ResourceOptimizer`
|
||||||
- `.RG()` - для работы с `RG`
|
- `.RG()` - для работы с `RG`
|
||||||
- `.SecurityGroup()` - для работы с `Security Group`
|
- `.SecurityGroup()` - для работы с `Security Group`
|
||||||
- `.SEP()` - для работы с `SEP`
|
- `.SEP()` - для работы с `SEP`
|
||||||
|
|||||||
@@ -36,10 +36,6 @@ type DecortClient struct {
|
|||||||
|
|
||||||
// Сlient builder
|
// Сlient builder
|
||||||
func New(cfg config.Config) *DecortClient {
|
func New(cfg config.Config) *DecortClient {
|
||||||
if err := validators.ValidateConfig(cfg); err != nil {
|
|
||||||
panic(validators.ValidationErrors(validators.GetErrors(err)))
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.Retries == 0 {
|
if cfg.Retries == 0 {
|
||||||
cfg.Retries = 5
|
cfg.Retries = 5
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
"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/pkg/cloudapi"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
|
||||||
@@ -39,10 +38,6 @@ type tokenJSON struct {
|
|||||||
|
|
||||||
// Сlient builder
|
// Сlient builder
|
||||||
func NewBVS(cfg config.BVSConfig) *BVSDecortClient {
|
func NewBVS(cfg config.BVSConfig) *BVSDecortClient {
|
||||||
if err := validators.ValidateConfig(cfg); err != nil {
|
|
||||||
panic(validators.ValidationErrors(validators.GetErrors(err)))
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.Retries == 0 {
|
if cfg.Retries == 0 {
|
||||||
cfg.Retries = 5
|
cfg.Retries = 5
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ var FileName = map[string]string{
|
|||||||
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
var K8sValues = []string{"labels", "taints", "annotations, additionalSANs"}
|
||||||
|
|
||||||
var VersionMap = map[string]string{
|
var VersionMap = map[string]string{
|
||||||
"4.7.0": "-",
|
|
||||||
"4.6.0": "-",
|
"4.6.0": "-",
|
||||||
"4.5.0": "-",
|
"4.5.0": "-",
|
||||||
"4.4.0": "-",
|
"4.4.0": "-",
|
||||||
|
|||||||
@@ -464,23 +464,3 @@ func sepTechStatusValidator(fe validator.FieldLevel) bool {
|
|||||||
|
|
||||||
return IsInSlice(fieldValue, sepTechStatusValues)
|
return IsInSlice(fieldValue, sepTechStatusValues)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pciDeviceHWPathValidator is used to validate PCI device hardware path fields (e.g. 0000:81:00.0)
|
|
||||||
func pciDeviceHWPathValidator(fe validator.FieldLevel) bool {
|
|
||||||
fieldValue := fe.Field().String()
|
|
||||||
|
|
||||||
ok, _ := regexp.MatchString(`^[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}\.[0-7]$`, fieldValue)
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// sepNameValidator is used to validate SEP name fields
|
|
||||||
func sepNameValidator(fe validator.FieldLevel) bool {
|
|
||||||
ok, _ := regexp.MatchString(`^[a-zA-Zа-яА-ЯёЁ0-9][a-zA-Zа-яА-ЯёЁ0-9_.\[\]()\-]*$`, fe.Field().String())
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|
||||||
// sepDescriptionValidator is used to validate SEP description fields
|
|
||||||
func sepDescriptionValidator(fe validator.FieldLevel) bool {
|
|
||||||
ok, _ := regexp.MatchString(`^[a-zA-Zа-яА-ЯёЁ0-9_.\[\]()\-]*$`, fe.Field().String())
|
|
||||||
return ok
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -306,20 +306,5 @@ func registerAllValidators(validate *validator.Validate) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = validate.RegisterValidation("pciDeviceHWPath", pciDeviceHWPathValidator)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = validate.RegisterValidation("sepName", sepNameValidator)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = validate.RegisterValidation("sepDescription", sepDescriptionValidator)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import (
|
|||||||
"github.com/google/go-querystring/query"
|
"github.com/google/go-querystring/query"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
"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/pkg/cloudapi"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/sdn"
|
||||||
@@ -33,10 +32,6 @@ type LegacyDecortClient struct {
|
|||||||
|
|
||||||
// Legacy client builder
|
// Legacy client builder
|
||||||
func NewLegacy(cfg config.LegacyConfig) *LegacyDecortClient {
|
func NewLegacy(cfg config.LegacyConfig) *LegacyDecortClient {
|
||||||
if err := validators.ValidateConfig(cfg); err != nil {
|
|
||||||
panic(validators.ValidationErrors(validators.GetErrors(err)))
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg.Retries == 0 {
|
if cfg.Retries == 0 {
|
||||||
cfg.Retries = 5
|
cfg.Retries = 5
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ type RecordAccount struct {
|
|||||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||||
|
|
||||||
// CPU allocation ratio
|
// CPU allocation ratio
|
||||||
CPUAllocationRatio uint64 `json:"cpu_allocation_ratio"`
|
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||||
|
|
||||||
// Created by
|
// Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|||||||
@@ -18,11 +18,6 @@ type AbortSharedSnapshotMergeRequest struct {
|
|||||||
Label string `url:"label" json:"label" validate:"required"`
|
Label string `url:"label" json:"label" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperAbortSharedSnapshotMergeRequest struct {
|
|
||||||
AbortSharedSnapshotMergeRequest
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// AbortSharedSnapshotMerge shared snapshots merge abort
|
// AbortSharedSnapshotMerge shared snapshots merge abort
|
||||||
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -30,36 +25,9 @@ func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSn
|
|||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperAbortSharedSnapshotMergeRequest{
|
|
||||||
AbortSharedSnapshotMergeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/abort_shared_snapshot_merge"
|
url := "/cloudapi/compute/abort_shared_snapshot_merge"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// AbortSharedSnapshotMergeAsync shared snapshots merge abort in async mode
|
|
||||||
func (c Compute) AbortSharedSnapshotMergeAsync(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperAbortSharedSnapshotMergeRequest{
|
|
||||||
AbortSharedSnapshotMergeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/abort_shared_snapshot_merge"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type CDEjectRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCDEjectRequest struct {
|
|
||||||
CDEjectRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CDEject eject CD image to compute's CD-ROM
|
// CDEject eject CD image to compute's CD-ROM
|
||||||
func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error) {
|
func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperCDEjectRequest{
|
|
||||||
CDEjectRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/cdEject"
|
url := "/cloudapi/compute/cdEject"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -44,28 +33,5 @@ func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CDEjectAsync ejects CD image to compute's CD-ROM with AsyncMode
|
|
||||||
func (c Compute) CDEjectAsync(ctx context.Context, req CDEjectRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCDEjectRequest{
|
|
||||||
CDEjectRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/cdEject"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type CDInsertRequest struct {
|
|||||||
CDROMID uint64 `url:"cdromId" json:"cdromId" validate:"required"`
|
CDROMID uint64 `url:"cdromId" json:"cdromId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCDInsertRequest struct {
|
|
||||||
CDInsertRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CDInsert insert new CD image to compute's CD-ROM
|
// CDInsert insert new CD image to compute's CD-ROM
|
||||||
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) {
|
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperCDInsertRequest{
|
|
||||||
CDInsertRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/cdInsert"
|
url := "/cloudapi/compute/cdInsert"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -48,28 +37,5 @@ func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CDInsertAsync inserts new CD image to compute's CD-ROM with AsyncMode
|
|
||||||
func (c Compute) CDInsertAsync(ctx context.Context, req CDInsertRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCDInsertRequest{
|
|
||||||
CDInsertRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/cdInsert"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -31,12 +31,6 @@ type ChangeIPRequest struct {
|
|||||||
IPAddr string `url:"ip_addr" json:"ip_addr" validate:"required"`
|
IPAddr string `url:"ip_addr" json:"ip_addr" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeIPRequest struct {
|
|
||||||
ChangeIPRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeIP change reserved IP for compute instance
|
// ChangeIP change reserved IP for compute instance
|
||||||
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
|
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -44,14 +38,9 @@ func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeIPRequest{
|
|
||||||
ChangeIPRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/changeIp"
|
url := "/cloudapi/compute/changeIp"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -63,25 +52,3 @@ func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeIPAsync change reserved IP for compute instance with AsyncMode
|
|
||||||
func (c Compute) ChangeIPAsync(ctx context.Context, req ChangeIPRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeIPRequest{
|
|
||||||
ChangeIPRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/changeIp"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChangeLinkStateRequest struct to change link state
|
// ChangeLinkStateRequest struct to change link state
|
||||||
@@ -24,12 +23,6 @@ type ChangeLinkStateRequest struct {
|
|||||||
State string `url:"state" json:"state" validate:"required,interfaceState"`
|
State string `url:"state" json:"state" validate:"required,interfaceState"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeLinkStateRequest struct {
|
|
||||||
ChangeLinkStateRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeLinkState changes the status link virtual of compute
|
// ChangeLinkState changes the status link virtual of compute
|
||||||
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
|
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -37,14 +30,9 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeLinkStateRequest{
|
|
||||||
ChangeLinkStateRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/changeLinkState"
|
url := "/cloudapi/compute/changeLinkState"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -53,28 +41,5 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeLinkStateAsync changes the status link virtual of compute with AsyncMode
|
|
||||||
func (c Compute) ChangeLinkStateAsync(ctx context.Context, req ChangeLinkStateRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeLinkStateRequest{
|
|
||||||
ChangeLinkStateRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/changeLinkState"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type ChangeMTURequest struct {
|
|||||||
MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"`
|
MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeMTURequest struct {
|
|
||||||
ChangeMTURequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeMTU change MTU for compute instance
|
// ChangeMTU change MTU for compute instance
|
||||||
func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) {
|
func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, err
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeMTURequest{
|
|
||||||
ChangeMTURequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/change_mtu"
|
url := "/cloudapi/compute/change_mtu"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, err
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeMTUAsync change MTU for compute instance with AsyncMode
|
|
||||||
func (c Compute) ChangeMTUAsync(ctx context.Context, req ChangeMTURequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeMTURequest{
|
|
||||||
ChangeMTURequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/change_mtu"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -27,12 +27,6 @@ type ChangeSecGroupsRequest struct {
|
|||||||
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeSecGroupsRequest struct {
|
|
||||||
ChangeSecGroupsRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeSecGroups changes security groups for compute
|
// ChangeSecGroups changes security groups for compute
|
||||||
func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) {
|
func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -40,14 +34,9 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeSecGroupsRequest{
|
|
||||||
ChangeSecGroupsRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/change_security_groups"
|
url := "/cloudapi/compute/change_security_groups"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -59,25 +48,3 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeSecGroupsAsync changes security groups for compute with AsyncMode
|
|
||||||
func (c Compute) ChangeSecGroupsAsync(ctx context.Context, req ChangeSecGroupsRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeSecGroupsRequest{
|
|
||||||
ChangeSecGroupsRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/change_security_groups"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -44,12 +44,6 @@ type CloneRequest struct {
|
|||||||
SEPID uint64 `url:"sep_id" json:"sep_id"`
|
SEPID uint64 `url:"sep_id" json:"sep_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCloneRequest struct {
|
|
||||||
CloneRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clone clones compute instance
|
// Clone clones compute instance
|
||||||
func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
|
func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -57,36 +51,9 @@ func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
|
|||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperCloneRequest{
|
|
||||||
CloneRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/clone"
|
url := "/cloudapi/compute/clone"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CloneAsync clones compute instance with AsyncMode
|
|
||||||
func (c Compute) CloneAsync(ctx context.Context, req CloneRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCloneRequest{
|
|
||||||
CloneRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/clone"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DeleteRequest struct {
|
|||||||
DetachDisks bool `url:"detachDisks,omitempty" json:"detachDisks,omitempty"`
|
DetachDisks bool `url:"detachDisks,omitempty" json:"detachDisks,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDeleteRequest struct {
|
|
||||||
DeleteRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete deletes compute
|
// Delete deletes compute
|
||||||
func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDeleteRequest{
|
|
||||||
DeleteRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/delete"
|
url := "/cloudapi/compute/delete"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteAsync deletes compute with AsyncMode
|
|
||||||
func (c Compute) DeleteAsync(ctx context.Context, req DeleteRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDeleteRequest{
|
|
||||||
DeleteRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/delete"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
package compute
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DeleteCPUAlignmentProfileRequest struct to delete CPU alignment profile for computes
|
|
||||||
type DeleteCPUAlignmentProfileRequest struct {
|
|
||||||
// IDs of the compute instances
|
|
||||||
// Required: true
|
|
||||||
ComputeIDs []uint64 `url:"compute_ids" json:"compute_ids" validate:"min=1"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCPUAlignmentProfile deletes CPU alignment profile for computes
|
|
||||||
func (c Compute) DeleteCPUAlignmentProfile(ctx context.Context, req DeleteCPUAlignmentProfileRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/delete_cpu_alignment_profile"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -15,12 +15,6 @@ type DisableRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDisableRequest struct {
|
|
||||||
DisableRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable disables compute
|
// Disable disables compute
|
||||||
func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDisableRequest{
|
|
||||||
DisableRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/disable"
|
url := "/cloudapi/compute/disable"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableAsync disables compute with AsyncMode
|
|
||||||
func (c Compute) DisableAsync(ctx context.Context, req DisableRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDisableRequest{
|
|
||||||
DisableRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/disable"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -51,16 +51,6 @@ type DiskAddRequest struct {
|
|||||||
// Desired bus number (hex string, e.g. "0x03")
|
// Desired bus number (hex string, e.g. "0x03")
|
||||||
// Required: false
|
// Required: false
|
||||||
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
||||||
|
|
||||||
// Mount disk in read-only mode
|
|
||||||
// Required: false
|
|
||||||
ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperDiskAddRequest struct {
|
|
||||||
DiskAddRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAdd creates new disk and attach to compute
|
// DiskAdd creates new disk and attach to compute
|
||||||
@@ -70,14 +60,9 @@ func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error
|
|||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAddRequest{
|
|
||||||
DiskAddRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskAdd"
|
url := "/cloudapi/compute/diskAdd"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@@ -89,25 +74,3 @@ func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAddAsync creates new disk and attach to compute with AsyncMode
|
|
||||||
func (c Compute) DiskAddAsync(ctx context.Context, req DiskAddRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAddRequest{
|
|
||||||
DiskAddRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskAdd"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -25,16 +25,6 @@ type DiskAttachRequest struct {
|
|||||||
// Desired bus number (hex string, e.g. "0x03")
|
// Desired bus number (hex string, e.g. "0x03")
|
||||||
// Required: false
|
// Required: false
|
||||||
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
||||||
|
|
||||||
// Mount disk in read-only mode
|
|
||||||
// Required: false
|
|
||||||
ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperDiskAttachRequest struct {
|
|
||||||
DiskAttachRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAttach attach disk to compute
|
// DiskAttach attach disk to compute
|
||||||
@@ -44,14 +34,9 @@ func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAttachRequest{
|
|
||||||
DiskAttachRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskAttach"
|
url := "/cloudapi/compute/diskAttach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -63,25 +48,3 @@ func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAttachAsync attaches disk to compute with AsyncMode
|
|
||||||
func (c Compute) DiskAttachAsync(ctx context.Context, req DiskAttachRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAttachRequest{
|
|
||||||
DiskAttachRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskAttach"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskDelRequest struct {
|
|||||||
Permanently bool `url:"permanently" json:"permanently"`
|
Permanently bool `url:"permanently" json:"permanently"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskDelRequest struct {
|
|
||||||
DiskDelRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskDel delete disk and detach from compute
|
// DiskDel delete disk and detach from compute
|
||||||
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) {
|
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDelRequest{
|
|
||||||
DiskDelRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskDel"
|
url := "/cloudapi/compute/diskDel"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskDelAsync deletes disk and detaches from compute with AsyncMode
|
|
||||||
func (c Compute) DiskDelAsync(ctx context.Context, req DiskDelRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDelRequest{
|
|
||||||
DiskDelRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskDel"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type DiskDetachRequest struct {
|
|||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskDetachRequest struct {
|
|
||||||
DiskDetachRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskDetach detach disk from compute
|
// DiskDetach detach disk from compute
|
||||||
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) {
|
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDetachRequest{
|
|
||||||
DiskDetachRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskDetach"
|
url := "/cloudapi/compute/diskDetach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskDetachAsync detaches disk from compute with AsyncMode
|
|
||||||
func (c Compute) DiskDetachAsync(ctx context.Context, req DiskDetachRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDetachRequest{
|
|
||||||
DiskDetachRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskDetach"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskQOSRequest struct {
|
|||||||
Limits string `url:"limits" json:"limits" validate:"required"`
|
Limits string `url:"limits" json:"limits" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskQOSRequest struct {
|
|
||||||
DiskQOSRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskQOS change QoS of the disk
|
// DiskQOS change QoS of the disk
|
||||||
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
|
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskQOSRequest{
|
|
||||||
DiskQOSRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskQos"
|
url := "/cloudapi/compute/diskQos"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskQOSAsync changes QoS of the disk with AsyncMode
|
|
||||||
func (c Compute) DiskQOSAsync(ctx context.Context, req DiskQOSRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskQOSRequest{
|
|
||||||
DiskQOSRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskQos"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskResizeRequest struct {
|
|||||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskResizeRequest struct {
|
|
||||||
DiskResizeRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskResize change disk size
|
// DiskResize change disk size
|
||||||
func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, error) {
|
func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskResizeRequest{
|
|
||||||
DiskResizeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskResize"
|
url := "/cloudapi/compute/diskResize"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskResizeAsync changes disk size with AsyncMode
|
|
||||||
func (c Compute) DiskResizeAsync(ctx context.Context, req DiskResizeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskResizeRequest{
|
|
||||||
DiskResizeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskResize"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskSwitchToReplicationRequest struct {
|
|||||||
StopReplication bool `url:"stopReplication" json:"stopReplication"`
|
StopReplication bool `url:"stopReplication" json:"stopReplication"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskSwitchToReplicationRequest struct {
|
|
||||||
DiskSwitchToReplicationRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskSwitchToReplication switches disk to it's replication
|
// DiskSwitchToReplication switches disk to it's replication
|
||||||
func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToReplicationRequest) (bool, error) {
|
func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToReplicationRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToRe
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskSwitchToReplicationRequest{
|
|
||||||
DiskSwitchToReplicationRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskSwitchToReplication"
|
url := "/cloudapi/compute/diskSwitchToReplication"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToRe
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskSwitchToReplicationAsync switches disk to it's replication with AsyncMode
|
|
||||||
func (c Compute) DiskSwitchToReplicationAsync(ctx context.Context, req DiskSwitchToReplicationRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskSwitchToReplicationRequest{
|
|
||||||
DiskSwitchToReplicationRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/diskSwitchToReplication"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
package compute
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetCPUAlignmentProfileRequest struct to get CPU alignment profile for compute
|
|
||||||
type GetCPUAlignmentProfileRequest struct {
|
|
||||||
// ID of the compute instance
|
|
||||||
// Required: true
|
|
||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCPUAlignmentProfile gets CPU alignment profile for compute
|
|
||||||
func (c Compute) GetCPUAlignmentProfile(ctx context.Context, req GetCPUAlignmentProfileRequest) (*CPUAlignmentProfile, error) {
|
|
||||||
res, err := c.GetCPUAlignmentProfileRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := CPUAlignmentProfile{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCPUAlignmentProfileRaw gets CPU alignment profile for compute as an array of bytes
|
|
||||||
func (c Compute) GetCPUAlignmentProfileRaw(ctx context.Context, req GetCPUAlignmentProfileRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/get_cpu_alignment_profile"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@@ -15,12 +15,6 @@ type GuestAgentDisableRequest struct {
|
|||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentDisableRequest struct {
|
|
||||||
GuestAgentDisableRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable guest agent at a specific compute
|
// Disable guest agent at a specific compute
|
||||||
func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) {
|
func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableReq
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentDisableRequest{
|
|
||||||
GuestAgentDisableRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_disable"
|
url := "/cloudapi/compute/guest_agent_disable"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableReq
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentDisableAsync disables guest agent at a specific compute with AsyncMode
|
|
||||||
func (c Compute) GuestAgentDisableAsync(ctx context.Context, req GuestAgentDisableRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentDisableRequest{
|
|
||||||
GuestAgentDisableRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_disable"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type GuestAgentEnableRequest struct {
|
|||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentEnableRequest struct {
|
|
||||||
GuestAgentEnableRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable guest agent at a specific compute
|
// Enable guest agent at a specific compute
|
||||||
func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) {
|
func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableReque
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentEnableRequest{
|
|
||||||
GuestAgentEnableRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_enable"
|
url := "/cloudapi/compute/guest_agent_enable"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableReque
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentEnableAsync enables guest agent at a specific compute with AsyncMode
|
|
||||||
func (c Compute) GuestAgentEnableAsync(ctx context.Context, req GuestAgentEnableRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentEnableRequest{
|
|
||||||
GuestAgentEnableRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_enable"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type GuestAgentExecuteRequest struct {
|
|||||||
Arguments string `url:"arguments" json:"arguments" validate:"required"`
|
Arguments string `url:"arguments" json:"arguments" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentExecuteRequest struct {
|
|
||||||
GuestAgentExecuteRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute guest agent command
|
// Execute guest agent command
|
||||||
func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) {
|
func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
|
|||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentExecuteRequest{
|
|
||||||
GuestAgentExecuteRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_execute"
|
url := "/cloudapi/compute/guest_agent_execute"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -57,25 +46,3 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentExecuteRequestAsync executes guest agent command with AsyncMode
|
|
||||||
func (c Compute) GuestAgentExecuteRequestAsync(ctx context.Context, req GuestAgentExecuteRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentExecuteRequest{
|
|
||||||
GuestAgentExecuteRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_execute"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type GuestAgentFeatureUpdateRequest struct {
|
|||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentFeatureUpdateRequest struct {
|
|
||||||
GuestAgentFeatureUpdateRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Feature update guest agent
|
// Feature update guest agent
|
||||||
func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) {
|
func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeat
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentFeatureUpdateRequest{
|
|
||||||
GuestAgentFeatureUpdateRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_feature_update"
|
url := "/cloudapi/compute/guest_agent_feature_update"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeat
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentFeatureUpdateAsync feature updates guest agent with AsyncMode
|
|
||||||
func (c Compute) GuestAgentFeatureUpdateAsync(ctx context.Context, req GuestAgentFeatureUpdateRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentFeatureUpdateRequest{
|
|
||||||
GuestAgentFeatureUpdateRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/guest_agent_feature_update"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type MigrateToZoneRequest struct {
|
|||||||
ZoneID uint64 `url:"zoneId" json:"zoneId " validate:"required"`
|
ZoneID uint64 `url:"zoneId" json:"zoneId " validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMigrateToZoneRequest struct {
|
|
||||||
MigrateToZoneRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MoveToRG moves compute instance to new resource group
|
// MoveToRG moves compute instance to new resource group
|
||||||
func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (b
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateToZoneRequest{
|
|
||||||
MigrateToZoneRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/migrateToZone"
|
url := "/cloudapi/compute/migrateToZone"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (b
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MigrateToZoneAsync moves compute to another zone with AsyncMode
|
|
||||||
func (c Compute) MigrateToZoneAsync(ctx context.Context, req MigrateToZoneRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateToZoneRequest{
|
|
||||||
MigrateToZoneRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/migrateToZone"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -83,10 +83,7 @@ type ListUsageSnapshots []ItemUsageSnapshot
|
|||||||
|
|
||||||
// Main information about snapshot
|
// Main information about snapshot
|
||||||
type ItemSnapshot struct {
|
type ItemSnapshot struct {
|
||||||
// Compute info
|
// List disk ID
|
||||||
Compute RecordCompute `json:"compute"`
|
|
||||||
|
|
||||||
// List of disk IDs
|
|
||||||
Disks []uint64 `json:"disks"`
|
Disks []uint64 `json:"disks"`
|
||||||
|
|
||||||
// GUID
|
// GUID
|
||||||
@@ -95,9 +92,6 @@ type ItemSnapshot 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"`
|
||||||
}
|
}
|
||||||
@@ -362,9 +356,6 @@ type RecordCompute struct {
|
|||||||
// List clone IDs
|
// List clone IDs
|
||||||
Clones []uint64 `json:"clones"`
|
Clones []uint64 `json:"clones"`
|
||||||
|
|
||||||
// Clock
|
|
||||||
Clock string `json:"clock"`
|
|
||||||
|
|
||||||
// Compute CI ID
|
// Compute CI ID
|
||||||
ComputeCIID uint64 `json:"computeciId"`
|
ComputeCIID uint64 `json:"computeciId"`
|
||||||
|
|
||||||
@@ -491,9 +482,6 @@ type RecordCompute struct {
|
|||||||
// PreferredCPU
|
// PreferredCPU
|
||||||
PreferredCPU []int64 `json:"preferredCpu"`
|
PreferredCPU []int64 `json:"preferredCpu"`
|
||||||
|
|
||||||
// CPU alignment profile
|
|
||||||
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
|
|
||||||
|
|
||||||
// Qemu_quest
|
// Qemu_quest
|
||||||
QemuQuest QemuQuest `json:"qemu_guest"`
|
QemuQuest QemuQuest `json:"qemu_guest"`
|
||||||
|
|
||||||
@@ -564,7 +552,6 @@ type RecordCompute struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `json:"zoneId"`
|
ZoneID uint64 `json:"zoneId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LoaderMetaIso struct {
|
type LoaderMetaIso struct {
|
||||||
// Name
|
// Name
|
||||||
DeviceName string `json:"devicename"`
|
DeviceName string `json:"devicename"`
|
||||||
@@ -581,12 +568,6 @@ type QemuQuest struct {
|
|||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CPUAlignmentProfile struct {
|
|
||||||
Model string `json:"model"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Vendor string `json:"vendor"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type VGPUItem struct {
|
type VGPUItem struct {
|
||||||
// ID
|
// ID
|
||||||
ID uint64 `json:"id"`
|
ID uint64 `json:"id"`
|
||||||
@@ -690,10 +671,7 @@ type ListOSUser []ItemOSUser
|
|||||||
|
|
||||||
// Main information about snapsets
|
// Main information about snapsets
|
||||||
type ItemSnapSet struct {
|
type ItemSnapSet struct {
|
||||||
// Compute info
|
// List disk IDs
|
||||||
Compute RecordCompute `json:"compute"`
|
|
||||||
|
|
||||||
// List disk ID
|
|
||||||
Disks []uint64 `json:"disks"`
|
Disks []uint64 `json:"disks"`
|
||||||
|
|
||||||
// GUID
|
// GUID
|
||||||
@@ -702,9 +680,6 @@ 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"`
|
||||||
}
|
}
|
||||||
@@ -817,8 +792,8 @@ type ItemComputeDisk struct {
|
|||||||
// Account ID
|
// Account ID
|
||||||
AccountID uint64 `json:"accountId"`
|
AccountID uint64 `json:"accountId"`
|
||||||
|
|
||||||
// Discard
|
// BLK Discard
|
||||||
Discard string `json:"discard"`
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
// Block Size
|
// Block Size
|
||||||
BlockSize string `json:"block_size"`
|
BlockSize string `json:"block_size"`
|
||||||
@@ -963,9 +938,6 @@ type ItemComputeDisk struct {
|
|||||||
|
|
||||||
// UpdatedTime
|
// UpdatedTime
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
// Read-only
|
|
||||||
ReadOnly bool `json:"read_only"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ItemReplication struct {
|
type ItemReplication struct {
|
||||||
@@ -1107,9 +1079,6 @@ type ItemCompute struct {
|
|||||||
// Clone reference
|
// Clone reference
|
||||||
CloneReference uint64 `json:"cloneReference"`
|
CloneReference uint64 `json:"cloneReference"`
|
||||||
|
|
||||||
// Clock
|
|
||||||
Clock string `json:"clock"`
|
|
||||||
|
|
||||||
// List clone IDs
|
// List clone IDs
|
||||||
Clones []uint64 `json:"clones"`
|
Clones []uint64 `json:"clones"`
|
||||||
|
|
||||||
@@ -1215,9 +1184,6 @@ type ItemCompute struct {
|
|||||||
// Name of OS
|
// Name of OS
|
||||||
OSVersion string `json:"os_version"`
|
OSVersion string `json:"os_version"`
|
||||||
|
|
||||||
// CPU alignment profile
|
|
||||||
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
|
|
||||||
|
|
||||||
// Qemu_quest
|
// Qemu_quest
|
||||||
QemuQuest QemuQuest `json:"qemu_guest"`
|
QemuQuest QemuQuest `json:"qemu_guest"`
|
||||||
|
|
||||||
@@ -1295,9 +1261,6 @@ type InfoDisk struct {
|
|||||||
|
|
||||||
// SEP ID
|
// SEP ID
|
||||||
SepID int64 `json:"sepId"`
|
SepID int64 `json:"sepId"`
|
||||||
|
|
||||||
// Read-only
|
|
||||||
ReadOnly bool `json:"read_only"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List information about computes
|
// List information about computes
|
||||||
|
|||||||
@@ -34,12 +34,6 @@ type MoveToRGRequest struct {
|
|||||||
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMoveToRGRequest struct {
|
|
||||||
MoveToRGRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MoveToRG moves compute instance to new resource group
|
// MoveToRG moves compute instance to new resource group
|
||||||
func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error) {
|
func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -47,14 +41,9 @@ func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMoveToRGRequest{
|
|
||||||
MoveToRGRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/moveToRg"
|
url := "/cloudapi/compute/moveToRg"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -66,25 +55,3 @@ func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MoveToRGAsync moves compute instance to new resource group with AsyncMode
|
|
||||||
func (c Compute) MoveToRGAsync(ctx context.Context, req MoveToRGRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMoveToRGRequest{
|
|
||||||
MoveToRGRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/moveToRg"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ type NetAttachRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||||
|
|
||||||
// SDN Object Group IDs
|
// SDN Object Group ID
|
||||||
// Required: false
|
// Required: false
|
||||||
SDNObjectGroupIDs []string `url:"sdn_object_group_ids,omitempty" json:"sdn_object_group_ids,omitempty"`
|
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
|
||||||
|
|
||||||
// SDN Logical Port Display Name
|
// SDN Logical Port Display Name
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -83,12 +83,6 @@ type NetAttachRequest struct {
|
|||||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperNetAttachRequest struct {
|
|
||||||
NetAttachRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NetAttach attaches network to compute and gets info about network
|
// NetAttach attaches network to compute and gets info about network
|
||||||
func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNetAttach, error) {
|
func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNetAttach, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -96,14 +90,9 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
|
|||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperNetAttachRequest{
|
|
||||||
NetAttachRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/netAttach"
|
url := "/cloudapi/compute/netAttach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -117,25 +106,3 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetAttachAsync attaches network to compute with AsyncMode
|
|
||||||
func (c Compute) NetAttachAsync(ctx context.Context, req NetAttachRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperNetAttachRequest{
|
|
||||||
NetAttachRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/netAttach"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type NetDetachRequest struct {
|
|||||||
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
|
MAC string `url:"mac,omitempty" json:"mac,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperNetDetachRequest struct {
|
|
||||||
NetDetachRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NetDetach detaches network from compute
|
// NetDetach detaches network from compute
|
||||||
func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, error) {
|
func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, err
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperNetDetachRequest{
|
|
||||||
NetDetachRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/netDetach"
|
url := "/cloudapi/compute/netDetach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) NetDetach(ctx context.Context, req NetDetachRequest) (bool, err
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetDetachAsync detaches network from compute with AsyncMode
|
|
||||||
func (c Compute) NetDetachAsync(ctx context.Context, req NetDetachRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperNetDetachRequest{
|
|
||||||
NetDetachRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/netDetach"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type PauseRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperPauseRequest struct {
|
|
||||||
PauseRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pause pause compute
|
// Pause pause compute
|
||||||
func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
|
func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperPauseRequest{
|
|
||||||
PauseRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pause"
|
url := "/cloudapi/compute/pause"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) Pause(ctx context.Context, req PauseRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PauseAsync pauses compute with AsyncMode
|
|
||||||
func (c Compute) PauseAsync(ctx context.Context, req PauseRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperPauseRequest{
|
|
||||||
PauseRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pause"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -33,12 +33,6 @@ type PFWAddRequest struct {
|
|||||||
Proto string `url:"proto" json:"proto" validate:"proto"`
|
Proto string `url:"proto" json:"proto" validate:"proto"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperPFWAddRequest struct {
|
|
||||||
PFWAddRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PFWAdd add port forward rule
|
// PFWAdd add port forward rule
|
||||||
func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error) {
|
func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -46,14 +40,9 @@ func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error)
|
|||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperPFWAddRequest{
|
|
||||||
PFWAddRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pfwAdd"
|
url := "/cloudapi/compute/pfwAdd"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@@ -65,25 +54,3 @@ func (c Compute) PFWAdd(ctx context.Context, req PFWAddRequest) (uint64, error)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PFWAddAsync adds port forward rule with AsyncMode
|
|
||||||
func (c Compute) PFWAddAsync(ctx context.Context, req PFWAddRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperPFWAddRequest{
|
|
||||||
PFWAddRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pfwAdd"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -36,12 +36,6 @@ type PFWDelRequest struct {
|
|||||||
Proto string `url:"proto,omitempty" json:"proto,omitempty"`
|
Proto string `url:"proto,omitempty" json:"proto,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperPFWDelRequest struct {
|
|
||||||
PFWDelRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PFWDel deletes port forward rule
|
// PFWDel deletes port forward rule
|
||||||
func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -49,14 +43,9 @@ func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperPFWDelRequest{
|
|
||||||
PFWDelRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pfwDel"
|
url := "/cloudapi/compute/pfwDel"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -68,25 +57,3 @@ func (c Compute) PFWDel(ctx context.Context, req PFWDelRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PFWDelAsync deletes port forward rule with AsyncMode
|
|
||||||
func (c Compute) PFWDelAsync(ctx context.Context, req PFWDelRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperPFWDelRequest{
|
|
||||||
PFWDelRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pfwDel"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -20,12 +20,6 @@ type PinToNodeRequest struct {
|
|||||||
AutoStart bool `url:"autoStart" json:"autoStart"`
|
AutoStart bool `url:"autoStart" json:"autoStart"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperPinToNodeRequest struct {
|
|
||||||
PinToNodeRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PinToNode pin compute to current node
|
// PinToNode pin compute to current node
|
||||||
func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, error) {
|
func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -33,14 +27,9 @@ func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, err
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperPinToNodeRequest{
|
|
||||||
PinToNodeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pin_to_node"
|
url := "/cloudapi/compute/pin_to_node"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -52,25 +41,3 @@ func (c Compute) PinToNode(ctx context.Context, req PinToNodeRequest) (bool, err
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PinToNodeAsync pins compute to current node with AsyncMode
|
|
||||||
func (c Compute) PinToNodeAsync(ctx context.Context, req PinToNodeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperPinToNodeRequest{
|
|
||||||
PinToNodeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/pin_to_node"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type PowerCycleRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperPowerCycleRequest struct {
|
|
||||||
PowerCycleRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PowerCycle makes force stop and start compute
|
// PowerCycle makes force stop and start compute
|
||||||
func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, error) {
|
func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperPowerCycleRequest{
|
|
||||||
PowerCycleRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/powerCycle"
|
url := "/cloudapi/compute/powerCycle"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) PowerCycle(ctx context.Context, req PowerCycleRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PowerCycleAsync makes force stop and start compute with AsyncMode
|
|
||||||
func (c Compute) PowerCycleAsync(ctx context.Context, req PowerCycleRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperPowerCycleRequest{
|
|
||||||
PowerCycleRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/powerCycle"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type RebootRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperRebootRequest struct {
|
|
||||||
RebootRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reboot reboots compute
|
// Reboot reboots compute
|
||||||
func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
|
func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperRebootRequest{
|
|
||||||
RebootRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/reboot"
|
url := "/cloudapi/compute/reboot"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) Reboot(ctx context.Context, req RebootRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RebootAsync reboots compute with AsyncMode
|
|
||||||
func (c Compute) RebootAsync(ctx context.Context, req RebootRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperRebootRequest{
|
|
||||||
RebootRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/reboot"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -44,12 +44,6 @@ type RedeployRequest struct {
|
|||||||
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperRedeployRequest struct {
|
|
||||||
RedeployRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redeploy redeploys compute
|
// Redeploy redeploys compute
|
||||||
func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error) {
|
func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -57,14 +51,9 @@ func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperRedeployRequest{
|
|
||||||
RedeployRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/redeploy"
|
url := "/cloudapi/compute/redeploy"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -76,25 +65,3 @@ func (c Compute) Redeploy(ctx context.Context, req RedeployRequest) (bool, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RedeployAsync redeploys compute with AsyncMode
|
|
||||||
func (c Compute) RedeployAsync(ctx context.Context, req RedeployRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperRedeployRequest{
|
|
||||||
RedeployRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/redeploy"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type ResetRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperResetRequest struct {
|
|
||||||
ResetRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset resets compute
|
// Reset resets compute
|
||||||
func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
|
func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperResetRequest{
|
|
||||||
ResetRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/reset"
|
url := "/cloudapi/compute/reset"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) Reset(ctx context.Context, req ResetRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetAsync resets compute with AsyncMode
|
|
||||||
func (c Compute) ResetAsync(ctx context.Context, req ResetRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperResetRequest{
|
|
||||||
ResetRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/reset"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -43,12 +43,6 @@ func (r ResizeRequest) GetRAM() map[string]uint64 {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperResizeRequest struct {
|
|
||||||
ResizeRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resize resizes compute instance
|
// Resize resizes compute instance
|
||||||
func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -56,14 +50,9 @@ func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperResizeRequest{
|
|
||||||
ResizeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/resize"
|
url := "/cloudapi/compute/resize"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -75,25 +64,3 @@ func (c Compute) Resize(ctx context.Context, req ResizeRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResizeAsync resizes compute instance with AsyncMode
|
|
||||||
func (c Compute) ResizeAsync(ctx context.Context, req ResizeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperResizeRequest{
|
|
||||||
ResizeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/resize"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -15,54 +14,16 @@ type RestoreRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperRestoreRequest struct {
|
|
||||||
RestoreRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore restores compute from recycle bin
|
// Restore restores compute from recycle bin
|
||||||
func (c Compute) Restore(ctx context.Context, req RestoreRequest) (bool, error) {
|
func (c Compute) Restore(ctx context.Context, req RestoreRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperRestoreRequest{
|
|
||||||
RestoreRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/restore"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RestoreAsync restores compute from recycle bin with AsyncMode
|
|
||||||
func (c Compute) RestoreAsync(ctx context.Context, req RestoreRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperRestoreRequest{
|
|
||||||
RestoreRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/restore"
|
url := "/cloudapi/compute/restore"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type ResumeRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperResumeRequest struct {
|
|
||||||
ResumeRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resume resume Compute from paused state
|
// Resume resume Compute from paused state
|
||||||
func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
|
func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperResumeRequest{
|
|
||||||
ResumeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/resume"
|
url := "/cloudapi/compute/resume"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) Resume(ctx context.Context, req ResumeRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResumeAsync resumes Compute from paused state with AsyncMode
|
|
||||||
func (c Compute) ResumeAsync(ctx context.Context, req ResumeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperResumeRequest{
|
|
||||||
ResumeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/resume"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
package compute
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// SetCPUAlignmentProfileRequest struct to set CPU alignment profile for computes
|
|
||||||
type SetCPUAlignmentProfileRequest struct {
|
|
||||||
// IDs of the compute instances
|
|
||||||
// Required: true
|
|
||||||
ComputeIDs []int64 `url:"compute_ids" json:"compute_ids" validate:"min=1"`
|
|
||||||
|
|
||||||
// CPU alignment profile name
|
|
||||||
// Required: true
|
|
||||||
CPUAlignmentProfile string `url:"cpu_alignment_profile" json:"cpu_alignment_profile" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetCPUAlignmentProfile sets CPU alignment profile for computes
|
|
||||||
func (c Compute) SetCPUAlignmentProfile(ctx context.Context, req SetCPUAlignmentProfileRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/set_cpu_alignment_profile"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -20,33 +20,18 @@ type SnapshotCreateRequest struct {
|
|||||||
// Maximum length: 36 characters
|
// Maximum length: 36 characters
|
||||||
// Required: true
|
// Required: true
|
||||||
Label string `url:"label" json:"label" validate:"required,max=36,excludesall=<>"`
|
Label string `url:"label" json:"label" validate:"required,max=36,excludesall=<>"`
|
||||||
|
|
||||||
// Create snapshot with memory dump
|
|
||||||
// Required: false
|
|
||||||
// Default: false
|
|
||||||
WithMemory bool `url:"with_memory" json:"with_memory"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperSnapshotCreateRequest struct {
|
// SnapshotCreate create compute snapshot
|
||||||
SnapshotCreateRequest
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// SnapshotCreate creates compute snapshot
|
|
||||||
func (c Compute) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (string, error) {
|
func (c Compute) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperSnapshotCreateRequest{
|
|
||||||
SnapshotCreateRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/snapshotCreate"
|
url := "/cloudapi/compute/snapshotCreate"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -55,25 +40,3 @@ func (c Compute) SnapshotCreate(ctx context.Context, req SnapshotCreateRequest)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SnapshotCreateAsync creates compute snapshot in async mode
|
|
||||||
func (c Compute) SnapshotCreateAsync(ctx context.Context, req SnapshotCreateRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperSnapshotCreateRequest{
|
|
||||||
SnapshotCreateRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/snapshotCreate"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -17,16 +17,6 @@ type SnapshotRollbackRequest struct {
|
|||||||
// Text label of snapshot to rollback
|
// Text label of snapshot to rollback
|
||||||
// Required: true
|
// Required: true
|
||||||
Label string `url:"label" json:"label" validate:"required"`
|
Label string `url:"label" json:"label" validate:"required"`
|
||||||
|
|
||||||
// Rollback with memory dump restore
|
|
||||||
// Required: false
|
|
||||||
// Default: true
|
|
||||||
WithMemory interface{} `url:"with_memory,omitempty" json:"with_memory,omitempty" validate:"omitempty,isBool"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperSnapshotRollbackRequest struct {
|
|
||||||
SnapshotRollbackRequest
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SnapshotRollback rollbacks specified compute snapshot
|
// SnapshotRollback rollbacks specified compute snapshot
|
||||||
@@ -36,14 +26,9 @@ func (c Compute) SnapshotRollback(ctx context.Context, req SnapshotRollbackReque
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperSnapshotRollbackRequest{
|
|
||||||
SnapshotRollbackRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/snapshotRollback"
|
url := "/cloudapi/compute/snapshotRollback"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +40,3 @@ func (c Compute) SnapshotRollback(ctx context.Context, req SnapshotRollbackReque
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SnapshotRollbackAsync rollbacks specified compute snapshot in async mode
|
|
||||||
func (c Compute) SnapshotRollbackAsync(ctx context.Context, req SnapshotRollbackRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperSnapshotRollbackRequest{
|
|
||||||
SnapshotRollbackRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/snapshotRollback"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type StartRequest struct {
|
|||||||
AltBootID uint64 `url:"altBootId,omitempty" json:"altBootId,omitempty"`
|
AltBootID uint64 `url:"altBootId,omitempty" json:"altBootId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperStartRequest struct {
|
|
||||||
StartRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start starts compute
|
// Start starts compute
|
||||||
func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
|
func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperStartRequest{
|
|
||||||
StartRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/start"
|
url := "/cloudapi/compute/start"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) Start(ctx context.Context, req StartRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartAsync starts compute with AsyncMode
|
|
||||||
func (c Compute) StartAsync(ctx context.Context, req StartRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperStartRequest{
|
|
||||||
StartRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/start"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type StopRequest struct {
|
|||||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperStopRequest struct {
|
|
||||||
StopRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop stops compute
|
// Stop stops compute
|
||||||
func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperStopRequest{
|
|
||||||
StopRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/stop"
|
url := "/cloudapi/compute/stop"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StopAsync stops compute with AsyncMode
|
|
||||||
func (c Compute) StopAsync(ctx context.Context, req StopRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperStopRequest{
|
|
||||||
StopRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudapi/compute/stop"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -69,11 +69,6 @@ type UpdateRequest struct {
|
|||||||
// The OS version that will be installed on the virtual machine
|
// The OS version that will be installed on the virtual machine
|
||||||
// Required: false
|
// Required: false
|
||||||
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
||||||
|
|
||||||
// Clock type for the VM
|
|
||||||
// Required: false
|
|
||||||
// Default: null
|
|
||||||
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates some properties of the compute
|
// Update updates some properties of the compute
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ type ItemDisk struct {
|
|||||||
// Account name
|
// Account name
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
|
|
||||||
// Discard
|
// BLK Discard
|
||||||
Discard string `json:"discard"`
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
// Block size of disk
|
// Block size of disk
|
||||||
BlockSize string `json:"block_size"`
|
BlockSize string `json:"block_size"`
|
||||||
@@ -20,9 +20,6 @@ type ItemDisk struct {
|
|||||||
// Computes
|
// Computes
|
||||||
Computes map[string]string `json:"computes"`
|
Computes map[string]string `json:"computes"`
|
||||||
|
|
||||||
// Computes read only
|
|
||||||
ComputesReadOnly map[string]bool `json:"computes_read_only"`
|
|
||||||
|
|
||||||
//Created by
|
//Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|
||||||
@@ -169,8 +166,8 @@ type ItemDiskUnattached struct {
|
|||||||
// Access Control List
|
// Access Control List
|
||||||
ACL map[string]interface{} `json:"acl"`
|
ACL map[string]interface{} `json:"acl"`
|
||||||
|
|
||||||
// Discard
|
// BLK Discard
|
||||||
Discard string `json:"discard"`
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
// Block size of disk
|
// Block size of disk
|
||||||
BlockSize string `json:"block_size"`
|
BlockSize string `json:"block_size"`
|
||||||
@@ -402,8 +399,8 @@ type RecordDisk struct {
|
|||||||
// Account name
|
// Account name
|
||||||
AccountName string `json:"accountName"`
|
AccountName string `json:"accountName"`
|
||||||
|
|
||||||
// Discard
|
// BLK Discard
|
||||||
Discard string `json:"discard"`
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
// Block size of disk
|
// Block size of disk
|
||||||
BlockSize string `json:"block_size"`
|
BlockSize string `json:"block_size"`
|
||||||
@@ -411,9 +408,6 @@ type RecordDisk struct {
|
|||||||
// Computes
|
// Computes
|
||||||
Computes map[string]string `json:"computes"`
|
Computes map[string]string `json:"computes"`
|
||||||
|
|
||||||
// Computes read only
|
|
||||||
ComputesReadOnly map[string]bool `json:"computes_read_only"`
|
|
||||||
|
|
||||||
// Created by
|
// Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ type ItemExtNet struct {
|
|||||||
|
|
||||||
// Status
|
// Status
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
|
|
||||||
// Free IPs
|
|
||||||
FreeIPs uint64 `json:"freeIps"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extend information about external network
|
// Extend information about external network
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ type CreateVirtualRequest struct {
|
|||||||
TargetID uint64 `url:"targetId" json:"targetId" validate:"required"`
|
TargetID uint64 `url:"targetId" json:"targetId" validate:"required"`
|
||||||
|
|
||||||
// AccountID to make the virtual image exclusive
|
// AccountID to make the virtual image exclusive
|
||||||
// Required: true
|
// Required: false
|
||||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
// Default: 0
|
||||||
|
AccountID uint64 `url:"accountId,omitempty" json:"accountId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateVirtual creates virtual image
|
// CreateVirtual creates virtual image
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ type ListRequest struct {
|
|||||||
|
|
||||||
// Find by type
|
// Find by type
|
||||||
// Required: false
|
// Required: false
|
||||||
TypeImage []string `url:"typeImage,omitempty" json:"typeImage,omitempty"`
|
TypeImage string `url:"typeImage,omitempty" json:"typeImage,omitempty"`
|
||||||
|
|
||||||
// Find by image size
|
// Find by image size
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -103,6 +102,6 @@ func (i Image) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
|||||||
|
|
||||||
url := "/cloudapi/image/list"
|
url := "/cloudapi/image/list"
|
||||||
|
|
||||||
res, err := i.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package kvmx86
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -48,9 +48,9 @@ type Interface struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||||
|
|
||||||
// SDN Object Group IDs
|
// SDN Object Group ID
|
||||||
// Required: false
|
// Required: false
|
||||||
SDNObjectGroupIDs []string `url:"sdn_object_group_ids,omitempty" json:"sdn_object_group_ids,omitempty"`
|
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
|
||||||
|
|
||||||
// SDN Logical Port Display Name
|
// SDN Logical Port Display Name
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -218,19 +218,11 @@ type CreateRequest struct {
|
|||||||
// Zone ID
|
// Zone ID
|
||||||
// Required: false
|
// Required: false
|
||||||
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
ZoneID uint64 `url:"zoneId,omitempty" json:"zoneId,omitempty"`
|
||||||
|
|
||||||
// CPU alignment profile name
|
|
||||||
// Required: false
|
|
||||||
CPUAlignmentProfile string `url:"cpu_alignment_profile,omitempty" json:"cpu_alignment_profile,omitempty"`
|
|
||||||
|
|
||||||
// Clock type for the VM
|
|
||||||
// Required: false
|
|
||||||
// Default: default
|
|
||||||
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
func (r CreateRequest) GetRAM() map[string]uint64 {
|
func (r CreateRequest) GetRAM() map[string]uint64 {
|
||||||
|
|
||||||
res := make(map[string]uint64, 1)
|
res := make(map[string]uint64, 1)
|
||||||
|
|
||||||
res["RAM"] = r.RAM
|
res["RAM"] = r.RAM
|
||||||
@@ -238,6 +230,12 @@ func (r CreateRequest) GetRAM() map[string]uint64 {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperCreateRequest struct {
|
||||||
|
CreateRequest
|
||||||
|
Interfaces []string `url:"interfaces,omitempty"`
|
||||||
|
DataDisks []string `url:"dataDisks,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// Create creates KVM x86 VM based on specified OS image
|
// Create creates KVM x86 VM based on specified OS image
|
||||||
func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -245,12 +243,55 @@ func (k KVMX86) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
|||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var interfaces []string
|
||||||
|
|
||||||
|
if req.Interfaces != nil && len(req.Interfaces) != 0 {
|
||||||
|
interfaces = make([]string, 0, len(req.Interfaces))
|
||||||
|
|
||||||
|
for i := range req.Interfaces {
|
||||||
|
b, err := json.Marshal(req.Interfaces[i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
interfaces = append(interfaces, string(b))
|
||||||
|
}
|
||||||
|
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||||
|
interfaces = []string{"[]"}
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataDisks []string
|
||||||
|
|
||||||
|
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||||
|
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||||
|
|
||||||
|
for i := range req.DataDisks {
|
||||||
|
b, err := json.Marshal(req.DataDisks[i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
dataDisks = append(dataDisks, string(b))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reqWrapped := wrapperCreateRequest{
|
||||||
|
CreateRequest: req,
|
||||||
|
Interfaces: interfaces,
|
||||||
|
DataDisks: dataDisks,
|
||||||
|
}
|
||||||
|
|
||||||
url := "/cloudapi/kvmx86/create"
|
url := "/cloudapi/kvmx86/create"
|
||||||
|
|
||||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return strconv.ParseUint(string(res), 10, 64)
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package kvmx86
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"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"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -115,15 +115,6 @@ type CreateBlankRequest struct {
|
|||||||
// The OS version that will be installed on the virtual machine
|
// The OS version that will be installed on the virtual machine
|
||||||
// Required: false
|
// Required: false
|
||||||
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
OSVersion string `url:"os_version,omitempty" json:"os_version,omitempty"`
|
||||||
|
|
||||||
// CPU alignment profile name
|
|
||||||
// Required: false
|
|
||||||
CPUAlignmentProfile string `url:"cpu_alignment_profile,omitempty" json:"cpu_alignment_profile,omitempty"`
|
|
||||||
|
|
||||||
// Clock type for the VM
|
|
||||||
// Required: false
|
|
||||||
// Default: default
|
|
||||||
Clock string `url:"clock,omitempty" json:"clock,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRAM returns RAM field values
|
// GetRAM returns RAM field values
|
||||||
@@ -136,6 +127,12 @@ func (r CreateBlankRequest) GetRAM() map[string]uint64 {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type wrapperCreateBlankRequest struct {
|
||||||
|
CreateBlankRequest
|
||||||
|
Interfaces []string `url:"interfaces,omitempty"`
|
||||||
|
DataDisks []string `url:"dataDisks,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// CreateBlank creates KVM x86 VM from scratch
|
// CreateBlank creates KVM x86 VM from scratch
|
||||||
func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
|
func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -143,12 +140,55 @@ func (k KVMX86) CreateBlank(ctx context.Context, req CreateBlankRequest) (uint64
|
|||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var interfaces []string
|
||||||
|
|
||||||
|
if req.Interfaces != nil && len(req.Interfaces) != 0 {
|
||||||
|
interfaces = make([]string, 0, len(req.Interfaces))
|
||||||
|
|
||||||
|
for i := range req.Interfaces {
|
||||||
|
b, err := json.Marshal(req.Interfaces[i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
interfaces = append(interfaces, string(b))
|
||||||
|
}
|
||||||
|
} else if req.Interfaces != nil && len(req.Interfaces) == 0 {
|
||||||
|
interfaces = []string{"[]"}
|
||||||
|
}
|
||||||
|
|
||||||
|
var dataDisks []string
|
||||||
|
|
||||||
|
if req.DataDisks != nil && len(req.DataDisks) != 0 {
|
||||||
|
dataDisks = make([]string, 0, len(req.DataDisks))
|
||||||
|
|
||||||
|
for i := range req.DataDisks {
|
||||||
|
b, err := json.Marshal(req.DataDisks[i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
dataDisks = append(dataDisks, string(b))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reqWrapped := wrapperCreateBlankRequest{
|
||||||
|
CreateBlankRequest: req,
|
||||||
|
Interfaces: interfaces,
|
||||||
|
DataDisks: dataDisks,
|
||||||
|
}
|
||||||
|
|
||||||
url := "/cloudapi/kvmx86/createBlank"
|
url := "/cloudapi/kvmx86/createBlank"
|
||||||
|
|
||||||
res, err := k.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
res, err := k.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return strconv.ParseUint(string(res), 10, 64)
|
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ type RecordResourceGroup struct {
|
|||||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||||
|
|
||||||
// CPU allocation ratio
|
// CPU allocation ratio
|
||||||
CPUAllocationRatio uint64 `json:"cpu_allocation_ratio"`
|
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||||
|
|
||||||
// Created by
|
// Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
@@ -180,7 +180,7 @@ type ItemResourceGroup struct {
|
|||||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||||
|
|
||||||
// CPU allocation ratio
|
// CPU allocation ratio
|
||||||
CPUAllocationRatio uint64 `json:"cpu_allocation_ratio"`
|
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||||
|
|
||||||
// Created by
|
// Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|||||||
@@ -1,17 +1,5 @@
|
|||||||
package zone
|
package zone
|
||||||
|
|
||||||
// CPU alignment profile
|
|
||||||
type CpuAlignmentProfile struct {
|
|
||||||
// Profile name
|
|
||||||
Name string `json:"name"`
|
|
||||||
|
|
||||||
// Vendor
|
|
||||||
Vendor string `json:"vendor"`
|
|
||||||
|
|
||||||
// Model
|
|
||||||
Model string `json:"model"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ListZones struct {
|
type ListZones struct {
|
||||||
// Entry count
|
// Entry count
|
||||||
EntryCount uint64 `json:"entryCount"`
|
EntryCount uint64 `json:"entryCount"`
|
||||||
@@ -108,9 +96,6 @@ type RecordZone struct {
|
|||||||
|
|
||||||
// Domain
|
// Domain
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"domain"`
|
||||||
|
|
||||||
// CPU alignment profiles
|
|
||||||
CpuAlignmentProfiles []CpuAlignmentProfile `json:"cpu_alignment_profiles"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A zone item from a list
|
// A zone item from a list
|
||||||
@@ -180,7 +165,4 @@ type ItemZone struct {
|
|||||||
|
|
||||||
// Domain
|
// Domain
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"domain"`
|
||||||
|
|
||||||
// CPU alignment profiles
|
|
||||||
CpuAlignmentProfiles []CpuAlignmentProfile `json:"cpu_alignment_profiles"`
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ type InfoAccount struct {
|
|||||||
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
CPUAllocationParameter string `json:"cpu_allocation_parameter"`
|
||||||
|
|
||||||
// CPU allocation ratio
|
// CPU allocation ratio
|
||||||
CPUAllocationRatio uint64 `json:"cpu_allocation_ratio"`
|
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||||
|
|
||||||
// Created by
|
// Created by
|
||||||
CreatedBy string `json:"createdBy"`
|
CreatedBy string `json:"createdBy"`
|
||||||
|
|||||||
@@ -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 uint64 `url:"ratio" json:"ratio" validate:"required"`
|
Ratio float64 `url:"ratio" json:"ratio" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetCPUAllocationRatio sets CPU allocation ratio
|
// SetCPUAllocationRatio sets CPU allocation ratio
|
||||||
|
|||||||
@@ -18,11 +18,6 @@ type AbortSharedSnapshotMergeRequest struct {
|
|||||||
Label string `url:"label" json:"label" validate:"required"`
|
Label string `url:"label" json:"label" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperAbortSharedSnapshotMergeRequest struct {
|
|
||||||
AbortSharedSnapshotMergeRequest
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// AbortSharedSnapshotMerge shared snapshots merge abort
|
// AbortSharedSnapshotMerge shared snapshots merge abort
|
||||||
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -30,36 +25,9 @@ func (c Compute) AbortSharedSnapshotMerge(ctx context.Context, req AbortSharedSn
|
|||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperAbortSharedSnapshotMergeRequest{
|
|
||||||
AbortSharedSnapshotMergeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/abort_shared_snapshot_merge"
|
url := "/cloudbroker/compute/abort_shared_snapshot_merge"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// AbortSharedSnapshotMergeAsync shared snapshots merge abort in async mode
|
|
||||||
func (c Compute) AbortSharedSnapshotMergeAsync(ctx context.Context, req AbortSharedSnapshotMergeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperAbortSharedSnapshotMergeRequest{
|
|
||||||
AbortSharedSnapshotMergeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/abort_shared_snapshot_merge"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type CDEjectRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCDEjectRequest struct {
|
|
||||||
CDEjectRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CDEject ejects CD image to compute's CD-ROM
|
// CDEject ejects CD image to compute's CD-ROM
|
||||||
func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error) {
|
func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperCDEjectRequest{
|
|
||||||
CDEjectRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/cdEject"
|
url := "/cloudbroker/compute/cdEject"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) CDEject(ctx context.Context, req CDEjectRequest) (bool, error)
|
|||||||
|
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// CDEjectAsync ejects CD image to compute's CD-ROM with AsyncMode
|
|
||||||
func (c Compute) CDEjectAsync(ctx context.Context, req CDEjectRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCDEjectRequest{
|
|
||||||
CDEjectRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/cdEject"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,12 +18,6 @@ type CDInsertRequest struct {
|
|||||||
CDROMID uint64 `url:"cdromId" json:"cdromId" validate:"required"`
|
CDROMID uint64 `url:"cdromId" json:"cdromId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCDInsertRequest struct {
|
|
||||||
CDInsertRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CDInsert inserts new CD image to compute's CD-ROM
|
// CDInsert inserts new CD image to compute's CD-ROM
|
||||||
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) {
|
func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -31,39 +25,12 @@ func (c Compute) CDInsert(ctx context.Context, req CDInsertRequest) (bool, error
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperCDInsertRequest{
|
|
||||||
CDInsertRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/cdInsert"
|
url := "/cloudbroker/compute/cdInsert"
|
||||||
|
|
||||||
_, err = c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
_, err = c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CDInsertAsync inserts new CD image to compute's CD-ROM with AsyncMode
|
|
||||||
func (c Compute) CDInsertAsync(ctx context.Context, req CDInsertRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCDInsertRequest{
|
|
||||||
CDInsertRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/cdInsert"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -31,12 +31,6 @@ type ChangeIPRequest struct {
|
|||||||
IPAddr string `url:"ip_addr" json:"ip_addr" validate:"required"`
|
IPAddr string `url:"ip_addr" json:"ip_addr" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeIPRequest struct {
|
|
||||||
ChangeIPRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeIP change reserved IP for compute instance
|
// ChangeIP change reserved IP for compute instance
|
||||||
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
|
func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -44,14 +38,9 @@ func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeIPRequest{
|
|
||||||
ChangeIPRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/changeIp"
|
url := "/cloudbroker/compute/changeIp"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -63,25 +52,3 @@ func (c Compute) ChangeIP(ctx context.Context, req ChangeIPRequest) (bool, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeIPAsync change reserved IP for compute instance with AsyncMode
|
|
||||||
func (c Compute) ChangeIPAsync(ctx context.Context, req ChangeIPRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeIPRequest{
|
|
||||||
ChangeIPRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/changeIp"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ChangeLinkStateRequest struct for changing link state
|
// ChangeLinkStateRequest struct for changing link state
|
||||||
@@ -24,12 +23,6 @@ type ChangeLinkStateRequest struct {
|
|||||||
State string `url:"state" json:"state" validate:"required,interfaceState"`
|
State string `url:"state" json:"state" validate:"required,interfaceState"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeLinkStateRequest struct {
|
|
||||||
ChangeLinkStateRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeLinkState changes the status link virtual of compute
|
// ChangeLinkState changes the status link virtual of compute
|
||||||
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
|
func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -37,14 +30,9 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeLinkStateRequest{
|
|
||||||
ChangeLinkStateRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/changeLinkState"
|
url := "/cloudbroker/compute/changeLinkState"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -53,28 +41,5 @@ func (c Compute) ChangeLinkState(ctx context.Context, req ChangeLinkStateRequest
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeLinkStateAsync changes the status link virtual of compute with AsyncMode
|
|
||||||
func (c Compute) ChangeLinkStateAsync(ctx context.Context, req ChangeLinkStateRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeLinkStateRequest{
|
|
||||||
ChangeLinkStateRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/changeLinkState"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type ChangeMTURequest struct {
|
|||||||
MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"`
|
MTU uint64 `url:"mtu" json:"mtu" validate:"required" validate:"omitempty,mtu"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeMTURequest struct {
|
|
||||||
ChangeMTURequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeMTU change MTU for compute instance
|
// ChangeMTU change MTU for compute instance
|
||||||
func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) {
|
func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, err
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeMTURequest{
|
|
||||||
ChangeMTURequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/change_mtu"
|
url := "/cloudbroker/compute/change_mtu"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) ChangeMTU(ctx context.Context, req ChangeMTURequest) (bool, err
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeMTUAsync change MTU for compute instance with AsyncMode
|
|
||||||
func (c Compute) ChangeMTUAsync(ctx context.Context, req ChangeMTURequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeMTURequest{
|
|
||||||
ChangeMTURequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/change_mtu"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -27,12 +27,6 @@ type ChangeSecGroupsRequest struct {
|
|||||||
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
EnableSecGroups interface{} `url:"enable_secgroups,omitempty" json:"enable_secgroups,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperChangeSecGroupsRequest struct {
|
|
||||||
ChangeSecGroupsRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChangeSecGroups changes security groups for compute
|
// ChangeSecGroups changes security groups for compute
|
||||||
func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) {
|
func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -40,14 +34,9 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperChangeSecGroupsRequest{
|
|
||||||
ChangeSecGroupsRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/change_security_groups"
|
url := "/cloudbroker/compute/change_security_groups"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -59,25 +48,3 @@ func (c Compute) ChangeSecGroups(ctx context.Context, req ChangeSecGroupsRequest
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChangeSecGroupsAsync changes security groups for compute with AsyncMode
|
|
||||||
func (c Compute) ChangeSecGroupsAsync(ctx context.Context, req ChangeSecGroupsRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperChangeSecGroupsRequest{
|
|
||||||
ChangeSecGroupsRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/change_security_groups"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -44,12 +44,6 @@ type CloneRequest struct {
|
|||||||
SEPID uint64 `url:"sep_id" json:"sep_id"`
|
SEPID uint64 `url:"sep_id" json:"sep_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCloneRequest struct {
|
|
||||||
CloneRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clone clones compute instance
|
// Clone clones compute instance
|
||||||
func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
|
func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -57,36 +51,9 @@ func (c Compute) Clone(ctx context.Context, req CloneRequest) (string, error) {
|
|||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperCloneRequest{
|
|
||||||
CloneRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/clone"
|
url := "/cloudbroker/compute/clone"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CloneAsync clones compute instance with AsyncMode
|
|
||||||
func (c Compute) CloneAsync(ctx context.Context, req CloneRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCloneRequest{
|
|
||||||
CloneRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/clone"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type CreateTemplateRequest struct {
|
|||||||
Name string `url:"name" json:"name" validate:"required"`
|
Name string `url:"name" json:"name" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperCreateTemplateRequest struct {
|
|
||||||
CreateTemplateRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateTemplate create template from compute instance
|
// CreateTemplate create template from compute instance
|
||||||
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (string, error) {
|
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest)
|
|||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperCreateTemplateRequest{
|
|
||||||
CreateTemplateRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/createTemplate"
|
url := "/cloudbroker/compute/createTemplate"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -48,25 +37,3 @@ func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateTemplateAsync create template from compute instance with AsyncMode
|
|
||||||
func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperCreateTemplateRequest{
|
|
||||||
CreateTemplateRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/createTemplate"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DeleteRequest struct {
|
|||||||
DetachDisks bool `url:"detachDisks,omitempty" json:"detachDisks,omitempty"`
|
DetachDisks bool `url:"detachDisks,omitempty" json:"detachDisks,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDeleteRequest struct {
|
|
||||||
DeleteRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete deletes compute
|
// Delete deletes compute
|
||||||
func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDeleteRequest{
|
|
||||||
DeleteRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/delete"
|
url := "/cloudbroker/compute/delete"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteAsync deletes compute with AsyncMode
|
|
||||||
func (c Compute) DeleteAsync(ctx context.Context, req DeleteRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDeleteRequest{
|
|
||||||
DeleteRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/delete"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
package compute
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/constants"
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DeleteCPUAlignmentProfileRequest struct to delete CPU alignment profile for computes
|
|
||||||
type DeleteCPUAlignmentProfileRequest struct {
|
|
||||||
// IDs of the compute instances
|
|
||||||
// Required: true
|
|
||||||
ComputeIDs []uint64 `url:"compute_ids" json:"compute_ids" validate:"min=1"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteCPUAlignmentProfile deletes CPU alignment profile for computes
|
|
||||||
func (c Compute) DeleteCPUAlignmentProfile(ctx context.Context, req DeleteCPUAlignmentProfileRequest) (bool, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/delete_cpu_alignment_profile"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
@@ -15,12 +15,6 @@ type DisableRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDisableRequest struct {
|
|
||||||
DisableRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable disables compute
|
// Disable disables compute
|
||||||
func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDisableRequest{
|
|
||||||
DisableRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/disable"
|
url := "/cloudbroker/compute/disable"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) Disable(ctx context.Context, req DisableRequest) (bool, error)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DisableAsync disables compute with AsyncMode
|
|
||||||
func (c Compute) DisableAsync(ctx context.Context, req DisableRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDisableRequest{
|
|
||||||
DisableRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/disable"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -56,19 +56,9 @@ type DiskAddRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
Cache string `url:"cache,omitempty" json:"cache,omitempty"`
|
Cache string `url:"cache,omitempty" json:"cache,omitempty"`
|
||||||
|
|
||||||
// Discard
|
// BLK Discard
|
||||||
// Required: false
|
// Required: false
|
||||||
Discard string `url:"discard,omitempty" json:"discard,omitempty"`
|
BLKDiscard interface{} `url:"blkdiscard,omitempty" json:"blkdiscard,omitempty" validate:"omitempty,isBool"`
|
||||||
|
|
||||||
// Mount disk in read-only mode
|
|
||||||
// Required: false
|
|
||||||
ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperDiskAddRequest struct {
|
|
||||||
DiskAddRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAdd creates new disk and attach to compute
|
// DiskAdd creates new disk and attach to compute
|
||||||
@@ -78,14 +68,9 @@ func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error
|
|||||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAddRequest{
|
|
||||||
DiskAddRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskAdd"
|
url := "/cloudbroker/compute/diskAdd"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@@ -97,25 +82,3 @@ func (c Compute) DiskAdd(ctx context.Context, req DiskAddRequest) (uint64, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAddAsync creates new disk and attach to compute with AsyncMode
|
|
||||||
func (c Compute) DiskAddAsync(ctx context.Context, req DiskAddRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAddRequest{
|
|
||||||
DiskAddRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskAdd"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -25,16 +25,6 @@ type DiskAttachRequest struct {
|
|||||||
// Desired bus number (hex string, e.g. "0x03")
|
// Desired bus number (hex string, e.g. "0x03")
|
||||||
// Required: false
|
// Required: false
|
||||||
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
BusNumber string `url:"bus_number,omitempty" json:"bus_number,omitempty"`
|
||||||
|
|
||||||
// Mount disk in read-only mode
|
|
||||||
// Required: false
|
|
||||||
ReadOnly bool `url:"read_only,omitempty" json:"read_only,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrapperDiskAttachRequest struct {
|
|
||||||
DiskAttachRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAttach attach disk to compute
|
// DiskAttach attach disk to compute
|
||||||
@@ -44,14 +34,9 @@ func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAttachRequest{
|
|
||||||
DiskAttachRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskAttach"
|
url := "/cloudbroker/compute/diskAttach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -63,25 +48,3 @@ func (c Compute) DiskAttach(ctx context.Context, req DiskAttachRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskAttachAsync attach disk to compute with AsyncMode
|
|
||||||
func (c Compute) DiskAttachAsync(ctx context.Context, req DiskAttachRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskAttachRequest{
|
|
||||||
DiskAttachRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskAttach"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskDelRequest struct {
|
|||||||
Permanently bool `url:"permanently" json:"permanently"`
|
Permanently bool `url:"permanently" json:"permanently"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskDelRequest struct {
|
|
||||||
DiskDelRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskDel deletes disk and detaches it from compute
|
// DiskDel deletes disk and detaches it from compute
|
||||||
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) {
|
func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDelRequest{
|
|
||||||
DiskDelRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskDel"
|
url := "/cloudbroker/compute/diskDel"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskDel(ctx context.Context, req DiskDelRequest) (bool, error)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskDelAsync deletes disk and detaches it from compute with AsyncMode
|
|
||||||
func (c Compute) DiskDelAsync(ctx context.Context, req DiskDelRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDelRequest{
|
|
||||||
DiskDelRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskDel"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type DiskDetachRequest struct {
|
|||||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskDetachRequest struct {
|
|
||||||
DiskDetachRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskDetach detaches disk from compute
|
// DiskDetach detaches disk from compute
|
||||||
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) {
|
func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDetachRequest{
|
|
||||||
DiskDetachRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskDetach"
|
url := "/cloudbroker/compute/diskDetach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) DiskDetach(ctx context.Context, req DiskDetachRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskDetachAsync detaches disk from compute with AsyncMode
|
|
||||||
func (c Compute) DiskDetachAsync(ctx context.Context, req DiskDetachRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskDetachRequest{
|
|
||||||
DiskDetachRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskDetach"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskQOSRequest struct {
|
|||||||
Limits string `url:"limits" json:"limits" validate:"required"`
|
Limits string `url:"limits" json:"limits" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskQOSRequest struct {
|
|
||||||
DiskQOSRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskQOS changes QOS of the disk
|
// DiskQOS changes QOS of the disk
|
||||||
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
|
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskQOSRequest{
|
|
||||||
DiskQOSRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskQos"
|
url := "/cloudbroker/compute/diskQos"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskQOSAsync changes QOS of the disk with AsyncMode
|
|
||||||
func (c Compute) DiskQOSAsync(ctx context.Context, req DiskQOSRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskQOSRequest{
|
|
||||||
DiskQOSRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskQos"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskResizeRequest struct {
|
|||||||
Size uint64 `url:"size" json:"size" validate:"required"`
|
Size uint64 `url:"size" json:"size" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskResizeRequest struct {
|
|
||||||
DiskResizeRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskResize changes disk size
|
// DiskResize changes disk size
|
||||||
func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, error) {
|
func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskResizeRequest{
|
|
||||||
DiskResizeRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskResize"
|
url := "/cloudbroker/compute/diskResize"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskResize(ctx context.Context, req DiskResizeRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskResizeAsync changes disk size with AsyncMode
|
|
||||||
func (c Compute) DiskResizeAsync(ctx context.Context, req DiskResizeRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskResizeRequest{
|
|
||||||
DiskResizeRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskResize"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type DiskSwitchToReplicationRequest struct {
|
|||||||
StopReplication bool `url:"stopReplication" json:"stopReplication"`
|
StopReplication bool `url:"stopReplication" json:"stopReplication"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperDiskSwitchToReplicationRequest struct {
|
|
||||||
DiskSwitchToReplicationRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// DiskSwitchToReplication switches disk to it's replication
|
// DiskSwitchToReplication switches disk to it's replication
|
||||||
func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToReplicationRequest) (bool, error) {
|
func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToReplicationRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToRe
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperDiskSwitchToReplicationRequest{
|
|
||||||
DiskSwitchToReplicationRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskSwitchToReplication"
|
url := "/cloudbroker/compute/diskSwitchToReplication"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -55,25 +44,3 @@ func (c Compute) DiskSwitchToReplication(ctx context.Context, req DiskSwitchToRe
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DiskSwitchToReplicationAsync switches disk to it's replication with AsyncMode
|
|
||||||
func (c Compute) DiskSwitchToReplicationAsync(ctx context.Context, req DiskSwitchToReplicationRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperDiskSwitchToReplicationRequest{
|
|
||||||
DiskSwitchToReplicationRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/diskSwitchToReplication"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
package compute
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetCPUAlignmentProfileRequest struct to get CPU alignment profile for compute
|
|
||||||
type GetCPUAlignmentProfileRequest struct {
|
|
||||||
// ID of the compute instance
|
|
||||||
// Required: true
|
|
||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCPUAlignmentProfile gets CPU alignment profile for compute
|
|
||||||
func (c Compute) GetCPUAlignmentProfile(ctx context.Context, req GetCPUAlignmentProfileRequest) (*CPUAlignmentProfile, error) {
|
|
||||||
res, err := c.GetCPUAlignmentProfileRaw(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
info := CPUAlignmentProfile{}
|
|
||||||
|
|
||||||
err = json.Unmarshal(res, &info)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCPUAlignmentProfileRaw gets CPU alignment profile for compute as an array of bytes
|
|
||||||
func (c Compute) GetCPUAlignmentProfileRaw(ctx context.Context, req GetCPUAlignmentProfileRequest) ([]byte, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/get_cpu_alignment_profile"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodGet, url, req)
|
|
||||||
return res, err
|
|
||||||
}
|
|
||||||
@@ -15,12 +15,6 @@ type GuestAgentDisableRequest struct {
|
|||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentDisableRequest struct {
|
|
||||||
GuestAgentDisableRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable guest agent at a specific compute
|
// Disable guest agent at a specific compute
|
||||||
func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) {
|
func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableReq
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentDisableRequest{
|
|
||||||
GuestAgentDisableRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/guest_agent_disable"
|
url := "/cloudbroker/compute/guest_agent_disable"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) GuestAgentDisable(ctx context.Context, req GuestAgentDisableReq
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentDisableAsync disables guest agent at a specific compute with AsyncMode
|
|
||||||
func (c Compute) GuestAgentDisableAsync(ctx context.Context, req GuestAgentDisableRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentDisableRequest{
|
|
||||||
GuestAgentDisableRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/guest_agent_disable"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type GuestAgentEnableRequest struct {
|
|||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentEnableRequest struct {
|
|
||||||
GuestAgentEnableRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enable guest agent at a specific compute
|
// Enable guest agent at a specific compute
|
||||||
func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) {
|
func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableReque
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentEnableRequest{
|
|
||||||
GuestAgentEnableRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/guest_agent_enable"
|
url := "/cloudbroker/compute/guest_agent_enable"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) GuestAgentEnable(ctx context.Context, req GuestAgentEnableReque
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentEnableAsync enables guest agent at a specific compute with AsyncMode
|
|
||||||
func (c Compute) GuestAgentEnableAsync(ctx context.Context, req GuestAgentEnableRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentEnableRequest{
|
|
||||||
GuestAgentEnableRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/guest_agent_enable"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -23,12 +23,6 @@ type GuestAgentExecuteRequest struct {
|
|||||||
Arguments string `url:"arguments" json:"arguments" validate:"required"`
|
Arguments string `url:"arguments" json:"arguments" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentExecuteRequest struct {
|
|
||||||
GuestAgentExecuteRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute guest agent command
|
// Execute guest agent command
|
||||||
func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) {
|
func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExecuteRequest) (map[string]interface{}, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -36,14 +30,9 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
|
|||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentExecuteRequest{
|
|
||||||
GuestAgentExecuteRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/guest_agent_execute"
|
url := "/cloudbroker/compute/guest_agent_execute"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -57,25 +46,3 @@ func (c Compute) GuestAgentExecuteRequest(ctx context.Context, req GuestAgentExe
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentExecuteRequestAsync executes guest agent command with AsyncMode
|
|
||||||
func (c Compute) GuestAgentExecuteRequestAsync(ctx context.Context, req GuestAgentExecuteRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentExecuteRequest{
|
|
||||||
GuestAgentExecuteRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/guest_agent_execute"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type GuestAgentFeatureUpdateRequest struct {
|
|||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperGuestAgentFeatureUpdateRequest struct {
|
|
||||||
GuestAgentFeatureUpdateRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Feature update guest agent
|
// Feature update guest agent
|
||||||
func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) {
|
func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeatureUpdateRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeat
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentFeatureUpdateRequest{
|
|
||||||
GuestAgentFeatureUpdateRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/guest_agent_feature_update"
|
url := "/cloudbroker/compute/guest_agent_feature_update"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) GuestAgentFeatureUpdate(ctx context.Context, req GuestAgentFeat
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GuestAgentFeatureUpdateAsync feature updates guest agent with AsyncMode
|
|
||||||
func (c Compute) GuestAgentFeatureUpdateAsync(ctx context.Context, req GuestAgentFeatureUpdateRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperGuestAgentFeatureUpdateRequest{
|
|
||||||
GuestAgentFeatureUpdateRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/guest_agent_feature_update"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type MassDeleteRequest struct {
|
|||||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMassDeleteRequest struct {
|
|
||||||
MassDeleteRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MassDelete starts jobs to delete several computes
|
// MassDelete starts jobs to delete several computes
|
||||||
func (c Compute) MassDelete(ctx context.Context, req MassDeleteRequest) (bool, error) {
|
func (c Compute) MassDelete(ctx context.Context, req MassDeleteRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) MassDelete(ctx context.Context, req MassDeleteRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMassDeleteRequest{
|
|
||||||
MassDeleteRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/massDelete"
|
url := "/cloudbroker/compute/massDelete"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) MassDelete(ctx context.Context, req MassDeleteRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MassDeleteAsync starts jobs to delete several computes with AsyncMode
|
|
||||||
func (c Compute) MassDeleteAsync(ctx context.Context, req MassDeleteRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMassDeleteRequest{
|
|
||||||
MassDeleteRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/massDelete"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type MassRebootRequest struct {
|
|||||||
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"min=1"`
|
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"min=1"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMassRebootRequest struct {
|
|
||||||
MassRebootRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MassReboot starts jobs to reboot several computes
|
// MassReboot starts jobs to reboot several computes
|
||||||
func (c Compute) MassReboot(ctx context.Context, req MassRebootRequest) (bool, error) {
|
func (c Compute) MassReboot(ctx context.Context, req MassRebootRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) MassReboot(ctx context.Context, req MassRebootRequest) (bool, e
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMassRebootRequest{
|
|
||||||
MassRebootRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/massReboot"
|
url := "/cloudbroker/compute/massReboot"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) MassReboot(ctx context.Context, req MassRebootRequest) (bool, e
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MassRebootAsync starts jobs to reboot several computes with AsyncMode
|
|
||||||
func (c Compute) MassRebootAsync(ctx context.Context, req MassRebootRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMassRebootRequest{
|
|
||||||
MassRebootRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/massReboot"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type MassStartRequest struct {
|
|||||||
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"min=1"`
|
ComputeIDs []uint64 `url:"computeIds" json:"computeIds" validate:"min=1"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMassStartRequest struct {
|
|
||||||
MassStartRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MassStart starts jobs to start several computes
|
// MassStart starts jobs to start several computes
|
||||||
func (c Compute) MassStart(ctx context.Context, req MassStartRequest) (bool, error) {
|
func (c Compute) MassStart(ctx context.Context, req MassStartRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) MassStart(ctx context.Context, req MassStartRequest) (bool, err
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMassStartRequest{
|
|
||||||
MassStartRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/massStart"
|
url := "/cloudbroker/compute/massStart"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -47,25 +36,3 @@ func (c Compute) MassStart(ctx context.Context, req MassStartRequest) (bool, err
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MassStartAsync starts jobs to start several computes with AsyncMode
|
|
||||||
func (c Compute) MassStartAsync(ctx context.Context, req MassStartRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMassStartRequest{
|
|
||||||
MassStartRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/massStart"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,12 +19,6 @@ type MassStopRequest struct {
|
|||||||
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMassStopRequest struct {
|
|
||||||
MassStopRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MassStop starts jobs to stop several computes
|
// MassStop starts jobs to stop several computes
|
||||||
func (c Compute) MassStop(ctx context.Context, req MassStopRequest) (bool, error) {
|
func (c Compute) MassStop(ctx context.Context, req MassStopRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -32,14 +26,9 @@ func (c Compute) MassStop(ctx context.Context, req MassStopRequest) (bool, error
|
|||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMassStopRequest{
|
|
||||||
MassStopRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/massStop"
|
url := "/cloudbroker/compute/massStop"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) MassStop(ctx context.Context, req MassStopRequest) (bool, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MassStopAsync starts jobs to stop several computes with AsyncMode
|
|
||||||
func (c Compute) MassStopAsync(ctx context.Context, req MassStopRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMassStopRequest{
|
|
||||||
MassStopRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/massStop"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ type MigrateRequest struct {
|
|||||||
// Particular Node ID to migrate this compute to
|
// Particular Node ID to migrate this compute to
|
||||||
// Required: false
|
// Required: false
|
||||||
TargetNodeID uint64 `url:"targetNodeId,omitempty" json:"targetNodeId,omitempty"`
|
TargetNodeID uint64 `url:"targetNodeId,omitempty" json:"targetNodeId,omitempty"`
|
||||||
|
|
||||||
|
// If live migration fails, destroy compute
|
||||||
|
// on source node and recreate on the target
|
||||||
|
// Required: false
|
||||||
|
Force bool `url:"force,omitempty" json:"force,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AsyncWrapperMigrateRequest struct {
|
type AsyncWrapperMigrateRequest struct {
|
||||||
|
|||||||
@@ -15,12 +15,6 @@ type MigrateAbortRequest struct {
|
|||||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMigrateAbortRequest struct {
|
|
||||||
MigrateAbortRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MigrateAbort aborts compute migration
|
// MigrateAbort aborts compute migration
|
||||||
func (c Compute) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (string, error) {
|
func (c Compute) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -28,14 +22,9 @@ func (c Compute) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (str
|
|||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateAbortRequest{
|
|
||||||
MigrateAbortRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/migrate_abort"
|
url := "/cloudbroker/compute/migrate_abort"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
@@ -44,25 +33,3 @@ func (c Compute) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (str
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MigrateAbortAsync aborts compute migration with AsyncMode
|
|
||||||
func (c Compute) MigrateAbortAsync(ctx context.Context, req MigrateAbortRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateAbortRequest{
|
|
||||||
MigrateAbortRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/migrate_abort"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strings"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -20,57 +20,21 @@ type MigrateStorageAbortRequest struct {
|
|||||||
StatusCheck bool `url:"statusCheck" json:"statusCheck"`
|
StatusCheck bool `url:"statusCheck" json:"statusCheck"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMigrateStorageAbortRequest struct {
|
|
||||||
MigrateStorageAbortRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MigrateStorageAbort aborts complex compute migration job
|
// MigrateStorageAbort aborts complex compute migration job
|
||||||
func (c Compute) MigrateStorageAbort(ctx context.Context, req MigrateStorageAbortRequest) (bool, error) {
|
func (c Compute) MigrateStorageAbort(ctx context.Context, req MigrateStorageAbortRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateStorageAbortRequest{
|
|
||||||
MigrateStorageAbortRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/migrateStorageAbort"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MigrateStorageAbortAsync aborts complex compute migration job with AsyncMode
|
|
||||||
func (c Compute) MigrateStorageAbortAsync(ctx context.Context, req MigrateStorageAbortRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateStorageAbortRequest{
|
|
||||||
MigrateStorageAbortRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/migrateStorageAbort"
|
url := "/cloudbroker/compute/migrateStorageAbort"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(res), nil
|
result := strings.ReplaceAll(string(res), "\"", "")
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package compute
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strings"
|
||||||
|
|
||||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
)
|
)
|
||||||
@@ -15,59 +15,23 @@ type MigrateStorageCleanUpRequest struct {
|
|||||||
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMigrateStorageCleanUpRequest struct {
|
|
||||||
MigrateStorageCleanUpRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MigrateStorageCleanUp cleanup resources after finished (success of failed) complex compute migration.
|
// MigrateStorageCleanUp cleanup resources after finished (success of failed) complex compute migration.
|
||||||
// If the migration was successful, then old disks will be removed, else new (target) disks will be removed.
|
// If the migration was successful, then old disks will be removed, else new (target) disks will be removed.
|
||||||
// Do it wisely!
|
// Do it wisely!
|
||||||
func (c Compute) MigrateStorageCleanUp(ctx context.Context, req MigrateStorageCleanUpRequest) (bool, error) {
|
func (c Compute) MigrateStorageCleanUp(ctx context.Context, req MigrateStorageCleanUpRequest) (string, error) {
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateStorageCleanUpRequest{
|
|
||||||
MigrateStorageCleanUpRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/migrateStorageCleanup"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := strconv.ParseBool(string(res))
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MigrateStorageCleanUpAsync cleanup resources after finished migration with AsyncMode
|
|
||||||
func (c Compute) MigrateStorageCleanUpAsync(ctx context.Context, req MigrateStorageCleanUpRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateStorageCleanUpRequest{
|
|
||||||
MigrateStorageCleanUpRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/migrateStorageCleanup"
|
url := "/cloudbroker/compute/migrateStorageCleanup"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(res), nil
|
result := strings.ReplaceAll(string(res), "\"", "")
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,27 +19,16 @@ type MigrateToZoneRequest struct {
|
|||||||
ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"`
|
ZoneID uint64 `url:"zoneId" json:"zoneId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMigrateToZoneRequest struct {
|
// MoveToZone moves compute to new zone
|
||||||
MigrateToZoneRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MigrateToZone moves compute to new zone
|
|
||||||
func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateToZoneRequest{
|
|
||||||
MigrateToZoneRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/migrateToZone"
|
url := "/cloudbroker/compute/migrateToZone"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -51,25 +40,3 @@ func (c Compute) MigrateToZone(ctx context.Context, req MigrateToZoneRequest) (b
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MigrateToZoneAsync moves compute to new zone with AsyncMode
|
|
||||||
func (c Compute) MigrateToZoneAsync(ctx context.Context, req MigrateToZoneRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMigrateToZoneRequest{
|
|
||||||
MigrateToZoneRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/migrateToZone"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -67,9 +67,6 @@ type ListACL []ItemACL
|
|||||||
|
|
||||||
// Main information about snapshot
|
// Main information about snapshot
|
||||||
type ItemSnapshot struct {
|
type ItemSnapshot struct {
|
||||||
// Compute info
|
|
||||||
Compute RecordCompute `json:"compute"`
|
|
||||||
|
|
||||||
// List of disk IDs
|
// List of disk IDs
|
||||||
Disks []uint64 `json:"disks"`
|
Disks []uint64 `json:"disks"`
|
||||||
|
|
||||||
@@ -79,9 +76,6 @@ type ItemSnapshot 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"`
|
||||||
}
|
}
|
||||||
@@ -397,8 +391,8 @@ type ItemDisk struct {
|
|||||||
// Access Control List
|
// Access Control List
|
||||||
ACL ItemACL `json:"acl"`
|
ACL ItemACL `json:"acl"`
|
||||||
|
|
||||||
// Discard
|
// BLK Discard
|
||||||
Discard string `json:"discard"`
|
BLKDiscard bool `json:"blkdiscard"`
|
||||||
|
|
||||||
// Block Size
|
// Block Size
|
||||||
BlockSize string `json:"block_size"`
|
BlockSize string `json:"block_size"`
|
||||||
@@ -552,9 +546,6 @@ type ItemDisk struct {
|
|||||||
|
|
||||||
// UpdatedTime
|
// UpdatedTime
|
||||||
UpdatedTime uint64 `json:"updatedTime"`
|
UpdatedTime uint64 `json:"updatedTime"`
|
||||||
|
|
||||||
// Read-only
|
|
||||||
ReadOnly bool `json:"read_only"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ItemReplication struct {
|
type ItemReplication struct {
|
||||||
@@ -732,9 +723,6 @@ type InfoCompute struct {
|
|||||||
// Clone reference
|
// Clone reference
|
||||||
CloneReference uint64 `json:"cloneReference"`
|
CloneReference uint64 `json:"cloneReference"`
|
||||||
|
|
||||||
// Clock
|
|
||||||
Clock string `json:"clock"`
|
|
||||||
|
|
||||||
// List clone IDs
|
// List clone IDs
|
||||||
Clones []uint64 `json:"clones"`
|
Clones []uint64 `json:"clones"`
|
||||||
|
|
||||||
@@ -837,9 +825,6 @@ type InfoCompute struct {
|
|||||||
// PreferredCPU
|
// PreferredCPU
|
||||||
PreferredCPU []int64 `json:"preferredCpu"`
|
PreferredCPU []int64 `json:"preferredCpu"`
|
||||||
|
|
||||||
// CPU alignment profile
|
|
||||||
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
|
|
||||||
|
|
||||||
// Qemu_quest
|
// Qemu_quest
|
||||||
QemuQuest QemuQuest `json:"qemu_guest"`
|
QemuQuest QemuQuest `json:"qemu_guest"`
|
||||||
|
|
||||||
@@ -927,12 +912,6 @@ type QemuQuest struct {
|
|||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CPUAlignmentProfile struct {
|
|
||||||
Model string `json:"model"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Vendor string `json:"vendor"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Information about libvirt settings
|
// Information about libvirt settings
|
||||||
type LibvirtSettings struct {
|
type LibvirtSettings struct {
|
||||||
// TX mode
|
// TX mode
|
||||||
@@ -1007,9 +986,6 @@ type RecordCompute struct {
|
|||||||
// Clone reference
|
// Clone reference
|
||||||
CloneReference uint64 `json:"cloneReference"`
|
CloneReference uint64 `json:"cloneReference"`
|
||||||
|
|
||||||
// Clock
|
|
||||||
Clock string `json:"clock"`
|
|
||||||
|
|
||||||
// List clone IDs
|
// List clone IDs
|
||||||
Clones []uint64 `json:"clones"`
|
Clones []uint64 `json:"clones"`
|
||||||
|
|
||||||
@@ -1139,9 +1115,6 @@ type RecordCompute struct {
|
|||||||
// PreferredCPU
|
// PreferredCPU
|
||||||
PreferredCPU []int64 `json:"preferredCpu"`
|
PreferredCPU []int64 `json:"preferredCpu"`
|
||||||
|
|
||||||
// CPU alignment profile
|
|
||||||
CPUAlignmentProfile CPUAlignmentProfile `json:"cpu_alignment_profile"`
|
|
||||||
|
|
||||||
// Qemu_quest
|
// Qemu_quest
|
||||||
QemuQuest QemuQuest `json:"qemu_guest"`
|
QemuQuest QemuQuest `json:"qemu_guest"`
|
||||||
|
|
||||||
@@ -1334,9 +1307,6 @@ type InfoDisk struct {
|
|||||||
|
|
||||||
// SEP ID
|
// SEP ID
|
||||||
SepID int64 `json:"sepId"`
|
SepID int64 `json:"sepId"`
|
||||||
|
|
||||||
// Read-only
|
|
||||||
ReadOnly bool `json:"read_only"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// List computes
|
// List computes
|
||||||
|
|||||||
@@ -34,27 +34,16 @@ type MoveToRGRequest struct {
|
|||||||
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
ForceStop bool `url:"forceStop,omitempty" json:"forceStop,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperMoveToRGRequest struct {
|
|
||||||
MoveToRGRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MoveToRG moves compute instance to new resource group
|
// MoveToRG moves compute instance to new resource group
|
||||||
func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error) {
|
func (c Compute) Validate(ctx context.Context, req MoveToRGRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperMoveToRGRequest{
|
|
||||||
MoveToRGRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/moveToRg"
|
url := "/cloudbroker/compute/moveToRg"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
@@ -66,25 +55,3 @@ func (c Compute) MoveToRG(ctx context.Context, req MoveToRGRequest) (bool, error
|
|||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MoveToRGAsync moves compute instance to new resource group with AsyncMode
|
|
||||||
func (c Compute) MoveToRGAsync(ctx context.Context, req MoveToRGRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperMoveToRGRequest{
|
|
||||||
MoveToRGRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/moveToRg"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -53,9 +53,9 @@ type NetAttachRequest struct {
|
|||||||
// Required: false
|
// Required: false
|
||||||
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
SDNSegmentID string `url:"sdn_segment_id,omitempty" json:"sdn_segment_id,omitempty"`
|
||||||
|
|
||||||
// SDN Object Group IDs
|
// SDN Object Group ID
|
||||||
// Required: false
|
// Required: false
|
||||||
SDNObjectGroupIDs []string `url:"sdn_object_group_ids,omitempty" json:"sdn_object_group_ids,omitempty"`
|
SDNObjectGroupID string `url:"sdn_object_group_id,omitempty" json:"sdn_object_group_id,omitempty"`
|
||||||
|
|
||||||
// SDN Logical Port Display Name
|
// SDN Logical Port Display Name
|
||||||
// Required: false
|
// Required: false
|
||||||
@@ -83,12 +83,6 @@ type NetAttachRequest struct {
|
|||||||
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
Enabled interface{} `url:"enabled,omitempty" json:"enabled,omitempty" validate:"omitempty,isBool"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type wrapperNetAttachRequest struct {
|
|
||||||
NetAttachRequest
|
|
||||||
|
|
||||||
AsyncMode bool `url:"asyncMode"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NetAttach attaches network to compute and gets info about network
|
// NetAttach attaches network to compute and gets info about network
|
||||||
func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNetAttach, error) {
|
func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNetAttach, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
@@ -96,14 +90,9 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
|
|||||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
reqWrapped := wrapperNetAttachRequest{
|
|
||||||
NetAttachRequest: req,
|
|
||||||
AsyncMode: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/netAttach"
|
url := "/cloudbroker/compute/netAttach"
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -117,25 +106,3 @@ func (c Compute) NetAttach(ctx context.Context, req NetAttachRequest) (*RecordNe
|
|||||||
|
|
||||||
return &info, nil
|
return &info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetAttachAsync attaches network to compute with AsyncMode
|
|
||||||
func (c Compute) NetAttachAsync(ctx context.Context, req NetAttachRequest) (string, error) {
|
|
||||||
err := validators.ValidateRequest(req)
|
|
||||||
if err != nil {
|
|
||||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
|
||||||
}
|
|
||||||
|
|
||||||
reqWrapped := wrapperNetAttachRequest{
|
|
||||||
NetAttachRequest: req,
|
|
||||||
AsyncMode: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
url := "/cloudbroker/compute/netAttach"
|
|
||||||
|
|
||||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(res), nil
|
|
||||||
}
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user