Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00994516ba | ||
|
|
bc8c2b40e9 | ||
|
|
5825bdfa9e | ||
|
|
70edc100d5 |
No files matched your search
+60
-60
@@ -1,19 +1,30 @@
|
||||
## Version 16.6.0
|
||||
## Version 16.10.0
|
||||
|
||||
|
||||
### Deprecated
|
||||
|
||||
Перечисленные методы будут удалены в `v17.0.0`
|
||||
Перечисленные методы будут удалены в `v17.0`
|
||||
|
||||
| Метод | CloudAPI | CloudBroker |
|
||||
| --- | --- | --- |
|
||||
| `account/AddUser` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `account/DeleteUser` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `account/UpdateUser` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `compute/CreateTemplate` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `compute/CreateTemplateFromBlank` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `compute/DiskQOS` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `compute/Migrate` | :x: | :heavy_check_mark: |
|
||||
| `compute/MigrateAbort` | :x: | :heavy_check_mark: |
|
||||
| `compute/MigrateStorage` | :x: | :heavy_check_mark: |
|
||||
| `compute/MigrateStorageAbort` | :x: | :heavy_check_mark: |
|
||||
| `compute/MigrateStorageCleanUp` | :x: | :heavy_check_mark: |
|
||||
| `compute/MigrateStorageInfo` | :x: | :heavy_check_mark: |
|
||||
| `compute/MigrateStorageList` | :x: | :heavy_check_mark: |
|
||||
| `compute/UserGrant` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `compute/UserList` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `compute/UserRevoke` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `compute/UserUpdate` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `disks/FromPlatformDisk` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `rg/AccessGrant` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `rg/AccessRevoke` | :heavy_check_mark: | :heavy_check_mark: |
|
||||
| `sep/ConfigFieldEdit` | :x: | :heavy_check_mark: |
|
||||
@@ -22,77 +33,66 @@
|
||||
|
||||
### Добавлено
|
||||
|
||||
#### apiaccess
|
||||
#### Общее
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1091 | Опциональное поле `UserID` в структуру запроса `ListRequest` в cloudbroker/apiaccess |
|
||||
| BGOS-1153 | Валидаторы `migrateV2UserMatch` и `migrateV2Status` |
|
||||
|
||||
#### audit
|
||||
#### account
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1088 | Опциональные поля `DiskID` и `VMFolderID` в структуру запроса `ListRequest` в cloudapi/audit |
|
||||
| BGOS-1088 | Опциональные поля `DiskID` и `VMFolderID` в структуру запроса `ListRequest` в cloudbroker/audit |
|
||||
|
||||
#### extnet
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1092 | Метод `EnableAsync` в cloudbroker/extnet |
|
||||
|
||||
#### node
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1065 | Структура запроса `RemoveSSHIdentityRequest` и метод `RemoveSSHIdentity` в cloudbroker/node |
|
||||
| BGOS-1101 | Вычисляемое поле `SharedLocks` в структуру ответа `ItemNode` в cloudbroker/node |
|
||||
| BGOS-1086 | Вычисляемые поля `LinkState` и `LinkSpeed` в структуру ответа `ItemNicInfo` в cloudbroker/node |
|
||||
|
||||
#### vins
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1102 | Вычисляемое поле `EnableDefaultGateway` в структуры ответа `VNFsConfig` и `ItemInterface` в cloudbroker/vins |
|
||||
| BGOS-1102 | Вычисляемое поле `EnableDefaultGateway` в структуры ответа `RecordDHCPConfig` и `ItemVNFInterface` в cloudapi/vins |
|
||||
|
||||
#### user
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1064 | Опциональное поле `ServiceAccount` в структуру запроса `CreateRequest` в clooudbroker/user |
|
||||
| BGOS-1064 | Структура запроса `UpdateServiceAccountRequest` и метод `UpdateServiceAccount` в clooudbroker/user |
|
||||
|
||||
### Изменено
|
||||
|
||||
#### apiaccess
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1091 | Тип вычисляемых полей `Account`, `APIAccess`, `AuditCollector`, `Backup`, `BackupCreator`, `BService`, `Compute`, `Disks`, `DPDKNet`, `Eco`, `ExtNet`, `FlIPgroup`, `Grid`, `Group`, `Health`, `Image`, `K8CI`, `K8S`, `KVMX86`, `LB`, `Metering`, `Milestones`, `PCIDevice`, `PGPU`, `Prometheus`, `RG`, `SecurityGroup`, `Sep`, `StoragePolicy`, `Tasks`, `TLock`, `Trunk`, `User`, `VFPool`, `VGPU`, `VINS`, `VMFolder`, `VNFDev`, `ZeroAccess` и `Zone` со `string` на `interface{}` в структуре ответа `CloudBrokerEndpoints` в cloudbroker/apiaccess |
|
||||
| BGOS-1161 | Методы `AddACLAccessAsync`, `AddUserAsync`, `DeleteACLAccessAsync`, `DeleteUserAsync`, `RestoreAsync`, `UpdateACLAccessAsync`, `UpdateAsync` и `UpdateUserAsync` в cloudapi/account |
|
||||
| BGOS-1161 | Структуры запроса `wrapperAddACLAccessRequest`, `wrapperAddUserRequest`, `wrapperDelACLAccessRequest`, `wrapperDeleteUserRequest`, `wrapperRestoreRequest`, `wrapperUpdateACLAccessRequest`, `wrapperUpdateRequest` и `wrapperUpdateUserRequest` в cloudapi/account |
|
||||
| BGOS-1161 | Методы `AddACLAccessAsync`, `AddStoragePolicyAsync`, `AddUserAsync`, `AddZoneAsync`, `CreateAsync`, `DelStoragePolicyAsync`, `DeleteACLAccessAsync`, `DeleteAccountsAsync`, `DeleteAsync`, `DeleteUserAsync`, `DisableAccountsAsync`, `EnableAccountsAsync`, `GrantAccessTemplatesAsync`, `RemoveZoneAsync`, `RestoreAsync`, `RevokeAccessTemplatesAsync`, `SetCPUAllocationParameterAsync`, `SetCPUAllocationRatioAsync`, `UpdateACLAccessAsync`, `UpdateAsync`, `UpdateComputeFeaturesAsync`, `UpdateResourceTypesAsync` и `UpdateUserAsync` в cloudbroker/account |
|
||||
| BGOS-1161 | Структуры запроса `wrapperAddACLAccessRequest`, `wrapperAddStoragePolicyRequest`, `wrapperAddUserRequest`, `wrapperAddZoneRequest`, `wrapperCreateRequest`, `wrapperDelACLAccessRequest`, `wrapperDelStoragePolicyRequest`, `wrapperDeleteAccountsRequest`, `wrapperDeleteRequest`, `wrapperDeleteUserRequest`, `wrapperDisableAccountsRequest`, `wrapperEnableAccountsRequest`, `wrapperGrantAccessTemplatesRequest`, `wrapperRemoveZoneRequest`, `wrapperRestoreRequest`, `wrapperRevokeAccessTemplatesRequest`, `wrapperSetCPUAllocationParameterRequest`, `wrapperSetCPUAllocationRatioRequest`, `wrapperUpdateACLAccessRequest`, `wrapperUpdateComputeFeaturesRequest`, `wrapperUpdateRequest`, `wrapperUpdateResourceTypesRequest` и `wrapperUpdateUserRequest` в cloudbroker/account |
|
||||
|
||||
#### compute
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1089 | Значение по умолчанию поля `MemoryBalloonMode` с `auto` на `none` в структуре запроса `UpdateRequest` в cloudapi/compute |
|
||||
| BGOS-1089 | Значение по умолчанию поля `MemoryBalloonMode` с `auto` на `none` в структуре запроса `UpdateRequest` в cloudbroker/compute |
|
||||
| BGOS-1152 | Опциональные поля `CopyParallelism` и `BandwidthBytesPerSecond` в структуру запроса `MigrateV2Request` в cloudbroker/compute |
|
||||
| BGOS-1152 | Вычисляемые поля `CopyParallelism`, `BandwidthBytesPerSecond`, `DiskPlanReady`, `ExecutionKind`, `OfflineCommitStarted`, `ReservesComputeResources`, `RequestedStorage`, `SourceDisks` и `TargetShadowCompute` в структуру ответа `MigrateV2Record` в cloudbroker/compute |
|
||||
| BGOS-1152 | Вычисляемые поля `CopyNodeID`, `CopyState` и `WriterStopped` в структуру ответа `Disk` в cloudbroker/compute |
|
||||
| BGOS-1152 | Вычисляемые поля `Items` и `PercentIsEstimated` в структуру ответа `ProgressDisks` в cloudbroker/compute |
|
||||
| BGOS-1152 | Опциональные поля `AccountID`, `RGID`, `User`, `UserMatch`, `UserIsNull`, `SourceNodeIDIsNull` и `TargetNodeIDIsNull` в структуру запроса `MigrateV2ListRequest` в cloudbroker/compute |
|
||||
| BGOS-1152 | Вычисляемые поля `CopyParallelism`, `BandwidthBytesPerSecond`, `DiskPlanReady`, `ExecutionKind`, `OfflineCommitStarted`, `RequestedStorage` и `SourceDisks` в структуру ответа `MigrateV2Item` в cloudbroker/compute |
|
||||
|
||||
#### kvmx86
|
||||
#### disks
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1089 | Значение по умолчанию поля `MemoryBalloonMode` с `auto` на `none` в структурах запроса `CreateRequest` и `CreateBlankRequest` в cloudapi/kvmx86 |
|
||||
| BGOS-1089 | Значение по умолчанию поля `MemoryBalloonMode` с `auto` на `none` в структурах запроса `CreateRequest`, `CreateBlankRequest` и `MassCreateRequest` в cloudbroker/kvmx86 |
|
||||
|
||||
#### sep
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1084 | Тэг `url` поля `AsyncMode` с `sync` на `async_mode` в структурах запроса `SharedLockStartRequest` и `SharedLockStopRequest` в cloudbroker/sep |
|
||||
|
||||
|
||||
### Исправлено
|
||||
|
||||
#### session
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1085 | Тип опционального поля `SID` с `uint64` на `string` в cloudbroker/session |
|
||||
| BGOS-1085 | Тэг опционального поля `SortBy` с `sortBy` на `sort_by` в cloudbroker/session |
|
||||
|
||||
### Удалено
|
||||
| BGOS-1153 | Методы `MigrateV2`, `MigrateV2Abort`, `MigrateV2AbortRaw`, `MigrateV2Cleanup`, `MigrateV2Get`, `MigrateV2GetRaw`, `MigrateV2List`, `MigrateV2ListRaw`, `MigrateV2Resolve` и `MigrateV2ResolveRaw` в cloudbroker/disks |
|
||||
| BGOS-1153 | Структуры запроса `MigrateV2Request`, `MigrateV2Storage`, `MigrateV2Target`, `MigrateV2AbortRequest`, `MigrateV2CleanupRequest`, `MigrateV2GetRequest`, `MigrateV2ListRequest` и `MigrateV2ResolveRequest` в cloudbroker/disks |
|
||||
| BGOS-1153 | Структуры ответа `MigrateV2Record`, `ListMigrateV2`, `MigrateV2Item`, `MigrateV2SourceDisk`, `MigrateV2RequestedStorage`, `MigrateV2RequestedTarget`, `MigrateV2Origin`, `MigrateV2Progress`, `MigrateV2Observation`, `MigrateV2Memory`, `MigrateV2ProgressDisks`, `MigrateV2ProgressItem`, `MigrateV2Disk`, `MigrateV2CleanupInfo`, `MigrateV2Resolution`, `MigrateV2AbortRecord`, `MigrateV2AbortResult` и `MigrateV2ResolveRecord` в cloudbroker/disks |
|
||||
| BGOS-1162 | Вычисляемые поля `Bandwidth`, `CopyRate`, `LastSync`, `PairID`, `ProfileID`, `ScheduleID`, `ScheduleName`, `Status`, `Target` и `Type` в структуру ответа `ItemReplication` в cloudapi/disks |
|
||||
| BGOS-1162 | Вычисляемые поля `Bandwidth`, `CopyRate`, `LastSync`, `PairID`, `ProfileID`, `ScheduleID`, `ScheduleName`, `Status`, `Target` и `Type` в структуру ответа `ItemReplication` в cloudbroker/disks |
|
||||
|
||||
#### node
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1083 | Опциональное поле `Message` из структуры запроса `EnableRequest` в cloudbroker/node |
|
||||
| BGOS-1151 | Вычисляемое поле `PhysicalNetState` в структуру ответа `RecordNode` в cloudbroker/node |
|
||||
|
||||
#### zone
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1154 | Вычисляемое поле `TaskDiskTimeout` в структуры ответа `RecordZone`, `ItemZone` в cloudbroker/zone |
|
||||
| BGOS-1154 | Вычисляемое поле `TaskDiskTimeout` в структуры ответа `RecordZone`, `ItemZone` в cloudapi/zone |
|
||||
|
||||
### Удалено
|
||||
|
||||
#### basismpm
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1163 | Опциональное поле `LogFile` из структур запроса `StartRequest` и `UpdateRequest` в cloudbroker/basismpm |
|
||||
|
||||
#### compute
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1152 | Вычисляемые поля `Scope`, `TargetDevs`, `CompletedDisks` и `CurrentDisk` из структуры ответа `ProgressDisks` в cloudbroker/compute |
|
||||
|
||||
### Изменено
|
||||
|
||||
#### account
|
||||
| Идентификатор задачи | Описание |
|
||||
| --- | --- |
|
||||
| BGOS-1161 | Метод `Restore` выполняется в синхронном режиме (`async_mode=false`) в cloudapi/account |
|
||||
| BGOS-1161 | Методы `Delete`, `DeleteAccounts`, `DisableAccounts`, `EnableAccounts` и `Restore` выполняются в синхронном режиме (`async_mode=false`) в cloudbroker/account |
|
||||
| BGOS-1161 | Тип возвращаемого значения методов `DeleteAccounts`, `DisableAccounts` и `EnableAccounts` с `string` на `[]uint64` в cloudbroker/account |
|
||||
@@ -139,6 +139,7 @@ go get -u repository.basistech.ru/BASIS/dynamix-golang-sdk/v16
|
||||
- `Audit` - получение информации о событиях системы;
|
||||
- `APIAccess` - управление доступом к API и его объектам;
|
||||
- `Backup` - управление резервным копированием;
|
||||
- `BasisMPM` - управление в случае нехватки памяти;
|
||||
- `BService` - управление группами виртуальных машин (computes);
|
||||
- `Compute` - управление виртуальными машинами (индивидуально);
|
||||
- `Disks` - управление виртуальными дисками;
|
||||
@@ -352,6 +353,7 @@ func main() {
|
||||
- `pkg/cloudbroker/audit` - для `Audit`
|
||||
- `pkg/cloudbroker/apiaccess` - для `APIAccess`
|
||||
- `pkg/cloudbroker/backup` - для `Backup`
|
||||
- `pkg/cloudbroker/basismpm` - для `BasisMPM`
|
||||
- `pkg/cloudbroker/bservice` - для `Basic Service`
|
||||
- `pkg/cloudbroker/compute` - для `Compute`
|
||||
- `pkg/cloudbroker/disks` - для `Disks`
|
||||
|
||||
@@ -210,7 +210,7 @@ func (dc *DecortClient) getToken(ctx context.Context) error {
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return fmt.Errorf("cannot get token: %s", tokenBytes)
|
||||
return newHTTPError("cannot get token", resp.StatusCode, tokenBytes)
|
||||
}
|
||||
|
||||
// save token in config
|
||||
@@ -297,8 +297,7 @@ func (dc *DecortClient) do(req *http.Request, ctype string) ([]byte, error) {
|
||||
}
|
||||
|
||||
// handle errors with status code other than 200
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||
return nil, newHTTPError("could not execute request", resp.StatusCode, respBytes)
|
||||
}
|
||||
|
||||
// isConnectionError checks if given error falls within specific and associated connection errors
|
||||
@@ -444,7 +443,7 @@ func getTokenExp(token string) (time.Time, error) {
|
||||
|
||||
exp, ok := claims["exp"]
|
||||
if !ok {
|
||||
return time.Time{}, fmt.Errorf("exp time bot found")
|
||||
return time.Time{}, fmt.Errorf("exp time not found")
|
||||
}
|
||||
|
||||
expTime := time.Unix(int64(exp.(float64)), 0)
|
||||
|
||||
+7
-13
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
@@ -127,7 +126,7 @@ func (bdc *BVSDecortClient) DecortApiCall(ctx context.Context, method, url strin
|
||||
}
|
||||
|
||||
// get token and retry in case of access denied
|
||||
if err.Error() == "access is denied" {
|
||||
if HasStatusCode(err, http.StatusUnauthorized) {
|
||||
_, err = bdc.GetToken(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -193,7 +192,7 @@ func (bdc *BVSDecortClient) DecortApiCallCtype(ctx context.Context, method, url,
|
||||
}
|
||||
|
||||
// get token and retry in case of access denied
|
||||
if err.Error() == "access is denied" {
|
||||
if HasStatusCode(err, http.StatusUnauthorized) {
|
||||
_, err = bdc.GetToken(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -243,7 +242,7 @@ func (bdc *BVSDecortClient) DecortApiCallMP(ctx context.Context, method, url str
|
||||
}
|
||||
|
||||
// get token and retry in case of access denied
|
||||
if err.Error() == "access is denied" {
|
||||
if HasStatusCode(err, http.StatusUnauthorized) {
|
||||
_, err = bdc.GetToken(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -287,7 +286,7 @@ func (bdc *BVSDecortClient) GetToken(ctx context.Context) (config.Token, error)
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return config.Token{}, fmt.Errorf("cannot get token: %s", tokenBytes)
|
||||
return config.Token{}, newHTTPError("cannot get token", resp.StatusCode, tokenBytes)
|
||||
}
|
||||
|
||||
// save token in config
|
||||
@@ -346,7 +345,7 @@ func (bdc *BVSDecortClient) RefreshToken(ctx context.Context) (config.Token, err
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return config.Token{}, fmt.Errorf("cannot refresh token: %s", tokenBytes)
|
||||
return config.Token{}, newHTTPError("cannot refresh token", resp.StatusCode, tokenBytes)
|
||||
}
|
||||
|
||||
// save token in config
|
||||
@@ -452,17 +451,12 @@ func (bdc *BVSDecortClient) do(req *http.Request, ctype string) ([]byte, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// handle access denied and successful request
|
||||
if resp.StatusCode == 401 {
|
||||
return respBytes, errors.New("access is denied")
|
||||
}
|
||||
if resp.StatusCode == 200 {
|
||||
return respBytes, nil
|
||||
}
|
||||
|
||||
// handle errors with other status codes
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||
// handle errors with status code other than 200 (401 triggers token refresh in callers)
|
||||
return nil, newHTTPError("could not execute request", resp.StatusCode, respBytes)
|
||||
}
|
||||
|
||||
func trimBVSConfig(cfg *config.BVSConfig) config.BVSConfig {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package decortsdk
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// HTTPError is returned when the API responds with a non-successful status code.
|
||||
type HTTPError struct {
|
||||
StatusCode int
|
||||
Body []byte
|
||||
}
|
||||
|
||||
func (e *HTTPError) Error() string {
|
||||
return string(e.Body)
|
||||
}
|
||||
|
||||
// IsNotFound reports whether err contains an HTTPError with status 404.
|
||||
func IsNotFound(err error) bool {
|
||||
return HasStatusCode(err, http.StatusNotFound)
|
||||
}
|
||||
|
||||
// HasStatusCode reports whether err contains an HTTPError with the given status code.
|
||||
func HasStatusCode(err error, code int) bool {
|
||||
var httpErr *HTTPError
|
||||
return errors.As(err, &httpErr) && httpErr.StatusCode == code
|
||||
}
|
||||
|
||||
func newHTTPError(prefix string, statusCode int, body []byte) error {
|
||||
return fmt.Errorf("%s: %w", prefix, &HTTPError{StatusCode: statusCode, Body: body})
|
||||
}
|
||||
@@ -500,3 +500,90 @@ func memoryBalloonModeValidator(fe validator.FieldLevel) bool {
|
||||
|
||||
return IsInSlice(fieldValue, memoryBalloonModeValues)
|
||||
}
|
||||
|
||||
func migrateV2ModeValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
return IsInSlice(fieldValue, migrateV2ModeValues)
|
||||
}
|
||||
|
||||
func migrateV2UserMatchValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
return IsInSlice(fieldValue, migrateV2UserMatchValues)
|
||||
}
|
||||
|
||||
func migrateV2StatusValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
return IsInSlice(fieldValue, migrateV2StatusValues)
|
||||
}
|
||||
|
||||
// pressureThresholdValidator checks if PressureThreshold is in range from 5 to 50
|
||||
func pressureThresholdValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Float()
|
||||
return fieldValue >= float64(pressureThresholdMin) && fieldValue <= float64(pressureThresholdMax)
|
||||
}
|
||||
|
||||
// deflateThresholdValidator checks if DeflateThreshold is in range from 10 to 70
|
||||
func deflateThresholdValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Float()
|
||||
return fieldValue >= float64(deflateThresholdMin) && fieldValue <= float64(deflateThresholdMax)
|
||||
}
|
||||
|
||||
func bufferPCTValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Float()
|
||||
return fieldValue >= float64(bufferPCTMin) && fieldValue <= float64(bufferPCTMax)
|
||||
}
|
||||
|
||||
func guaranteedPCTValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Float()
|
||||
return fieldValue >= float64(guaranteedPCTMin) && fieldValue <= float64(guaranteedPCTMax)
|
||||
}
|
||||
|
||||
func guaranteedABSMinValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Uint()
|
||||
return fieldValue >= uint64(guaranteedABSMinMin) && fieldValue <= uint64(guaranteedABSMinMax)
|
||||
}
|
||||
|
||||
func shrinkThresholdPCTValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Float()
|
||||
return fieldValue >= float64(shrinkThresholdPCTMin) && fieldValue <= float64(shrinkThresholdPCTMax)
|
||||
}
|
||||
|
||||
func balloonMaxShrinkPCTValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Float()
|
||||
return fieldValue >= float64(balloonMaxShrinkPCTMin) && fieldValue <= float64(balloonMaxShrinkPCTMax)
|
||||
}
|
||||
|
||||
func balloonMaxGrowPCTValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Float()
|
||||
return fieldValue >= float64(balloonMaxGrowPCTMin) && fieldValue <= float64(balloonMaxGrowPCTMax)
|
||||
}
|
||||
|
||||
func vmChangeCooldownValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Uint()
|
||||
return fieldValue >= uint64(vmChangeCooldownMin) && fieldValue <= uint64(vmChangeCooldownMax)
|
||||
}
|
||||
|
||||
func emergencyReturnCooldownValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Uint()
|
||||
return fieldValue >= uint64(emergencyReturnCooldownMin) && fieldValue <= uint64(emergencyReturnCooldownMax)
|
||||
}
|
||||
|
||||
func majorFaultThresholdValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().Uint()
|
||||
return fieldValue >= uint64(majorFaultThresholdMin) && fieldValue <= uint64(majorFaultThresholdMax)
|
||||
}
|
||||
|
||||
func logLevelValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
return IsInSlice(fieldValue, logLevelValues)
|
||||
}
|
||||
|
||||
func sepTypesValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
return IsInSlice(fieldValue, sepTypesValues)
|
||||
}
|
||||
|
||||
func userMatchValidator(fe validator.FieldLevel) bool {
|
||||
fieldValue := fe.Field().String()
|
||||
return IsInSlice(fieldValue, userMatchValues)
|
||||
}
|
||||
@@ -367,6 +367,28 @@ func errorMessage(fe validator.FieldError) string {
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(sepTechStatusValues))
|
||||
|
||||
case "sepTypes":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(sepTypesValues))
|
||||
case "migrateV2UserMatch":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(migrateV2UserMatchValues))
|
||||
case "migrateV2Status":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(migrateV2StatusValues))
|
||||
|
||||
case "userMatch":
|
||||
return fmt.Sprintf("%s %s must be one of the following: %s",
|
||||
prefix,
|
||||
fe.Field(),
|
||||
joinValues(userMatchValues))
|
||||
}
|
||||
|
||||
return fe.Error()
|
||||
|
||||
@@ -101,6 +101,11 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("userMatch", userMatchValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("computeDataDisks", computeDataDisksValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -336,5 +341,82 @@ func registerAllValidators(validate *validator.Validate) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("migrateV2Mode", migrateV2ModeValidator)
|
||||
|
||||
err = validate.RegisterValidation("pressureThreshold", pressureThresholdValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("deflateThreshold", deflateThresholdValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("bufferPCT", bufferPCTValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("guaranteedPCT", guaranteedPCTValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("guaranteedABSMin", guaranteedABSMinValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("shrinkThresholdPCT", shrinkThresholdPCTValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("balloonMaxShrinkPCT", balloonMaxShrinkPCTValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("balloonMaxGrowPCT", balloonMaxGrowPCTValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("vmChangeCooldown", vmChangeCooldownValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("emergencyReturnCooldown", emergencyReturnCooldownValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("majorFaultThreshold", majorFaultThresholdValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("logLevel", logLevelValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("sepTypes", sepTypesValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("migrateV2UserMatch", migrateV2UserMatchValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = validate.RegisterValidation("migrateV2Status", migrateV2StatusValidator)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -63,7 +63,7 @@ var (
|
||||
|
||||
loaderTypeValues = []string{"linux", "windows", "unknown"}
|
||||
|
||||
sepTypeValues = []string{"hitachi", "dorado", "tatlin", "shared", "local", "des", "ustor"}
|
||||
sepTypeValues = []string{"hitachi", "dorado", "tatlin", "shared", "local", "des", "ustor", "aerodisk"}
|
||||
|
||||
languageValues = []string{"ru", "en"}
|
||||
|
||||
@@ -84,6 +84,18 @@ var (
|
||||
watchdogActionValues = []string{"reset", "shutdown", "poweroff", "pause", "none"}
|
||||
|
||||
memoryBalloonModeValues = []string{"auto", "legacy", "none"}
|
||||
|
||||
migrateV2ModeValues = []string{"compute", "disks", "compute_and_disks"}
|
||||
|
||||
migrateV2UserMatchValues = []string{"exact", "prefix"}
|
||||
|
||||
migrateV2StatusValues = []string{"QUEUED", "VALIDATING", "PREPARING", "MIGRATING", "COMPLETING", "ABORTING", "NEEDS_ATTENTION", "COMPLETED", "PARTIALLY_COMPLETED", "ABORTED", "ERROR", "RESOLVED"}
|
||||
|
||||
logLevelValues = []string{"DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"}
|
||||
|
||||
sepTypesValues = []string{"DES", "DORADO", "HITACHI", "LOCAL", "SHARED", "TATLIN", "USTOR", "AERODISK"}
|
||||
|
||||
userMatchValues = []string{"exact", "prefix"}
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -92,4 +104,37 @@ const (
|
||||
|
||||
trunkTagsMin = 1
|
||||
trunkTagsMax = 4095
|
||||
|
||||
pressureThresholdMin = 5
|
||||
pressureThresholdMax = 50
|
||||
|
||||
deflateThresholdMin = 10
|
||||
deflateThresholdMax = 70
|
||||
|
||||
bufferPCTMin = 5
|
||||
bufferPCTMax = 50
|
||||
|
||||
guaranteedPCTMin = 10
|
||||
guaranteedPCTMax = 50
|
||||
|
||||
guaranteedABSMinMin = 256
|
||||
guaranteedABSMinMax = 4096
|
||||
|
||||
shrinkThresholdPCTMin = 30
|
||||
shrinkThresholdPCTMax = 90
|
||||
|
||||
balloonMaxShrinkPCTMin = 5
|
||||
balloonMaxShrinkPCTMax = 25
|
||||
|
||||
balloonMaxGrowPCTMin = 5
|
||||
balloonMaxGrowPCTMax = 25
|
||||
|
||||
vmChangeCooldownMin = 30
|
||||
vmChangeCooldownMax = 300
|
||||
|
||||
emergencyReturnCooldownMin = 60
|
||||
emergencyReturnCooldownMax = 1800
|
||||
|
||||
majorFaultThresholdMin = 1
|
||||
majorFaultThresholdMax = 10000
|
||||
)
|
||||
+2
-3
@@ -210,7 +210,7 @@ func (ldc *LegacyDecortClient) getToken(ctx context.Context) error {
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return fmt.Errorf("cannot get token: %s", tokenBytes)
|
||||
return newHTTPError("cannot get token", resp.StatusCode, tokenBytes)
|
||||
}
|
||||
|
||||
// save token in config
|
||||
@@ -291,8 +291,7 @@ func (ldc *LegacyDecortClient) do(req *http.Request, ctype string) ([]byte, erro
|
||||
}
|
||||
|
||||
// handle errors with status code other than 200
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||
return nil, newHTTPError("could not execute request", resp.StatusCode, respBytes)
|
||||
}
|
||||
|
||||
func trimLegacyConfig(cfg *config.LegacyConfig) config.LegacyConfig {
|
||||
|
||||
@@ -17,6 +17,12 @@ type AddACLAccessRequest struct {
|
||||
APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperAddACLAccessRequest struct {
|
||||
AddACLAccessRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// AddACLAccess adds ACL access to an account.
|
||||
func (a Account) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -26,7 +32,12 @@ func (a Account) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (boo
|
||||
|
||||
url := "/cloudapi/account/add_acl_access"
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
reqWrapped := wrapperAddACLAccessRequest{
|
||||
AddACLAccessRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -38,3 +49,25 @@ func (a Account) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (boo
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AddACLAccessAsync adds ACL access to an account in async mode
|
||||
func (a Account) AddACLAccessAsync(ctx context.Context, req AddACLAccessRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/add_acl_access"
|
||||
|
||||
reqWrapped := wrapperAddACLAccessRequest{
|
||||
AddACLAccessRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -26,9 +26,15 @@ type AddUserRequest struct {
|
||||
AccessType string `url:"accesstype" json:"accesstype" validate:"required,accessType"`
|
||||
}
|
||||
|
||||
type wrapperAddUserRequest struct {
|
||||
AddUserRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// AddUser gives a user access rights.
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -37,7 +43,12 @@ func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error)
|
||||
|
||||
url := "/cloudapi/account/addUser"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperAddUserRequest{
|
||||
AddUserRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -49,3 +60,27 @@ func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AddUserAsync gives a user access rights in async mode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) AddUserAsync(ctx context.Context, req AddUserRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/addUser"
|
||||
|
||||
reqWrapped := wrapperAddUserRequest{
|
||||
AddUserRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -16,6 +16,12 @@ type DelACLAccessRequest struct {
|
||||
APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperDelACLAccessRequest struct {
|
||||
DelACLAccessRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// DelACLAccess deletes ACL access from an account.
|
||||
func (a Account) DeleteACLAccess(ctx context.Context, req DelACLAccessRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -25,7 +31,12 @@ func (a Account) DeleteACLAccess(ctx context.Context, req DelACLAccessRequest) (
|
||||
|
||||
url := "/cloudapi/account/del_acl_access"
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
reqWrapped := wrapperDelACLAccessRequest{
|
||||
DelACLAccessRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -37,3 +48,25 @@ func (a Account) DeleteACLAccess(ctx context.Context, req DelACLAccessRequest) (
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeleteACLAccessAsync deletes ACL access from an account in async mode
|
||||
func (a Account) DeleteACLAccessAsync(ctx context.Context, req DelACLAccessRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/del_acl_access"
|
||||
|
||||
reqWrapped := wrapperDelACLAccessRequest{
|
||||
DelACLAccessRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -19,9 +19,15 @@ type DeleteUserRequest struct {
|
||||
UserID string `url:"userId" json:"userId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperDeleteUserRequest struct {
|
||||
DeleteUserRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// DeleteUser revokes user access from the account
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -30,7 +36,12 @@ func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, e
|
||||
|
||||
url := "/cloudapi/account/deleteUser"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperDeleteUserRequest{
|
||||
DeleteUserRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -42,3 +53,27 @@ func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, e
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeleteUserAsync revokes user access from the account in async mode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) DeleteUserAsync(ctx context.Context, req DeleteUserRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/deleteUser"
|
||||
|
||||
reqWrapped := wrapperDeleteUserRequest{
|
||||
DeleteUserRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -14,6 +14,12 @@ type RestoreRequest struct {
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperRestoreRequest struct {
|
||||
RestoreRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Restore restores a deleted account
|
||||
func (a Account) Restore(ctx context.Context, req RestoreRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -23,10 +29,37 @@ func (a Account) Restore(ctx context.Context, req RestoreRequest) (string, error
|
||||
|
||||
url := "/cloudapi/account/restore"
|
||||
|
||||
result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperRestoreRequest{
|
||||
RestoreRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(result), nil
|
||||
}
|
||||
|
||||
// RestoreAsync restores a deleted account in async mode
|
||||
func (a Account) RestoreAsync(ctx context.Context, req RestoreRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/restore"
|
||||
|
||||
reqWrapped := wrapperRestoreRequest{
|
||||
RestoreRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -56,6 +56,12 @@ type UpdateRequest struct {
|
||||
DefaultZoneID uint64 `url:"defaultZoneId,omitempty" json:"defaultZoneId,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperUpdateRequest struct {
|
||||
UpdateRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Update updates an account name and resource types and limits
|
||||
func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -65,7 +71,12 @@ func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
|
||||
url := "/cloudapi/account/update"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperUpdateRequest{
|
||||
UpdateRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -77,3 +88,25 @@ func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateAsync updates an account name and resource types and limits in async mode
|
||||
func (a Account) UpdateAsync(ctx context.Context, req UpdateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/update"
|
||||
|
||||
reqWrapped := wrapperUpdateRequest{
|
||||
UpdateRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -17,6 +17,12 @@ type UpdateACLAccessRequest struct {
|
||||
APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperUpdateACLAccessRequest struct {
|
||||
UpdateACLAccessRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// UpdateACLAccess updates ACL access in an account.
|
||||
func (a Account) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -26,7 +32,12 @@ func (a Account) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest
|
||||
|
||||
url := "/cloudapi/account/update_acl_access"
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
reqWrapped := wrapperUpdateACLAccessRequest{
|
||||
UpdateACLAccessRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -38,3 +49,25 @@ func (a Account) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateACLAccessAsync updates ACL access in an account in async mode
|
||||
func (a Account) UpdateACLAccessAsync(ctx context.Context, req UpdateACLAccessRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/update_acl_access"
|
||||
|
||||
reqWrapped := wrapperUpdateACLAccessRequest{
|
||||
UpdateACLAccessRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -26,9 +26,15 @@ type UpdateUserRequest struct {
|
||||
AccessType string `url:"accesstype" json:"accesstype" validate:"required,accessType"`
|
||||
}
|
||||
|
||||
type wrapperUpdateUserRequest struct {
|
||||
UpdateUserRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// UpdateUser updates user access rights
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -37,7 +43,12 @@ func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, e
|
||||
|
||||
url := "/cloudapi/account/updateUser"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperUpdateUserRequest{
|
||||
UpdateUserRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -49,3 +60,27 @@ func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, e
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateUserAsync updates user access rights in async mode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) UpdateUserAsync(ctx context.Context, req UpdateUserRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/account/updateUser"
|
||||
|
||||
reqWrapped := wrapperUpdateUserRequest{
|
||||
UpdateUserRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -122,6 +122,9 @@ type ItemAudit struct {
|
||||
// Persistent disk IDs associated with the operation
|
||||
DiskIDs []uint64 `json:"disk_ids"`
|
||||
|
||||
// VM folder ID
|
||||
VMFolderID uint64 `json:"vmfolder_id"`
|
||||
|
||||
// API task ID for asynchronous calls
|
||||
APITask string `json:"apitask"`
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ type wrapperCreateTemplateRequest struct {
|
||||
}
|
||||
|
||||
// CreateTemplate create template from compute instance
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -56,6 +56,8 @@ type wrapperCreateTemplateFromBlankRequest struct {
|
||||
|
||||
// CreateTemplateFromBlank creates template from boot disk of current compute in sync mode.
|
||||
// It returns id of created compute and error.
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) CreateTemplateFromBlank(ctx context.Context, req CreateTemplateFromBlankRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -84,6 +86,8 @@ func (c Compute) CreateTemplateFromBlank(ctx context.Context, req CreateTemplate
|
||||
|
||||
// CreateTemplateFromBlankAsync creates template from boot disk of current compute in async mode.
|
||||
// It returns guid of task and error.
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) CreateTemplateFromBlankAsync(ctx context.Context, req CreateTemplateFromBlankRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,6 +30,8 @@ type wrapperDiskQOSRequest struct {
|
||||
}
|
||||
|
||||
// DiskQOS change QoS of the disk
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -57,6 +59,8 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
|
||||
}
|
||||
|
||||
// DiskQOSAsync changes QoS of the disk with AsyncMode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) DiskQOSAsync(ctx context.Context, req DiskQOSRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -20,7 +20,11 @@ type DiskSwitchToReplicationRequest struct {
|
||||
|
||||
// Delete replication relationship
|
||||
// Required: false
|
||||
StopReplication bool `url:"stopReplication" json:"stopReplication"`
|
||||
StopReplication bool `url:"stopReplication,omitempty" json:"stopReplication,omitempty"`
|
||||
|
||||
// Use planned failover for asynchronous replication
|
||||
// Required: false
|
||||
Planned interface{} `url:"planned,omitempty" json:"planned,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperDiskSwitchToReplicationRequest struct {
|
||||
|
||||
@@ -1107,6 +1107,9 @@ type ItemComputeDisk struct {
|
||||
// Created time
|
||||
CreatedTime uint64 `json:"createdTime"`
|
||||
|
||||
// Whether CRT tracking is enabled
|
||||
CRTTracking bool `json:"crt_tracking"`
|
||||
|
||||
// Device name
|
||||
DeviceName string `json:"devicename"`
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ type UserGrantRequest struct {
|
||||
|
||||
// UserGrant grants user access to the compute
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) UserGrant(ctx context.Context, req UserGrantRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -17,7 +17,7 @@ type UserListRequest struct {
|
||||
|
||||
// UserList gets users list for compute
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) UserList(ctx context.Context, req UserListRequest) (*ListUsers, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -21,7 +21,7 @@ type UserRevokeRequest struct {
|
||||
|
||||
// UserRevoke revokes user access to the compute
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) UserRevoke(ctx context.Context, req UserRevokeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -29,7 +29,7 @@ type UserUpdateRequest struct {
|
||||
|
||||
// UserUpdate updates user access to the compute
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) UserUpdate(ctx context.Context, req UserUpdateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -18,6 +18,11 @@ type ChangeDiskStoragePolicyRequest struct {
|
||||
// ID of the storage policy to which to connect for disk
|
||||
// Required: true
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
|
||||
// Keep current disk I/O tune settings in the domain XML
|
||||
// Required: false
|
||||
// Default: false
|
||||
KeepCurrentIOTune interface{} `url:"keep_current_iotune,omitempty" json:"keep_current_iotune,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperChangeDiskStoragePolicyRequest struct {
|
||||
|
||||
@@ -55,6 +55,8 @@ type wrapperFromPlatformDiskRequest struct {
|
||||
|
||||
// FromPlatformDisk creates template from platform disk in sync mode.
|
||||
// It returns id of created disk and error.
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (d Disks) FromPlatformDisk(ctx context.Context, req FromPlatformDiskRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -83,6 +85,8 @@ func (d Disks) FromPlatformDisk(ctx context.Context, req FromPlatformDiskRequest
|
||||
|
||||
// FromPlatformDiskAsync creates template from platform disk in async mode.
|
||||
// It returns guid of task and error.
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (d Disks) FromPlatformDiskAsync(ctx context.Context, req FromPlatformDiskRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -67,6 +67,30 @@ type LimitIORequest struct {
|
||||
// Required: false
|
||||
WriteIOPSSecMax uint64 `url:"write_iops_sec_max,omitempty" json:"write_iops_sec_max,omitempty"`
|
||||
|
||||
// Duration in seconds of the total bytes burst. Requires TotalBytesSecMax
|
||||
// Required: false
|
||||
TotalBytesSecMaxLength uint64 `url:"total_bytes_sec_max_length,omitempty" json:"total_bytes_sec_max_length,omitempty"`
|
||||
|
||||
// Duration in seconds of the read bytes burst. Requires ReadBytesSecMax
|
||||
// Required: false
|
||||
ReadBytesSecMaxLength uint64 `url:"read_bytes_sec_max_length,omitempty" json:"read_bytes_sec_max_length,omitempty"`
|
||||
|
||||
// Duration in seconds of the write bytes burst. Requires WriteBytesSecMax
|
||||
// Required: false
|
||||
WriteBytesSecMaxLength uint64 `url:"write_bytes_sec_max_length,omitempty" json:"write_bytes_sec_max_length,omitempty"`
|
||||
|
||||
// Duration in seconds of the total IOPS burst. Requires TotalIOPSSecMax
|
||||
// Required: false
|
||||
TotalIOPSSecMaxLength uint64 `url:"total_iops_sec_max_length,omitempty" json:"total_iops_sec_max_length,omitempty"`
|
||||
|
||||
// Duration in seconds of the read IOPS burst. Requires ReadIOPSSecMax
|
||||
// Required: false
|
||||
ReadIOPSSecMaxLength uint64 `url:"read_iops_sec_max_length,omitempty" json:"read_iops_sec_max_length,omitempty"`
|
||||
|
||||
// Duration in seconds of the write IOPS burst. Requires WriteIOPSSecMax
|
||||
// Required: false
|
||||
WriteIOPSSecMaxLength uint64 `url:"write_iops_sec_max_length,omitempty" json:"write_iops_sec_max_length,omitempty"`
|
||||
|
||||
// SizeIOPSSec
|
||||
// Required: false
|
||||
SizeIOPSSec uint64 `url:"size_iops_sec,omitempty" json:"size_iops_sec,omitempty"`
|
||||
|
||||
@@ -154,6 +154,9 @@ type ItemDisk struct {
|
||||
|
||||
// Cache mode of disk
|
||||
Cache string `json:"cache"`
|
||||
|
||||
// Whether CRT is tracked
|
||||
CRTTracking bool `json:"crt_tracking"`
|
||||
}
|
||||
|
||||
type ItemDiskUnattached struct {
|
||||
@@ -300,6 +303,9 @@ type ItemDiskUnattached struct {
|
||||
|
||||
// Virtual machine ID
|
||||
VMID uint64 `json:"vmid"`
|
||||
|
||||
// Whether CRT is tracked
|
||||
CRTTracking bool `json:"crt_tracking"`
|
||||
}
|
||||
|
||||
// List of disks searched
|
||||
@@ -549,24 +555,57 @@ type RecordDisk struct {
|
||||
|
||||
// Cache mode of disk
|
||||
Cache string `json:"cache"`
|
||||
|
||||
// Whether CRT is tracked
|
||||
CRTTracking bool `json:"crt_tracking"`
|
||||
}
|
||||
|
||||
type ItemReplication struct {
|
||||
// Bandwidth
|
||||
Bandwidth uint64 `json:"bandwidth"`
|
||||
|
||||
// CopyRate
|
||||
CopyRate uint64 `json:"copy_rate"`
|
||||
|
||||
// DiskID
|
||||
DiskID uint64 `json:"diskId"`
|
||||
|
||||
// LastSync
|
||||
LastSync uint64 `json:"last_sync"`
|
||||
|
||||
// PairID
|
||||
PairID string `json:"pair_id"`
|
||||
|
||||
// PoolID
|
||||
PoolID string `json:"poolId"`
|
||||
|
||||
// ProfileID
|
||||
ProfileID uint64 `json:"profile_id"`
|
||||
|
||||
// Role
|
||||
Role string `json:"role"`
|
||||
|
||||
// ScheduleID
|
||||
ScheduleID uint64 `json:"schedule_id"`
|
||||
|
||||
// ScheduleName
|
||||
ScheduleName string `json:"schedule_name"`
|
||||
|
||||
// SelfVolumeID
|
||||
SelfVolumeID string `json:"selfVolumeId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// StorageID
|
||||
StorageID string `json:"storageId"`
|
||||
|
||||
// Target
|
||||
Target string `json:"target"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
|
||||
// VolumeID
|
||||
VolumeID string `json:"volumeId"`
|
||||
}
|
||||
@@ -30,6 +30,14 @@ type ReplicateRequest struct {
|
||||
// ID of the storage policy under the disk will be created
|
||||
// Required: true
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
|
||||
// Copy rate for an asynchronous replication pair (in MB/s)
|
||||
// Required: false
|
||||
CopyRate uint64 `url:"copy_rate,omitempty" json:"copy_rate,omitempty"`
|
||||
|
||||
// Name of the schedule from the replication profile
|
||||
// Required: false
|
||||
Schedule string `url:"schedule,omitempty" json:"schedule,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperReplicateRequest struct {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicationDisableScheduleRequest to remove the schedule from an asynchronous replication pair
|
||||
type ReplicationDisableScheduleRequest struct {
|
||||
// Disk ID
|
||||
// Required: true
|
||||
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
|
||||
}
|
||||
|
||||
// ReplicationDisableScheduleRequest removes the schedule from an asynchronous replication pair
|
||||
func (d Disks) ReplicationDisableSchedule(ctx context.Context, req ReplicationDisableScheduleRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/disks/replication_disable_schedule"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicationManualSyncRequest to start manual synchronization of an asynchronous replication pair
|
||||
type ReplicationManualSyncRequest struct {
|
||||
// Disk ID
|
||||
// Required: true
|
||||
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
|
||||
}
|
||||
|
||||
// ReplicationManualSync starts manual synchronization of an asynchronous replication pair
|
||||
func (d Disks) ReplicationManualSync(ctx context.Context, req ReplicationManualSyncRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/disks/replication_manual_sync"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicationPromoteRequest to promote the primary side of an asynchronous replication pair
|
||||
type ReplicationPromoteRequest struct {
|
||||
// Disk ID
|
||||
// Required: true
|
||||
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperReplicationPromoteRequest struct {
|
||||
ReplicationPromoteRequest
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// ReplicationPromote promotes the primary side of an asynchronous replication pair
|
||||
func (d Disks) ReplicationPromote(ctx context.Context, req ReplicationPromoteRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/disks/replication_promote"
|
||||
|
||||
aReq := wrapperReplicationPromoteRequest{
|
||||
ReplicationPromoteRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ReplicationPromoteAsync promotes the primary side of an asynchronous replication pair in async mode
|
||||
func (d Disks) ReplicationPromoteAsync(ctx context.Context, req ReplicationPromoteRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/disks/replication_promote"
|
||||
|
||||
aReq := wrapperReplicationPromoteRequest{
|
||||
ReplicationPromoteRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(res, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -14,6 +14,10 @@ type ReplicationReverseRequest struct {
|
||||
// Id of the disk
|
||||
// Required: true
|
||||
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||
|
||||
// Use planned failover for asynchronous replication
|
||||
// Required: false
|
||||
Planned interface{} `url:"planned,omitempty" json:"planned,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperReplicationReverseRequest struct {
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicationSetCopyRateRequest to set the copy rate of an asynchronous replication pair
|
||||
type ReplicationSetCopyRateRequest struct {
|
||||
// Disk ID
|
||||
// Required: true
|
||||
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
|
||||
|
||||
// Copy rate in MB/s
|
||||
// Required: true
|
||||
CopyRate uint64 `url:"copy_rate" json:"copy_rate" validate:"required"`
|
||||
}
|
||||
|
||||
// ReplicationSetCopyRate sets the copy rate of an asynchronous replication pair
|
||||
func (d Disks) ReplicationSetCopyRate(ctx context.Context, req ReplicationSetCopyRateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/disks/replication_set_copy_rate"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package disks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// ReplicationSetScheduleRequest to apply a replication profile schedule to an asynchronous replication pair
|
||||
type ReplicationSetScheduleRequest struct {
|
||||
// Disk ID
|
||||
// Required: true
|
||||
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
|
||||
|
||||
// ID of the replication profile assigned to the pair
|
||||
// Required: true
|
||||
ProfileID uint64 `url:"profile_id" json:"profile_id" validate:"required"`
|
||||
|
||||
// Name of the interval or calendar schedule from the profile
|
||||
// Required: true
|
||||
ScheduleName string `url:"schedule_name" json:"schedule_name" validate:"required"`
|
||||
}
|
||||
|
||||
// ReplicationSetSchedule applies a replication profile schedule to an asynchronous replication pair
|
||||
func (d Disks) ReplicationSetSchedule(ctx context.Context, req ReplicationSetScheduleRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/disks/replication_set_schedule"
|
||||
|
||||
res, err := d.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
@@ -18,6 +18,14 @@ type ReplicationStartRequest struct {
|
||||
// ID of target disk. Secondary disk in replication
|
||||
// Required: true
|
||||
TargetDiskID uint64 `url:"targetDiskId" json:"targetDiskId" validate:"required"`
|
||||
|
||||
// Copy rate for an asynchronous replication pair (in MB/s)
|
||||
// Required: false
|
||||
CopyRate uint64 `url:"copy_rate,omitempty" json:"copy_rate,omitempty"`
|
||||
|
||||
// Name of the schedule from the replication profile
|
||||
// Required: false
|
||||
Schedule string `url:"schedule,omitempty" json:"schedule,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperReplicationStartRequest struct {
|
||||
|
||||
@@ -34,6 +34,14 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
ComputeIDs []uint64 `url:"computeIds,omitempty" json:"computeIds,omitempty"`
|
||||
|
||||
// Find by account access
|
||||
// Required: false
|
||||
AccountAccess []uint64 `url:"accountAccess,omitempty" json:"accountAccess,omitempty"`
|
||||
|
||||
// Find by resource group access
|
||||
// Required: false
|
||||
RGAccess []uint64 `url:"rgAccess,omitempty" json:"rgAccess,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// CreateFromDiskRequest to create image from existing disk
|
||||
type CreateFromDiskRequest struct {
|
||||
// Name of the new image
|
||||
// Required: true
|
||||
Name string `url:"name" json:"name" validate:"required"`
|
||||
|
||||
// ID of the source disk to create image from
|
||||
// Required: true
|
||||
DiskID uint64 `url:"disk_id" json:"disk_id" validate:"required"`
|
||||
|
||||
// Boot type of the image (bios or uefi)
|
||||
// Required: true
|
||||
// Options:
|
||||
// - bios
|
||||
// - uefi
|
||||
BootType string `url:"boot_type" json:"boot_type" validate:"required,imageBootType"`
|
||||
|
||||
// Type of the operating system
|
||||
// Required: true
|
||||
// Options:
|
||||
// - linux
|
||||
// - windows
|
||||
// - unknown
|
||||
ImageType string `url:"image_type" json:"image_type" validate:"required,imageType"`
|
||||
|
||||
// ID of the storage policy to apply
|
||||
// Required: true
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
|
||||
// Network interface naming pattern for Linux machines. eth - onboard naming, ens - PCI slot naming.
|
||||
// Required: false
|
||||
// Default: ens
|
||||
// Options:
|
||||
// - eth
|
||||
// - ens
|
||||
NetworkInterfaceNaming string `url:"network_interface_naming,omitempty" json:"network_interface_naming,omitempty" validate:"omitempty,networkInterfaceNaming"`
|
||||
|
||||
// Whether the image supports hot resize (online resizing)
|
||||
// Required: false
|
||||
// Default: false
|
||||
HotResize interface{} `url:"hot_resize,omitempty" json:"hot_resize,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Default username for VMs created from this image
|
||||
// Required: false
|
||||
UserName string `url:"user_name,omitempty" json:"user_name,omitempty"`
|
||||
|
||||
// Default password for the default user
|
||||
// Required: false
|
||||
Password string `url:"password,omitempty" json:"password,omitempty"`
|
||||
|
||||
// Account ID to grant exclusive access to the image
|
||||
// Required: false
|
||||
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
|
||||
|
||||
// Target SEP ID where the image will be created. If not specified, the best SEP will be selected based on storage policy.
|
||||
// Required: false
|
||||
SEPID uint64 `url:"sep_id,omitempty" json:"sep_id,omitempty"`
|
||||
|
||||
// Target pool name in the SEP. If not specified, the best pool will be selected automatically.
|
||||
// Required: false
|
||||
PoolName string `url:"pool_name,omitempty" json:"pool_name,omitempty"`
|
||||
|
||||
// Whether the image is bootable
|
||||
// Required: false
|
||||
// Default: true
|
||||
Bootable interface{} `url:"bootable,omitempty" json:"bootable,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperCreateFromDiskRequest struct {
|
||||
CreateFromDiskRequest
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// CreateFromDisk creates image from existing disk
|
||||
func (i Image) CreateFromDisk(ctx context.Context, req CreateFromDiskRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return 0, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/image/create_from_disk"
|
||||
|
||||
aReq := wrapperCreateFromDiskRequest{
|
||||
CreateFromDiskRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateFromDiskAsync creates image from existing disk in async mode
|
||||
func (i Image) CreateFromDiskAsync(ctx context.Context, req CreateFromDiskRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudapi/image/create_from_disk"
|
||||
|
||||
aReq := wrapperCreateFromDiskRequest{
|
||||
CreateFromDiskRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := i.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(res, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -59,6 +59,14 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Sort by account ID
|
||||
// Required: false
|
||||
AccountID uint64 `url:"account_id,omitempty" json:"account_id,omitempty"`
|
||||
|
||||
// Sort by sep type
|
||||
// Required: false
|
||||
SEPType string `url:"sep_type,omitempty" json:"sep_type,omitempty" validate:"omitempty,sepTypes"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
@@ -32,6 +32,9 @@ type ItemImage struct {
|
||||
// Link to
|
||||
LinkTo uint64 `json:"linkTo"`
|
||||
|
||||
// Links to
|
||||
LinksTo []uint64 `json:"linksTo"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
@@ -214,4 +217,7 @@ type RecordImage struct {
|
||||
|
||||
// Version
|
||||
Version string `json:"version"`
|
||||
|
||||
// Real size of the image
|
||||
RealSize uint64 `json:"real_size"`
|
||||
}
|
||||
@@ -46,6 +46,12 @@ type ItemLocation struct {
|
||||
|
||||
// Are VM Folders enabled
|
||||
VMFoldersEnabled bool `json:"vm_folders_enabled"`
|
||||
|
||||
// SDN Web config
|
||||
SDNWeb SDNWeb `json:"sdn_web"`
|
||||
|
||||
// BVP Web config
|
||||
BVPWeb BVPWeb `json:"bvp_web"`
|
||||
}
|
||||
|
||||
// List of locations
|
||||
@@ -56,3 +62,27 @@ type ListLocations struct {
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// SDN Web config
|
||||
type SDNWeb struct {
|
||||
// Whether the config is enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// URL
|
||||
URL string `json:"url"`
|
||||
|
||||
// Number of the port
|
||||
Port uint64 `json:"port"`
|
||||
}
|
||||
|
||||
// BVP Web config
|
||||
type BVPWeb struct {
|
||||
// Whether the config is enabled
|
||||
Enabled bool `json:"enabled"`
|
||||
|
||||
// URL
|
||||
URL string `json:"url"`
|
||||
|
||||
// Number of ther port
|
||||
Port uint64 `json:"port"`
|
||||
}
|
||||
@@ -34,6 +34,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Sort by node ID
|
||||
// Required: false
|
||||
NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
@@ -28,7 +28,7 @@ type AccessGrantRequest struct {
|
||||
|
||||
// AccessGrant grants user or group access to the resource group as specified
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (r RG) AccessGrant(ctx context.Context, req AccessGrantRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -21,7 +21,7 @@ type AccessRevokeRequest struct {
|
||||
|
||||
// AccessRevoke revokes specified user or group access from the resource group
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (r RG) AccessRevoke(ctx context.Context, req AccessRevokeRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -22,6 +22,9 @@ type Resource struct {
|
||||
|
||||
// SEPs
|
||||
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||
|
||||
// Policies
|
||||
Policies map[string]PolicyUsage `json:"policies"`
|
||||
}
|
||||
|
||||
// Disk usage
|
||||
@@ -33,6 +36,21 @@ type DiskUsage struct {
|
||||
DiskSizeMax float64 `json:"disksizemax"`
|
||||
}
|
||||
|
||||
// Policy usage
|
||||
type PolicyUsage struct {
|
||||
// Disk size
|
||||
DiskSize float64 `json:"disksize"`
|
||||
|
||||
// Max disk size
|
||||
DiskSizeMax float64 `json:"disksizemax"`
|
||||
|
||||
// Limit
|
||||
Limit float64 `json:"limit"`
|
||||
|
||||
// SEPs
|
||||
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||
}
|
||||
|
||||
// Information about resources
|
||||
type Resources struct {
|
||||
// Current information about resources
|
||||
@@ -51,10 +69,31 @@ type ItemResourceConsumption struct {
|
||||
Reserved Resource `json:"reserved"`
|
||||
|
||||
// Resource limits
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
ResourceLimits ResourceConsumptionLimits `json:"resourceLimits"`
|
||||
|
||||
// Resource group ID
|
||||
RGID uint64 `json:"rgid"`
|
||||
RGID uint64 `json:"id"`
|
||||
}
|
||||
|
||||
// Resource limits of resource consumption
|
||||
type ResourceConsumptionLimits struct {
|
||||
// CUC
|
||||
CUC float64 `json:"CU_C"`
|
||||
|
||||
// CUD
|
||||
CUD float64 `json:"CU_D"`
|
||||
|
||||
// CUDM
|
||||
CUDM float64 `json:"CU_DM"`
|
||||
|
||||
// CUI
|
||||
CUI float64 `json:"CU_I"`
|
||||
|
||||
// CUM
|
||||
CUM float64 `json:"CU_M"`
|
||||
|
||||
// GPU units
|
||||
GPUUnits float64 `json:"gpu_units"`
|
||||
}
|
||||
|
||||
type ListResourceConsumption struct {
|
||||
@@ -892,4 +931,7 @@ type RecordResourceUsage struct {
|
||||
|
||||
// SEPs
|
||||
SEPs map[string]map[string]DiskUsage `json:"seps"`
|
||||
|
||||
// Policies
|
||||
Policies map[string]PolicyUsage `json:"policies"`
|
||||
}
|
||||
@@ -42,6 +42,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
SortBy string `url:"sort_by,omitempty" json:"sort_by,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Sort by name
|
||||
// Required: false
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
@@ -54,6 +54,12 @@ type ItemVGPU struct {
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Node ID
|
||||
NodeID uint64 `json:"node_id"`
|
||||
}
|
||||
|
||||
// List of VGPU
|
||||
|
||||
@@ -72,7 +72,7 @@ type CreateInAccountRequest struct {
|
||||
|
||||
type asyncWrapperCreateInAccountRequest struct {
|
||||
CreateInAccountRequest
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// CreateInAccount creates VINS in account level
|
||||
|
||||
@@ -66,7 +66,7 @@ type CreateInRGRequest struct {
|
||||
|
||||
type asyncWrapperCreateInRgRequest struct {
|
||||
CreateInRGRequest
|
||||
AsyncMode bool `url:"asyncMode" json:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// CreateInRG creates VINS in resource group level
|
||||
|
||||
@@ -18,7 +18,7 @@ type EnableRequest struct {
|
||||
|
||||
type asyncWrapperEnableRequest struct {
|
||||
EnableRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// Enable enables VINS
|
||||
|
||||
@@ -844,6 +844,9 @@ type ItemReservation struct {
|
||||
// Account ID
|
||||
AccountID uint64 `json:"account_id"`
|
||||
|
||||
// Whether reservation is auto assignable
|
||||
AutoAssignable bool `json:"auto_assignable"`
|
||||
|
||||
// IP
|
||||
IP string `json:"ip"`
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ type VNFDevRedeployRequest struct {
|
||||
|
||||
type asyncWrapperVNFDevRedeployRequest struct {
|
||||
VNFDevRedeployRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// VNFDevRedeploy redeploys VINS VNFDevs
|
||||
|
||||
@@ -18,7 +18,7 @@ type VNFDevRestartRequest struct {
|
||||
|
||||
type asyncWrapperVNFDevRestartRequest struct {
|
||||
VNFDevRestartRequest
|
||||
AsyncMode bool `url:"asyncMode"`
|
||||
AsyncMode bool `url:"async_mode"`
|
||||
}
|
||||
|
||||
// VNFDevRestart reboots VINSes primary VNF device
|
||||
|
||||
@@ -126,6 +126,9 @@ type RecordZone struct {
|
||||
|
||||
// Minimal level of logs
|
||||
LoggingLevel string `json:"logging_level"`
|
||||
|
||||
// Timeout
|
||||
TaskDiskTimeout string `json:"task_disk_timeout"`
|
||||
}
|
||||
|
||||
// A zone item from a list
|
||||
@@ -213,4 +216,7 @@ type ItemZone struct {
|
||||
|
||||
// Minimal level of logs
|
||||
LoggingLevel string `json:"logging_level"`
|
||||
|
||||
// Timeout
|
||||
TaskDiskTimeout string `json:"task_disk_timeout"`
|
||||
}
|
||||
@@ -17,6 +17,12 @@ type AddACLAccessRequest struct {
|
||||
APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperAddACLAccessRequest struct {
|
||||
AddACLAccessRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// AddACLAccess adds ACL access to an account.
|
||||
func (a Account) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -26,7 +32,12 @@ func (a Account) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (boo
|
||||
|
||||
url := "/cloudbroker/account/add_acl_access"
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
reqWrapped := wrapperAddACLAccessRequest{
|
||||
AddACLAccessRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -38,3 +49,25 @@ func (a Account) AddACLAccess(ctx context.Context, req AddACLAccessRequest) (boo
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AddACLAccessAsync adds ACL access to an account in async mode
|
||||
func (a Account) AddACLAccessAsync(ctx context.Context, req AddACLAccessRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/add_acl_access"
|
||||
|
||||
reqWrapped := wrapperAddACLAccessRequest{
|
||||
AddACLAccessRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -23,6 +23,12 @@ type AddStoragePolicyRequest struct {
|
||||
Limit int `url:"limit,omitempty" json:"limit,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperAddStoragePolicyRequest struct {
|
||||
AddStoragePolicyRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// AddStoragePolicy add storage policy to the account.
|
||||
func (a Account) AddStoragePolicy(ctx context.Context, req AddStoragePolicyRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -32,7 +38,12 @@ func (a Account) AddStoragePolicy(ctx context.Context, req AddStoragePolicyReque
|
||||
|
||||
url := "/cloudbroker/account/add_storage_policy"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperAddStoragePolicyRequest{
|
||||
AddStoragePolicyRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -44,3 +55,25 @@ func (a Account) AddStoragePolicy(ctx context.Context, req AddStoragePolicyReque
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AddStoragePolicyAsync add storage policy to the account in async mode
|
||||
func (a Account) AddStoragePolicyAsync(ctx context.Context, req AddStoragePolicyRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/add_storage_policy"
|
||||
|
||||
reqWrapped := wrapperAddStoragePolicyRequest{
|
||||
AddStoragePolicyRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -26,9 +26,15 @@ type AddUserRequest struct {
|
||||
AccessType string `url:"accesstype" json:"accesstype" validate:"accessType"`
|
||||
}
|
||||
|
||||
type wrapperAddUserRequest struct {
|
||||
AddUserRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// AddUser gives a user access rights.
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -37,7 +43,12 @@ func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error)
|
||||
|
||||
url := "/cloudbroker/account/addUser"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperAddUserRequest{
|
||||
AddUserRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -49,3 +60,27 @@ func (a Account) AddUser(ctx context.Context, req AddUserRequest) (bool, error)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AddUserAsync gives a user access rights in async mode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) AddUserAsync(ctx context.Context, req AddUserRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/addUser"
|
||||
|
||||
reqWrapped := wrapperAddUserRequest{
|
||||
AddUserRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -19,7 +19,13 @@ type AddZoneRequest struct {
|
||||
ZoneIDs []uint64 `url:"zoneIds" json:"zoneIds" validate:"required"`
|
||||
}
|
||||
|
||||
// AddUser gives a user access rights.
|
||||
type wrapperAddZoneRequest struct {
|
||||
AddZoneRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// AddZone adds zones to account
|
||||
func (a Account) AddZone(ctx context.Context, req AddZoneRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -28,7 +34,12 @@ func (a Account) AddZone(ctx context.Context, req AddZoneRequest) (bool, error)
|
||||
|
||||
url := "/cloudbroker/account/addZone"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperAddZoneRequest{
|
||||
AddZoneRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,25 @@ func (a Account) AddZone(ctx context.Context, req AddZoneRequest) (bool, error)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// AddZoneAsync adds zones to account in async mode
|
||||
func (a Account) AddZoneAsync(ctx context.Context, req AddZoneRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/addZone"
|
||||
|
||||
reqWrapped := wrapperAddZoneRequest{
|
||||
AddZoneRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -79,6 +79,12 @@ type StoragePolicy struct {
|
||||
Limit int `url:"limit" json:"limit"`
|
||||
}
|
||||
|
||||
type wrapperCreateRequest struct {
|
||||
CreateRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Create creates account
|
||||
// Setting a cloud unit maximum to -1 or empty will not put any restrictions on the resource
|
||||
func (a Account) Create(ctx context.Context, req CreateRequest) (uint64, error) {
|
||||
@@ -89,7 +95,12 @@ func (a Account) Create(ctx context.Context, req CreateRequest) (uint64, error)
|
||||
|
||||
url := "/cloudbroker/account/create"
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
CreateRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@@ -101,3 +112,25 @@ func (a Account) Create(ctx context.Context, req CreateRequest) (uint64, error)
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateAsync creates account in async mode
|
||||
func (a Account) CreateAsync(ctx context.Context, req CreateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/create"
|
||||
|
||||
reqWrapped := wrapperCreateRequest{
|
||||
CreateRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -16,6 +16,12 @@ type DelACLAccessRequest struct {
|
||||
APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperDelACLAccessRequest struct {
|
||||
DelACLAccessRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// DelACLAccess deletes ACL access from an account.
|
||||
func (a Account) DeleteACLAccess(ctx context.Context, req DelACLAccessRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -25,7 +31,12 @@ func (a Account) DeleteACLAccess(ctx context.Context, req DelACLAccessRequest) (
|
||||
|
||||
url := "/cloudbroker/account/del_acl_access"
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
reqWrapped := wrapperDelACLAccessRequest{
|
||||
DelACLAccessRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -37,3 +48,25 @@ func (a Account) DeleteACLAccess(ctx context.Context, req DelACLAccessRequest) (
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeleteACLAccessAsync deletes ACL access from an account in async mode
|
||||
func (a Account) DeleteACLAccessAsync(ctx context.Context, req DelACLAccessRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/del_acl_access"
|
||||
|
||||
reqWrapped := wrapperDelACLAccessRequest{
|
||||
DelACLAccessRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -19,6 +19,12 @@ type DelStoragePolicyRequest struct {
|
||||
StoragePolicyID uint64 `url:"storage_policy_id" json:"storage_policy_id" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperDelStoragePolicyRequest struct {
|
||||
DelStoragePolicyRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// DelStoragePolicy delete storage policy to the account.
|
||||
func (a Account) DelStoragePolicy(ctx context.Context, req DelStoragePolicyRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +34,12 @@ func (a Account) DelStoragePolicy(ctx context.Context, req DelStoragePolicyReque
|
||||
|
||||
url := "/cloudbroker/account/del_storage_policy"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperDelStoragePolicyRequest{
|
||||
DelStoragePolicyRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,25 @@ func (a Account) DelStoragePolicy(ctx context.Context, req DelStoragePolicyReque
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DelStoragePolicyAsync delete storage policy to the account in async mode
|
||||
func (a Account) DelStoragePolicyAsync(ctx context.Context, req DelStoragePolicyRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/del_storage_policy"
|
||||
|
||||
reqWrapped := wrapperDelStoragePolicyRequest{
|
||||
DelStoragePolicyRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -22,7 +22,13 @@ type DeleteRequest struct {
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// Delete completes delete an account from the system Returns true if account is deleted or was already deleted or never existed
|
||||
type wrapperDeleteRequest struct {
|
||||
DeleteRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Delete deletes an account from the system
|
||||
func (a Account) Delete(ctx context.Context, req DeleteRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -31,10 +37,37 @@ func (a Account) Delete(ctx context.Context, req DeleteRequest) (string, error)
|
||||
|
||||
url := "/cloudbroker/account/delete"
|
||||
|
||||
result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperDeleteRequest{
|
||||
DeleteRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(result), nil
|
||||
}
|
||||
|
||||
// DeleteAsync deletes an account from the system in async mode
|
||||
func (a Account) DeleteAsync(ctx context.Context, req DeleteRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/delete"
|
||||
|
||||
reqWrapped := wrapperDeleteRequest{
|
||||
DeleteRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
@@ -18,8 +19,43 @@ type DeleteAccountsRequest struct {
|
||||
Permanently bool `url:"permanently,omitempty" json:"permanently,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperDeleteAccountsRequest struct {
|
||||
DeleteAccountsRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// DeleteAccounts destroys a group of accounts
|
||||
func (a Account) DeleteAccounts(ctx context.Context, req DeleteAccountsRequest) (string, error) {
|
||||
func (a Account) DeleteAccounts(ctx context.Context, req DeleteAccountsRequest) ([]uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/deleteAccounts"
|
||||
|
||||
reqWrapped := wrapperDeleteAccountsRequest{
|
||||
DeleteAccountsRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make([]uint64, 0)
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeleteAccountsAsync destroys a group of accounts in async mode
|
||||
func (a Account) DeleteAccountsAsync(ctx context.Context, req DeleteAccountsRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
@@ -27,7 +63,12 @@ func (a Account) DeleteAccounts(ctx context.Context, req DeleteAccountsRequest)
|
||||
|
||||
url := "/cloudbroker/account/deleteAccounts"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperDeleteAccountsRequest{
|
||||
DeleteAccountsRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -19,9 +19,15 @@ type DeleteUserRequest struct {
|
||||
UserName string `url:"username" json:"username" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperDeleteUserRequest struct {
|
||||
DeleteUserRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// DeleteUser revokes user access from the account
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -30,7 +36,12 @@ func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, e
|
||||
|
||||
url := "/cloudbroker/account/deleteUser"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperDeleteUserRequest{
|
||||
DeleteUserRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -42,3 +53,27 @@ func (a Account) DeleteUser(ctx context.Context, req DeleteUserRequest) (bool, e
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DeleteUserAsync revokes user access from the account in async mode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) DeleteUserAsync(ctx context.Context, req DeleteUserRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/deleteUser"
|
||||
|
||||
reqWrapped := wrapperDeleteUserRequest{
|
||||
DeleteUserRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
@@ -14,8 +15,43 @@ type DisableAccountsRequest struct {
|
||||
AccountIDs []uint64 `url:"accountIds" json:"accountIds" validate:"min=1"`
|
||||
}
|
||||
|
||||
type wrapperDisableAccountsRequest struct {
|
||||
DisableAccountsRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// DisableAccounts disables accounts
|
||||
func (a Account) DisableAccounts(ctx context.Context, req DisableAccountsRequest) (string, error) {
|
||||
func (a Account) DisableAccounts(ctx context.Context, req DisableAccountsRequest) ([]uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/disableAccounts"
|
||||
|
||||
reqWrapped := wrapperDisableAccountsRequest{
|
||||
DisableAccountsRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make([]uint64, 0)
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// DisableAccountsAsync disables accounts in async mode
|
||||
func (a Account) DisableAccountsAsync(ctx context.Context, req DisableAccountsRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
@@ -23,7 +59,12 @@ func (a Account) DisableAccounts(ctx context.Context, req DisableAccountsRequest
|
||||
|
||||
url := "/cloudbroker/account/disableAccounts"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperDisableAccountsRequest{
|
||||
DisableAccountsRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
@@ -14,8 +15,43 @@ type EnableAccountsRequest struct {
|
||||
AccountIDs []uint64 `url:"accountIds" json:"accountIds" validate:"min=1"`
|
||||
}
|
||||
|
||||
type wrapperEnableAccountsRequest struct {
|
||||
EnableAccountsRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// EnableAccounts enables accounts
|
||||
func (a Account) EnableAccounts(ctx context.Context, req EnableAccountsRequest) (string, error) {
|
||||
func (a Account) EnableAccounts(ctx context.Context, req EnableAccountsRequest) ([]uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/enableAccounts"
|
||||
|
||||
reqWrapped := wrapperEnableAccountsRequest{
|
||||
EnableAccountsRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make([]uint64, 0)
|
||||
|
||||
err = json.Unmarshal(res, &result)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// EnableAccountsAsync enables accounts in async mode
|
||||
func (a Account) EnableAccountsAsync(ctx context.Context, req EnableAccountsRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
@@ -23,7 +59,12 @@ func (a Account) EnableAccounts(ctx context.Context, req EnableAccountsRequest)
|
||||
|
||||
url := "/cloudbroker/account/enableAccounts"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperEnableAccountsRequest{
|
||||
EnableAccountsRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@ type GrantAccessTemplatesRequest struct {
|
||||
ImageIDs []uint64 `url:"imageIds" json:"imageIds" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperGrantAccessTemplatesRequest struct {
|
||||
GrantAccessTemplatesRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// GrantAccessTemplates shares specified images with specified account
|
||||
func (a Account) GrantAccessTemplates(ctx context.Context, req GrantAccessTemplatesRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +34,12 @@ func (a Account) GrantAccessTemplates(ctx context.Context, req GrantAccessTempla
|
||||
|
||||
url := "/cloudbroker/account/grantAccessTemplates"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperGrantAccessTemplatesRequest{
|
||||
GrantAccessTemplatesRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,25 @@ func (a Account) GrantAccessTemplates(ctx context.Context, req GrantAccessTempla
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GrantAccessTemplatesAsync shares specified images with specified account in async mode
|
||||
func (a Account) GrantAccessTemplatesAsync(ctx context.Context, req GrantAccessTemplatesRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/grantAccessTemplates"
|
||||
|
||||
reqWrapped := wrapperGrantAccessTemplatesRequest{
|
||||
GrantAccessTemplatesRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -19,6 +19,12 @@ type RemoveZoneRequest struct {
|
||||
ZoneIDs []uint64 `url:"zoneIds" json:"zoneIds" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperRemoveZoneRequest struct {
|
||||
RemoveZoneRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// RemoveZone removes zones with ids provided from a user.
|
||||
func (a Account) RemoveZone(ctx context.Context, req RemoveZoneRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +34,12 @@ func (a Account) RemoveZone(ctx context.Context, req RemoveZoneRequest) (bool, e
|
||||
|
||||
url := "/cloudbroker/account/removeZone"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperRemoveZoneRequest{
|
||||
RemoveZoneRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,25 @@ func (a Account) RemoveZone(ctx context.Context, req RemoveZoneRequest) (bool, e
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// RemoveZoneAsync removes zones with ids provided from a user in async mode
|
||||
func (a Account) RemoveZoneAsync(ctx context.Context, req RemoveZoneRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/removeZone"
|
||||
|
||||
reqWrapped := wrapperRemoveZoneRequest{
|
||||
RemoveZoneRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -14,6 +14,12 @@ type RestoreRequest struct {
|
||||
AccountID uint64 `url:"accountId" json:"accountId" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperRestoreRequest struct {
|
||||
RestoreRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Restore restores a deleted account
|
||||
func (a Account) Restore(ctx context.Context, req RestoreRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -23,10 +29,37 @@ func (a Account) Restore(ctx context.Context, req RestoreRequest) (string, error
|
||||
|
||||
url := "/cloudbroker/account/restore"
|
||||
|
||||
result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperRestoreRequest{
|
||||
RestoreRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
result, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(result), nil
|
||||
}
|
||||
|
||||
// RestoreAsync restores a deleted account in async mode
|
||||
func (a Account) RestoreAsync(ctx context.Context, req RestoreRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/restore"
|
||||
|
||||
reqWrapped := wrapperRestoreRequest{
|
||||
RestoreRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -19,6 +19,12 @@ type RevokeAccessTemplatesRequest struct {
|
||||
ImageIDs []uint64 `url:"imageIds" json:"imageIds" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperRevokeAccessTemplatesRequest struct {
|
||||
RevokeAccessTemplatesRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// RevokeAccessTemplates unshares specified images with specified account
|
||||
func (a Account) RevokeAccessTemplates(ctx context.Context, req RevokeAccessTemplatesRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +34,12 @@ func (a Account) RevokeAccessTemplates(ctx context.Context, req RevokeAccessTemp
|
||||
|
||||
url := "/cloudbroker/account/revokeAccessTemplates"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperRevokeAccessTemplatesRequest{
|
||||
RevokeAccessTemplatesRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,25 @@ func (a Account) RevokeAccessTemplates(ctx context.Context, req RevokeAccessTemp
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// RevokeAccessTemplatesAsync unshares specified images with specified account in async mode
|
||||
func (a Account) RevokeAccessTemplatesAsync(ctx context.Context, req RevokeAccessTemplatesRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/revokeAccessTemplates"
|
||||
|
||||
reqWrapped := wrapperRevokeAccessTemplatesRequest{
|
||||
RevokeAccessTemplatesRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -20,6 +20,12 @@ type SetCPUAllocationParameterRequest struct {
|
||||
StrictLoose string `url:"strict_loose" json:"strict_loose" validate:"required,strict_loose"`
|
||||
}
|
||||
|
||||
type wrapperSetCPUAllocationParameterRequest struct {
|
||||
SetCPUAllocationParameterRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// SetCPUAllocationParameter sets CPU allocation parameter
|
||||
func (a Account) SetCPUAllocationParameter(ctx context.Context, req SetCPUAllocationParameterRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -29,7 +35,12 @@ func (a Account) SetCPUAllocationParameter(ctx context.Context, req SetCPUAlloca
|
||||
|
||||
url := "/cloudbroker/account/setCpuAllocationParameter"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperSetCPUAllocationParameterRequest{
|
||||
SetCPUAllocationParameterRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -41,3 +52,25 @@ func (a Account) SetCPUAllocationParameter(ctx context.Context, req SetCPUAlloca
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SetCPUAllocationParameterAsync sets CPU allocation parameter in async mode
|
||||
func (a Account) SetCPUAllocationParameterAsync(ctx context.Context, req SetCPUAllocationParameterRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/setCpuAllocationParameter"
|
||||
|
||||
reqWrapped := wrapperSetCPUAllocationParameterRequest{
|
||||
SetCPUAllocationParameterRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -19,6 +19,12 @@ type SetCPUAllocationRatioRequest struct {
|
||||
Ratio uint64 `url:"ratio" json:"ratio" validate:"required"`
|
||||
}
|
||||
|
||||
type wrapperSetCPUAllocationRatioRequest struct {
|
||||
SetCPUAllocationRatioRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// SetCPUAllocationRatio sets CPU allocation ratio
|
||||
func (a Account) SetCPUAllocationRatio(ctx context.Context, req SetCPUAllocationRatioRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -28,7 +34,12 @@ func (a Account) SetCPUAllocationRatio(ctx context.Context, req SetCPUAllocation
|
||||
|
||||
url := "/cloudbroker/account/setCpuAllocationRatio"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperSetCPUAllocationRatioRequest{
|
||||
SetCPUAllocationRatioRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -40,3 +51,25 @@ func (a Account) SetCPUAllocationRatio(ctx context.Context, req SetCPUAllocation
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// SetCPUAllocationRatioAsync sets CPU allocation ratio in async mode
|
||||
func (a Account) SetCPUAllocationRatioAsync(ctx context.Context, req SetCPUAllocationRatioRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/setCpuAllocationRatio"
|
||||
|
||||
reqWrapped := wrapperSetCPUAllocationRatioRequest{
|
||||
SetCPUAllocationRatioRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -70,6 +70,12 @@ type UpdateRequest struct {
|
||||
CpuAllocationParameter string `url:"cpu_allocation_parameter,omitempty" json:"cpu_allocation_parameter,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperUpdateRequest struct {
|
||||
UpdateRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// Update updates an account name and resource types and limits
|
||||
func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -79,7 +85,12 @@ func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
|
||||
url := "/cloudbroker/account/update"
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
reqWrapped := wrapperUpdateRequest{
|
||||
UpdateRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -91,3 +102,25 @@ func (a Account) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateAsync updates an account name and resource types and limits in async mode
|
||||
func (a Account) UpdateAsync(ctx context.Context, req UpdateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/update"
|
||||
|
||||
reqWrapped := wrapperUpdateRequest{
|
||||
UpdateRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -17,6 +17,12 @@ type UpdateACLAccessRequest struct {
|
||||
APIAccesses []uint64 `url:"apiaccesses,omitempty" json:"apiaccesses,omitempty"`
|
||||
}
|
||||
|
||||
type wrapperUpdateACLAccessRequest struct {
|
||||
UpdateACLAccessRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// UpdateACLAccess updates ACL access in an account.
|
||||
func (a Account) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -26,7 +32,12 @@ func (a Account) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest
|
||||
|
||||
url := "/cloudbroker/account/update_acl_access"
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
reqWrapped := wrapperUpdateACLAccessRequest{
|
||||
UpdateACLAccessRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -38,3 +49,25 @@ func (a Account) UpdateACLAccess(ctx context.Context, req UpdateACLAccessRequest
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateACLAccessAsync updates ACL access in an account in async mode
|
||||
func (a Account) UpdateACLAccessAsync(ctx context.Context, req UpdateACLAccessRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/update_acl_access"
|
||||
|
||||
reqWrapped := wrapperUpdateACLAccessRequest{
|
||||
UpdateACLAccessRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -20,6 +20,12 @@ type UpdateComputeFeaturesRequest struct {
|
||||
ComputeFeatures []string `url:"computeFeatures,omitempty" json:"computeFeatures,omitempty" validate:"omitempty,computeFeatures"`
|
||||
}
|
||||
|
||||
type wrapperUpdateComputeFeaturesRequest struct {
|
||||
UpdateComputeFeaturesRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// UpdateComputeFeatures updates advanced compute features
|
||||
func (a Account) UpdateComputeFeatures(ctx context.Context, req UpdateComputeFeaturesRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
@@ -29,7 +35,12 @@ func (a Account) UpdateComputeFeatures(ctx context.Context, req UpdateComputeFea
|
||||
|
||||
url := "/cloudbroker/account/updateComputeFeatures"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperUpdateComputeFeaturesRequest{
|
||||
UpdateComputeFeaturesRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -41,3 +52,25 @@ func (a Account) UpdateComputeFeatures(ctx context.Context, req UpdateComputeFea
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateComputeFeaturesAsync updates advanced compute features in async mode
|
||||
func (a Account) UpdateComputeFeaturesAsync(ctx context.Context, req UpdateComputeFeaturesRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/updateComputeFeatures"
|
||||
|
||||
reqWrapped := wrapperUpdateComputeFeaturesRequest{
|
||||
UpdateComputeFeaturesRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -26,6 +26,13 @@ type UpdateResourceTypesRequest struct {
|
||||
ResTypes []string `url:"resourceTypes" json:"resourceTypes" validate:"min=1,resTypes"`
|
||||
}
|
||||
|
||||
type wrapperUpdateResourceTypesRequest struct {
|
||||
UpdateResourceTypesRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// UpdateResourceTypes updates resource types in account
|
||||
func (a Account) UpdateResourceTypes(ctx context.Context, req UpdateResourceTypesRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -34,7 +41,12 @@ func (a Account) UpdateResourceTypes(ctx context.Context, req UpdateResourceType
|
||||
|
||||
url := "/cloudbroker/account/updateResourceTypes"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperUpdateResourceTypesRequest{
|
||||
UpdateResourceTypesRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -46,3 +58,25 @@ func (a Account) UpdateResourceTypes(ctx context.Context, req UpdateResourceType
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateResourceTypesAsync updates resource types in account in async mode
|
||||
func (a Account) UpdateResourceTypesAsync(ctx context.Context, req UpdateResourceTypesRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/updateResourceTypes"
|
||||
|
||||
reqWrapped := wrapperUpdateResourceTypesRequest{
|
||||
UpdateResourceTypesRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -26,9 +26,15 @@ type UpdateUserRequest struct {
|
||||
AccessType string `url:"accesstype" json:"accesstype" validate:"accessType"`
|
||||
}
|
||||
|
||||
type wrapperUpdateUserRequest struct {
|
||||
UpdateUserRequest
|
||||
|
||||
AsyncMode bool `url:"async_mode" json:"async_mode"`
|
||||
}
|
||||
|
||||
// UpdateUser updates user access rights
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -37,7 +43,12 @@ func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, e
|
||||
|
||||
url := "/cloudbroker/account/updateUser"
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
reqWrapped := wrapperUpdateUserRequest{
|
||||
UpdateUserRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -49,3 +60,27 @@ func (a Account) UpdateUser(ctx context.Context, req UpdateUserRequest) (bool, e
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// UpdateUserAsync updates user access rights in async mode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a Account) UpdateUserAsync(ctx context.Context, req UpdateUserRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/account/updateUser"
|
||||
|
||||
reqWrapped := wrapperUpdateUserRequest{
|
||||
UpdateUserRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := a.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(res), nil
|
||||
}
|
||||
@@ -168,6 +168,7 @@ type CloudBrokerEndpoints struct {
|
||||
AuditCollector interface{} `json:"auditcollector,omitempty"`
|
||||
Backup interface{} `json:"backup,omitempty"`
|
||||
BackupCreator interface{} `json:"backupcreator,omitempty"`
|
||||
BasisMPM interface{} `json:"basis_mpm,omitempty"`
|
||||
BService interface{} `json:"bservice,omitempty"`
|
||||
Compute interface{} `json:"compute,omitempty"`
|
||||
Disks interface{} `json:"disks,omitempty"`
|
||||
|
||||
@@ -25,7 +25,7 @@ type UserListRequest struct {
|
||||
|
||||
// UserList gets a list of users currently included in the specified group.
|
||||
//
|
||||
// Deprecated: will be removed in SDK v1.17
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (a APIAccess) UserList(ctx context.Context, req UserListRequest) ([]string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -77,6 +77,9 @@ type ItemAudit struct {
|
||||
// Persistent disk IDs associated with the operation
|
||||
DiskIDs []uint64 `json:"disk_ids"`
|
||||
|
||||
// VM folder ID
|
||||
VMFolderID uint64 `json:"vmfolder_id"`
|
||||
|
||||
// API task ID for asynchronous calls
|
||||
APITask string `json:"apitask"`
|
||||
}
|
||||
@@ -146,6 +149,9 @@ type RecordAudit struct {
|
||||
|
||||
// Compute ID
|
||||
ComputeID uint64 `json:"compute_id"`
|
||||
|
||||
// VM folder ID
|
||||
VMFolderID uint64 `json:"vmfolder_id"`
|
||||
}
|
||||
|
||||
// List of Linked Jobs
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package cloudbroker
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/pkg/cloudbroker/basismpm"
|
||||
)
|
||||
|
||||
// Accessing the BasisMPM method group
|
||||
func (cb *CloudBroker) BasisMPM() *basismpm.BasisMPM {
|
||||
return basismpm.New(cb.client)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package basismpm
|
||||
|
||||
import (
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/interfaces"
|
||||
)
|
||||
|
||||
// Structure for creating request to Basis mpm
|
||||
type BasisMPM struct {
|
||||
client interfaces.Caller
|
||||
}
|
||||
|
||||
// BasisMPM for Basis mpm endpoints
|
||||
func New(client interfaces.Caller) *BasisMPM {
|
||||
return &BasisMPM{
|
||||
client: client,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package basismpm
|
||||
|
||||
type MemInfo struct {
|
||||
// Total amount of memory
|
||||
MemTotal string `json:"MemTotal"`
|
||||
|
||||
// Amount of free memory
|
||||
MemFree string `json:"MemFree"`
|
||||
|
||||
// Amount of available memory
|
||||
MemAvailable string `json:"MemAvailable"`
|
||||
|
||||
// Amount of available memory (in percent)
|
||||
MemAvailablePercent float64 `json:"MemAvailablePercent"`
|
||||
}
|
||||
|
||||
// Basis MPM service status
|
||||
type RecordBasisMPM struct {
|
||||
// Whether the service is installed
|
||||
ServiceInstalled bool `json:"service_installed"`
|
||||
|
||||
// Whether the config exists
|
||||
ConfigExists bool `json:"config_exists"`
|
||||
|
||||
// Whether the service is active
|
||||
ServiceActive bool `json:"service_active"`
|
||||
|
||||
// Service state
|
||||
ServiceState string `json:"service_state"`
|
||||
|
||||
// Config
|
||||
Config interface{} `json:"config"`
|
||||
|
||||
// Memory info
|
||||
MemInfo MemInfo `json:"meminfo"`
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package basismpm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// StartRequest to start basis_mpm service on a node
|
||||
type StartRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
|
||||
// Memory pressure threshold (%)
|
||||
// Required: false
|
||||
// Default: 20
|
||||
PressureThreshold float64 `url:"pressure_threshold,omitempty" json:"pressure_threshold,omitempty" validate:"omitempty,pressureThreshold"`
|
||||
|
||||
// Deflate threshold (%)
|
||||
// Required: false
|
||||
// Default: 30
|
||||
DeflateThreshold float64 `url:"deflate_threshold,omitempty" json:"deflate_threshold,omitempty" validate:"omitempty,deflateThreshold"`
|
||||
|
||||
// Host reserved memory
|
||||
// Required: false
|
||||
// Default: "8GB+5%"
|
||||
HostReserved string `url:"host_reserved,omitempty" json:"host_reserved,omitempty"`
|
||||
|
||||
// Buffer percentage (%)
|
||||
// Required: false
|
||||
// Default: 20
|
||||
BufferPCT float64 `url:"buffer_pct,omitempty" json:"buffer_pct,omitempty" validate:"omitempty,bufferPCT"`
|
||||
|
||||
// Guaranteed memory percentage (%)
|
||||
// Required: false
|
||||
// Default: 25
|
||||
GuaranteedPCT float64 `url:"guaranteed_pct,omitempty" json:"guaranteed_pct,omitempty" validate:"omitempty,guaranteedPCT"`
|
||||
|
||||
// Absolute minimum guaranteed memory (MB)
|
||||
// Required: false
|
||||
// Default: 512
|
||||
GuaranteedABSMin uint64 `url:"guaranteed_abs_min,omitempty" json:"guaranteed_abs_min,omitempty" validate:"omitempty,guaranteedABSMin"`
|
||||
|
||||
// Shrink threshold percentage (%)
|
||||
// Required: false
|
||||
// Default: 50
|
||||
ShrinkThresholdPCT float64 `url:"shrink_threshold_pct,omitempty" json:"shrink_threshold_pct,omitempty" validate:"omitempty,shrinkThresholdPCT"`
|
||||
|
||||
// Max shrink percentage per cycle (%)
|
||||
// Required: false
|
||||
// Default: 10
|
||||
BalloonMaxShrinkPCT float64 `url:"balloon_max_shrink_pct,omitempty" json:"balloon_max_shrink_pct,omitempty" validate:"omitempty,balloonMaxShrinkPCT"`
|
||||
|
||||
// Max grow percentage per cycle (%)
|
||||
// Required: false
|
||||
// Default: 10
|
||||
BalloonMaxGrowPCT float64 `url:"balloon_max_grow_pct,omitempty" json:"balloon_max_grow_pct,omitempty" validate:"omitempty,balloonMaxGrowPCT"`
|
||||
|
||||
// VM change cooldown (seconds)
|
||||
// Required: false
|
||||
// Default: 60
|
||||
VMChangeCooldown uint64 `url:"vm_change_cooldown,omitempty" json:"vm_change_cooldown,omitempty" validate:"omitempty,vmChangeCooldown"`
|
||||
|
||||
// Emergency return cooldown (seconds)
|
||||
// Required: false
|
||||
// Default: 300
|
||||
EmergencyReturnCooldown uint64 `url:"emergency_return_cooldown,omitempty" json:"emergency_return_cooldown,omitempty"`
|
||||
|
||||
// Major fault increase per cycle that triggers emergency memory return
|
||||
// Required: false
|
||||
// Default: 100
|
||||
MajorFaultThreshold uint64 `url:"major_fault_threshold,omitempty" json:"major_fault_threshold,omitempty" validate:"omitempty,majorFaultThreshold"`
|
||||
|
||||
// Daemon log level
|
||||
// Required: false
|
||||
// Default: INFO
|
||||
// Options:
|
||||
// - DEBUG
|
||||
// - INFO
|
||||
// - WARNING
|
||||
// - ERROR
|
||||
// - CRITICAL
|
||||
LogLevel string `url:"log_level,omitempty" json:"log_level,omitempty" validate:"omitempty,logLevel"`
|
||||
}
|
||||
|
||||
// Start starts basis_mpm service on a node
|
||||
func (bm BasisMPM) Start(ctx context.Context, req StartRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/basis_mpm/start"
|
||||
|
||||
res, err := bm.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
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package basismpm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// StatusRequest to get basis_mpm service status on a node
|
||||
type StatusRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Status gets basis_mpm service status on a node
|
||||
func (bm BasisMPM) Status(ctx context.Context, req StatusRequest) (*RecordBasisMPM, error) {
|
||||
res, err := bm.StatusRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := RecordBasisMPM{}
|
||||
|
||||
err = json.Unmarshal(res, &info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// StatusRaw gets basis_mpm service status on a node as an array of bites
|
||||
func (bm BasisMPM) StatusRaw(ctx context.Context, req StatusRequest) ([]byte, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/basis_mpm/status"
|
||||
|
||||
res, err := bm.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
return res, err
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package basismpm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// StopRequest to stop basis_mpm service on a node
|
||||
type StopRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
|
||||
// Restore VM memory before stopping
|
||||
// Required: false
|
||||
// Default: true
|
||||
RestoreMemory interface{} `url:"restore_memory,omitempty" json:"restore_memory,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// Stop stops basis_mpm service on a node
|
||||
func (bm BasisMPM) Stop(ctx context.Context, req StopRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/basis_mpm/stop"
|
||||
|
||||
res, err := bm.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
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package basismpm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
// UpdateRequest to update basis_mpm service configuration on a node
|
||||
type UpdateRequest struct {
|
||||
// Node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
|
||||
// Memory pressure threshold (%)
|
||||
// Required: false
|
||||
// Default: 20
|
||||
PressureThreshold float64 `url:"pressure_threshold,omitempty" json:"pressure_threshold,omitempty" validate:"omitempty,pressureThreshold"`
|
||||
|
||||
// Deflate threshold (%)
|
||||
// Required: false
|
||||
// Default: 30
|
||||
DeflateThreshold float64 `url:"deflate_threshold,omitempty" json:"deflate_threshold,omitempty" validate:"omitempty,deflateThreshold"`
|
||||
|
||||
// Host reserved memory
|
||||
// Required: false
|
||||
// Default: "8GB+5%"
|
||||
HostReserved string `url:"host_reserved,omitempty" json:"host_reserved,omitempty"`
|
||||
|
||||
// Buffer percentage (%)
|
||||
// Required: false
|
||||
// Default: 20
|
||||
BufferPCT float64 `url:"buffer_pct,omitempty" json:"buffer_pct,omitempty" validate:"omitempty,bufferPCT"`
|
||||
|
||||
// Guaranteed memory percentage (%)
|
||||
// Required: false
|
||||
// Default: 25
|
||||
GuaranteedPCT float64 `url:"guaranteed_pct,omitempty" json:"guaranteed_pct,omitempty" validate:"omitempty,guaranteedPCT"`
|
||||
|
||||
// Absolute minimum guaranteed memory (MB)
|
||||
// Required: false
|
||||
// Default: 512
|
||||
GuaranteedABSMin uint64 `url:"guaranteed_abs_min,omitempty" json:"guaranteed_abs_min,omitempty" validate:"omitempty,guaranteedABSMin"`
|
||||
|
||||
// Shrink threshold percentage (%)
|
||||
// Required: false
|
||||
// Default: 50
|
||||
ShrinkThresholdPCT float64 `url:"shrink_threshold_pct,omitempty" json:"shrink_threshold_pct,omitempty" validate:"omitempty,shrinkThresholdPCT"`
|
||||
|
||||
// Max shrink percentage per cycle (%)
|
||||
// Required: false
|
||||
// Default: 10
|
||||
BalloonMaxShrinkPCT float64 `url:"balloon_max_shrink_pct,omitempty" json:"balloon_max_shrink_pct,omitempty" validate:"omitempty,balloonMaxShrinkPCT"`
|
||||
|
||||
// Max grow percentage per cycle (%)
|
||||
// Required: false
|
||||
// Default: 10
|
||||
BalloonMaxGrowPCT float64 `url:"balloon_max_grow_pct,omitempty" json:"balloon_max_grow_pct,omitempty" validate:"omitempty,balloonMaxGrowPCT"`
|
||||
|
||||
// VM change cooldown (seconds)
|
||||
// Required: false
|
||||
// Default: 60
|
||||
VMChangeCooldown uint64 `url:"vm_change_cooldown,omitempty" json:"vm_change_cooldown,omitempty" validate:"omitempty,vmChangeCooldown"`
|
||||
|
||||
// Emergency return cooldown (seconds)
|
||||
// Required: false
|
||||
// Default: 300
|
||||
EmergencyReturnCooldown uint64 `url:"emergency_return_cooldown,omitempty" json:"emergency_return_cooldown,omitempty" validate:"omitempty,emergencyReturnCooldown"`
|
||||
|
||||
// Major fault increase per cycle that triggers emergency memory return
|
||||
// Required: false
|
||||
// Default: 100
|
||||
MajorFaultThreshold uint64 `url:"major_fault_threshold,omitempty" json:"major_fault_threshold,omitempty" validate:"omitempty,majorFaultThreshold"`
|
||||
|
||||
// Daemon log level
|
||||
// Required: false
|
||||
// Default: INFO
|
||||
// Options:
|
||||
// - DEBUG
|
||||
// - INFO
|
||||
// - WARNING
|
||||
// - ERROR
|
||||
// - CRITICAL
|
||||
LogLevel string `url:"log_level,omitempty" json:"log_level,omitempty" validate:"omitempty,logLevel"`
|
||||
}
|
||||
|
||||
func (bm BasisMPM) Update(ctx context.Context, req UpdateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/basis_mpm/update"
|
||||
|
||||
res, err := bm.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
|
||||
}
|
||||
@@ -26,6 +26,8 @@ type wrapperCreateTemplateRequest struct {
|
||||
}
|
||||
|
||||
// CreateTemplate create template from compute instance
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -50,6 +52,8 @@ func (c Compute) CreateTemplate(ctx context.Context, req CreateTemplateRequest)
|
||||
}
|
||||
|
||||
// CreateTemplateAsync create template from compute instance with AsyncMode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) CreateTemplateAsync(ctx context.Context, req CreateTemplateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -60,6 +60,8 @@ type wrapperCreateTemplateFromBlankRequest struct {
|
||||
|
||||
// CreateTemplateFromBlank creates template from boot disk of current compute in sync mode.
|
||||
// It returns id of created compute and error.
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) CreateTemplateFromBlank(ctx context.Context, req CreateTemplateFromBlankRequest) (uint64, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -88,6 +90,8 @@ func (c Compute) CreateTemplateFromBlank(ctx context.Context, req CreateTemplate
|
||||
|
||||
// CreateTemplateFromBlankAsync creates template from boot disk of current compute in async mode.
|
||||
// It returns guid of task and error.
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) CreateTemplateFromBlankAsync(ctx context.Context, req CreateTemplateFromBlankRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,6 +30,8 @@ type wrapperDiskQOSRequest struct {
|
||||
}
|
||||
|
||||
// DiskQOS changes QOS of the disk
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -57,6 +59,8 @@ func (c Compute) DiskQOS(ctx context.Context, req DiskQOSRequest) (bool, error)
|
||||
}
|
||||
|
||||
// DiskQOSAsync changes QOS of the disk with AsyncMode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) DiskQOSAsync(ctx context.Context, req DiskQOSRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -21,6 +21,10 @@ type DiskSwitchToReplicationRequest struct {
|
||||
// Delete replication relationship
|
||||
// Required: false
|
||||
StopReplication bool `url:"stopReplication" json:"stopReplication"`
|
||||
|
||||
// Use planned failover for asynchronous replication
|
||||
// Required: false
|
||||
Planned interface{} `url:"planned,omitempty" json:"planned,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
type wrapperDiskSwitchToReplicationRequest struct {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/constants"
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
)
|
||||
|
||||
type Pin struct {
|
||||
// ID of the compute instance
|
||||
// Required: true
|
||||
ComputeID uint64 `url:"compute_id" json:"compute_id" validate:"required"`
|
||||
|
||||
// Target node ID. Required for stopped computes.
|
||||
// For started computes it is optional;
|
||||
// if it differs from the current node, allow_migration must be true,
|
||||
// otherwise the compute is reported with migration_not_allowed error.
|
||||
// Required: false
|
||||
NodeID uint64 `url:"node_id,omitempty" json:"node_id,omitempty"`
|
||||
}
|
||||
|
||||
// MassPinToNodeRequest to pin multiple computes to nodes in a single call
|
||||
type MassPinToNodeRequest struct {
|
||||
// Computes to pin, at most 200 items per request
|
||||
// Required: true
|
||||
Pins []Pin `url:"pins" json:"pins" validate:"required,min=1,max=200,dive"`
|
||||
|
||||
// Allow live migration of started computes to the requested node_id
|
||||
// Default: false
|
||||
// Required: false
|
||||
AllowMigration interface{} `url:"allow_migration,omitempty" json:"allow_migration,omitempty" validate:"omitempty,isBool"`
|
||||
|
||||
// Start compute after node exits from MAINTENANCE state
|
||||
// Default: false
|
||||
// Required: false
|
||||
AutoStart interface{} `url:"auto_start,omitempty" json:"auto_start,omitempty" validate:"omitempty,isBool"`
|
||||
}
|
||||
|
||||
// MassPinToNode pins multiple computes to nodes in a single call
|
||||
func (c Compute) MassPinToNode(ctx context.Context, req MassPinToNodeRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/mass_pin_to_node"
|
||||
|
||||
res, err := c.client.DecortApiCallCtype(ctx, http.MethodPost, url, constants.MIMEJSON, req)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var resp string
|
||||
|
||||
err = json.Unmarshal(res, &resp)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
@@ -26,6 +26,8 @@ type AsyncWrapperMigrateRequest struct {
|
||||
}
|
||||
|
||||
// Migrate migrates compute to another node
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) Migrate(ctx context.Context, req MigrateRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -50,6 +52,8 @@ func (c Compute) Migrate(ctx context.Context, req MigrateRequest) (bool, error)
|
||||
}
|
||||
|
||||
// AsyncMigrate migrates compute to another node in async mode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) AsyncMigrate(ctx context.Context, req MigrateRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -22,6 +22,8 @@ type wrapperMigrateAbortRequest struct {
|
||||
}
|
||||
|
||||
// MigrateAbort aborts compute migration
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -46,6 +48,8 @@ func (c Compute) MigrateAbort(ctx context.Context, req MigrateAbortRequest) (str
|
||||
}
|
||||
|
||||
// MigrateAbortAsync aborts compute migration with AsyncMode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) MigrateAbortAsync(ctx context.Context, req MigrateAbortRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
@@ -3,6 +3,7 @@ package compute
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"repository.basistech.ru/BASIS/dynamix-golang-sdk/v16/internal/validators"
|
||||
@@ -25,17 +26,48 @@ type MigrateStorageRequest struct {
|
||||
// Target node ID
|
||||
// Required: true
|
||||
NodeID uint64 `url:"node_id" json:"node_id" validate:"required"`
|
||||
}
|
||||
|
||||
// Async API call
|
||||
// Required: true
|
||||
Async interface{} `url:"async_mode" json:"async_mode" validate:"required,isBool"`
|
||||
type wrapperMigrateStorageRequest struct {
|
||||
MigrateStorageRequest
|
||||
AsyncMode bool `url:"async_mode,omitempty"`
|
||||
}
|
||||
|
||||
// MigrateStorage gets complex compute migration
|
||||
// Compute will be migrated to specified node, and compute disks will
|
||||
// be migrated to specified SEP to specified pool.
|
||||
// This action can take up to 84 hours
|
||||
func (c Compute) MigrateStorage(ctx context.Context, req MigrateStorageRequest) (string, error) {
|
||||
func (c Compute) MigrateStorage(ctx context.Context, req MigrateStorageRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/compute/migrateStorage"
|
||||
|
||||
aReq := wrapperMigrateStorageRequest{
|
||||
MigrateStorageRequest: req,
|
||||
AsyncMode: false,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// MigrateStorageAsync gets complex compute migration in async mode
|
||||
// Compute will be migrated to specified node, and compute disks will
|
||||
// be migrated to specified SEP to specified pool.
|
||||
// This action can take up to 84 hours
|
||||
func (c Compute) MigrateStorageAsync(ctx context.Context, req MigrateStorageRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return "", validators.ValidationErrors(validators.GetErrors(err))
|
||||
@@ -43,7 +75,12 @@ func (c Compute) MigrateStorage(ctx context.Context, req MigrateStorageRequest)
|
||||
|
||||
url := "/cloudbroker/compute/migrateStorage"
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
aReq := wrapperMigrateStorageRequest{
|
||||
MigrateStorageRequest: req,
|
||||
AsyncMode: true,
|
||||
}
|
||||
|
||||
res, err := c.client.DecortApiCall(ctx, http.MethodPost, url, aReq)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ type wrapperMigrateStorageAbortRequest struct {
|
||||
}
|
||||
|
||||
// MigrateStorageAbort aborts complex compute migration job
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) MigrateStorageAbort(ctx context.Context, req MigrateStorageAbortRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
@@ -54,6 +56,8 @@ func (c Compute) MigrateStorageAbort(ctx context.Context, req MigrateStorageAbor
|
||||
}
|
||||
|
||||
// MigrateStorageAbortAsync aborts complex compute migration job with AsyncMode
|
||||
//
|
||||
// Deprecated: will be removed in SDK v17.0
|
||||
func (c Compute) MigrateStorageAbortAsync(ctx context.Context, req MigrateStorageAbortRequest) (string, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
|
||||
Loaded 100 of 173 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user