Compare commits
2 Commits
v1.4.1
...
v1.5.0-alf
| Author | SHA1 | Date | |
|---|---|---|---|
| 256dba5134 | |||
| b7137683ab |
@@ -1,6 +1,6 @@
|
|||||||
## Version 1.4.1
|
## Version 1.4.2
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
- Fixed cloudapi/k8s/workerAdd returning value type
|
- Fixed cloudapi/cloudbroker/compute/pfwAdd publicPortEnd request field type
|
||||||
- Fixed cloudapi/cloudbroker/account/create/update SendAccessEmails field tags
|
- Fixed typo in cloudapi/k8s/disable/enable request name
|
||||||
|
|||||||
@@ -19,8 +19,9 @@ type PFWAddRequest struct {
|
|||||||
PublicPortStart uint64 `url:"publicPortStart" json:"publicPortStart" validate:"required"`
|
PublicPortStart uint64 `url:"publicPortStart" json:"publicPortStart" validate:"required"`
|
||||||
|
|
||||||
// End port number (inclusive) for the ranged rule
|
// End port number (inclusive) for the ranged rule
|
||||||
|
// Default value: -1
|
||||||
// Required: false
|
// Required: false
|
||||||
PublicPortEnd uint64 `url:"publicPortEnd,omitempty" json:"publicPortEnd,omitempty"`
|
PublicPortEnd int64 `url:"publicPortEnd,omitempty" json:"publicPortEnd,omitempty"`
|
||||||
|
|
||||||
// Internal base port number
|
// Internal base port number
|
||||||
// Required: true
|
// Required: true
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Request struct for disable/enable kubernetes cluster
|
// Request struct for disable/enable kubernetes cluster
|
||||||
type DisabelEnableRequest struct {
|
type DisableEnableRequest struct {
|
||||||
// Kubernetes cluster ID
|
// Kubernetes cluster ID
|
||||||
// Required: true
|
// Required: true
|
||||||
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
K8SID uint64 `url:"k8sId" json:"k8sId" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable disables kubernetes cluster by ID
|
// Disable disables kubernetes cluster by ID
|
||||||
func (k8s K8S) Disable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
func (k8s K8S) Disable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
@@ -40,7 +40,7 @@ func (k8s K8S) Disable(ctx context.Context, req DisabelEnableRequest) (bool, err
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Enable enables kubernetes cluster by ID
|
// Enable enables kubernetes cluster by ID
|
||||||
func (k8s K8S) Enable(ctx context.Context, req DisabelEnableRequest) (bool, error) {
|
func (k8s K8S) Enable(ctx context.Context, req DisableEnableRequest) (bool, error) {
|
||||||
err := validators.ValidateRequest(req)
|
err := validators.ValidateRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, validationError := range validators.GetErrors(err) {
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
|||||||
8
pkg/cloudbroker/backup.go
Normal file
8
pkg/cloudbroker/backup.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package cloudbroker
|
||||||
|
|
||||||
|
import "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/backup"
|
||||||
|
|
||||||
|
// Accessing the Backup method group
|
||||||
|
func (cb *CloudBroker) Backup() *backup.Backup {
|
||||||
|
return backup.New(cb.client)
|
||||||
|
}
|
||||||
17
pkg/cloudbroker/backup/backup.go
Normal file
17
pkg/cloudbroker/backup/backup.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package backup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Structure for creating request to backup
|
||||||
|
type Backup struct {
|
||||||
|
client interfaces.Caller
|
||||||
|
}
|
||||||
|
|
||||||
|
// Builder for backup endpoints
|
||||||
|
func New(client interfaces.Caller) *Backup {
|
||||||
|
return &Backup{
|
||||||
|
client: client,
|
||||||
|
}
|
||||||
|
}
|
||||||
81
pkg/cloudbroker/backup/create_disk_backup.go
Normal file
81
pkg/cloudbroker/backup/create_disk_backup.go
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
package backup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for creating disk backup
|
||||||
|
type CreateDiskBackupRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
// Required: true
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Disk ID
|
||||||
|
// Required: true
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
|
||||||
|
// Backup path
|
||||||
|
// Required: true
|
||||||
|
BackupPath string `url:"backupPath" json:"backupPath" validate:"required"`
|
||||||
|
|
||||||
|
// Async API Call
|
||||||
|
// For async call use CreateDiskBackupAsync
|
||||||
|
// For sync call use CreateDiskBackup
|
||||||
|
// Required: true
|
||||||
|
async bool `url:"async"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateDiskBackup creates disk backup
|
||||||
|
func (b Backup) CreateDiskBackup(ctx context.Context, req CreateDiskBackupRequest) (ListInfoBackup, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.async = false
|
||||||
|
|
||||||
|
url := "/cloudbroker/backup/createDiskBackup"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make(ListInfoBackup, 0)
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateDiskBackupAsync creates disk backup
|
||||||
|
func (b Backup) CreateDiskBackupAsync(ctx context.Context, req CreateDiskBackupRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return "", validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.async = true
|
||||||
|
|
||||||
|
url := "/cloudbroker/backup/createDiskBackup"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := strings.ReplaceAll(string(res), "\"", "")
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
83
pkg/cloudbroker/backup/create_disks_backup.go
Normal file
83
pkg/cloudbroker/backup/create_disks_backup.go
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
package backup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Disk struct {
|
||||||
|
// Disk ID
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
|
||||||
|
// Backup path
|
||||||
|
BackupPath string `url:"backupPath" json:"backupPath" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request struct for creating disks backup
|
||||||
|
type CreateDisksBackupRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Disks
|
||||||
|
Disks []Disk `url:"disks" json:"disks" validate:"required,dive"`
|
||||||
|
|
||||||
|
// Async API Call
|
||||||
|
// For async call use CreateDisksBackupAsync
|
||||||
|
// For sync call use CreateDisksBackup
|
||||||
|
// Required: true
|
||||||
|
async bool `url:"async"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateDisksBackup creates disks backup
|
||||||
|
func (b Backup) CreateDisksBackup(ctx context.Context, req CreateDisksBackupRequest) (ListInfoBackup, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.async = false
|
||||||
|
|
||||||
|
url := "/cloudbroker/backup/createDisksBackup"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make(ListInfoBackup, 0)
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateDisksBackupAsync creates disks backup
|
||||||
|
func (b Backup) CreateDisksBackupAsync(ctx context.Context, req CreateDisksBackupRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return "", validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.async = true
|
||||||
|
|
||||||
|
url := "/cloudbroker/backup/createDisksBackup"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := strings.ReplaceAll(string(res), "\"", "")
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
73
pkg/cloudbroker/backup/delete_disk_backup.go
Normal file
73
pkg/cloudbroker/backup/delete_disk_backup.go
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
package backup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for deleting disk backup
|
||||||
|
type DeleteDiskBackupRequest struct {
|
||||||
|
// Backup path
|
||||||
|
BackupPath string `url:"backupPath" json:"backupPath" validate:"required"`
|
||||||
|
|
||||||
|
// Backup file
|
||||||
|
BackupFile string `url:"backupFile" json:"backupFile" validate:"required"`
|
||||||
|
|
||||||
|
// Async API Call
|
||||||
|
// For async call use DeleteDiskBackupAsync
|
||||||
|
// For sync call use DeleteDiskBackup
|
||||||
|
// Required: true
|
||||||
|
async bool `url:"async"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteDiskBackup deletes disk backup
|
||||||
|
func (b Backup) DeleteDiskBackup(ctx context.Context, req DeleteDiskBackupRequest) (bool, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return false, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.async = false
|
||||||
|
|
||||||
|
url := "/cloudbroker/backup/deleteDiskBackup"
|
||||||
|
|
||||||
|
res, err := b.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
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteDiskBackupAsync deletes disk backup
|
||||||
|
func (b Backup) DeleteDiskBackupAsync(ctx context.Context, req DeleteDiskBackupRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return "", validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.async = true
|
||||||
|
|
||||||
|
url := "/cloudbroker/backup/deleteDiskBackup"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := strings.ReplaceAll(string(res), "\"", "")
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
40
pkg/cloudbroker/backup/list_backup_paths.go
Normal file
40
pkg/cloudbroker/backup/list_backup_paths.go
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
package backup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for getting list of backup paths
|
||||||
|
type ListBackupPathsRequest struct {
|
||||||
|
// Grid ID
|
||||||
|
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBackupPaths gets list of backup paths
|
||||||
|
func (b Backup) ListBackupPaths(ctx context.Context, req ListBackupPathsRequest) ([]string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
url := "/cloudbroker/backup/listBackupPaths"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
list := make([]string, 0)
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
28
pkg/cloudbroker/backup/models.go
Normal file
28
pkg/cloudbroker/backup/models.go
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package backup
|
||||||
|
|
||||||
|
// Main info about backup
|
||||||
|
type InfoBackup struct {
|
||||||
|
// Compute ID
|
||||||
|
ComputeID uint64 `json:"computeId"`
|
||||||
|
|
||||||
|
// Disk ID
|
||||||
|
DiskID uint64 `json:"diskId"`
|
||||||
|
|
||||||
|
// Backup path
|
||||||
|
BackupPath string `json:"backupPath"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateDisksBackup response
|
||||||
|
type ListInfoBackup []InfoBackup
|
||||||
|
|
||||||
|
// RestoreDiskFromFile response
|
||||||
|
type InfoRestoredDisk struct {
|
||||||
|
// Compute ID
|
||||||
|
ComputeID uint64 `json:"computeId"`
|
||||||
|
|
||||||
|
// Disk ID
|
||||||
|
DiskID uint64 `json:"diskId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RestoreDisksFromFile response
|
||||||
|
type ListInfoRestoredDisk []InfoRestoredDisk
|
||||||
81
pkg/cloudbroker/backup/restore_disk_from_backup.go
Normal file
81
pkg/cloudbroker/backup/restore_disk_from_backup.go
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
package backup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Request struct for restoring disk from backup
|
||||||
|
type RestoreDiskFromBackupRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
// Disk ID
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
|
||||||
|
// Backup path
|
||||||
|
BackupPath string `url:"backupPath" json:"backupPath" validate:"required"`
|
||||||
|
|
||||||
|
// Backup file
|
||||||
|
BackupFile string `url:"backupFile" json:"backupFile" validate:"required"`
|
||||||
|
|
||||||
|
// Async API Call
|
||||||
|
// For async call use RestoreDiskFromBackupAsync
|
||||||
|
// For sync call use RestoreDiskFromBackup
|
||||||
|
// Required: true
|
||||||
|
async bool `url:"async"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RestoreDiskFromBackup restores disk from backup
|
||||||
|
func (b Backup) RestoreDiskFromBackup(ctx context.Context, req RestoreDiskFromBackupRequest) (ListInfoRestoredDisk, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.async = false
|
||||||
|
|
||||||
|
url := "/cloudbroker/backup/restoreDiskFromBackup"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make(ListInfoRestoredDisk, 0)
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RestoreDiskFromBackupAsync restores disk from backup
|
||||||
|
func (b Backup) RestoreDiskFromBackupAsync(ctx context.Context, req RestoreDiskFromBackupRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return "", validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.async = true
|
||||||
|
|
||||||
|
url := "/cloudbroker/backup/restoreDiskFromBackup"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := strings.ReplaceAll(string(res), "\"", "")
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
86
pkg/cloudbroker/backup/restore_disks_from_backup.go
Normal file
86
pkg/cloudbroker/backup/restore_disks_from_backup.go
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
package backup
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BackupFile struct {
|
||||||
|
// Disk ID
|
||||||
|
DiskID uint64 `url:"diskId" json:"diskId" validate:"required"`
|
||||||
|
|
||||||
|
// Backup path
|
||||||
|
BackupPath string `url:"backupPath" json:"backupPath" validate:"required"`
|
||||||
|
|
||||||
|
// Backup file
|
||||||
|
BackupFile string `url:"backupFile" json:"backupFile" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request struct for restoring disks from backup
|
||||||
|
type RestoreDisksFromBackupRequest struct {
|
||||||
|
// Compute ID
|
||||||
|
ComputeID uint64 `url:"computeId" json:"computeId" validate:"required"`
|
||||||
|
|
||||||
|
//Backup files
|
||||||
|
BackupFiles []BackupFile `url:"backupFiles" json:"backupFiles" validate:"required,dive"`
|
||||||
|
|
||||||
|
// Async API Call
|
||||||
|
// For async call use RestoreDisksFromBackupAsync
|
||||||
|
// For sync call use RestoreDisksFromBackup
|
||||||
|
// Required: true
|
||||||
|
async bool `url:"async"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RestoreDisksFromBackup restores disks from backup
|
||||||
|
func (b Backup) RestoreDisksFromBackup(ctx context.Context, req RestoreDisksFromBackupRequest) (ListInfoRestoredDisk, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return nil, validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.async = false
|
||||||
|
|
||||||
|
url := "/cloudbroker/backup/restoreDisksFromBackup"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make(ListInfoRestoredDisk, 0)
|
||||||
|
|
||||||
|
err = json.Unmarshal(res, &result)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RestoreDisksFromBackupAsync restores disks from backup
|
||||||
|
func (b Backup) RestoreDisksFromBackupAsync(ctx context.Context, req RestoreDisksFromBackupRequest) (string, error) {
|
||||||
|
err := validators.ValidateRequest(req)
|
||||||
|
if err != nil {
|
||||||
|
for _, validationError := range validators.GetErrors(err) {
|
||||||
|
return "", validators.ValidationError(validationError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
req.async = true
|
||||||
|
|
||||||
|
url := "/cloudbroker/backup/restoreDisksFromBackup"
|
||||||
|
|
||||||
|
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := strings.ReplaceAll(string(res), "\"", "")
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -19,8 +19,9 @@ type PFWAddRequest struct {
|
|||||||
PublicPortStart uint64 `url:"publicPortStart" json:"publicPortStart" validate:"required"`
|
PublicPortStart uint64 `url:"publicPortStart" json:"publicPortStart" validate:"required"`
|
||||||
|
|
||||||
// End port number (inclusive) for the ranged rule
|
// End port number (inclusive) for the ranged rule
|
||||||
|
// Default value: -1
|
||||||
// Required: false
|
// Required: false
|
||||||
PublicPortEnd uint64 `url:"publicPortEnd,omitempty" json:"publicPortEnd,omitempty"`
|
PublicPortEnd int64 `url:"publicPortEnd,omitempty" json:"publicPortEnd,omitempty"`
|
||||||
|
|
||||||
// Internal base port number
|
// Internal base port number
|
||||||
// Required: true
|
// Required: true
|
||||||
|
|||||||
Reference in New Issue
Block a user