This commit is contained in:
2023-06-23 15:13:22 +03:00
parent c06a3198f6
commit 264538f492
50 changed files with 2143 additions and 76 deletions

View File

@@ -4,8 +4,9 @@ import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
"strings"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for creating disk backup
@@ -21,12 +22,12 @@ type CreateDiskBackupRequest struct {
// 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"`
type wrapperCreateDiskBackupRequest struct {
CreateDiskBackupRequest
Async bool `url:"async"`
}
// CreateDiskBackup creates disk backup
@@ -38,11 +39,14 @@ func (b Backup) CreateDiskBackup(ctx context.Context, req CreateDiskBackupReques
}
}
req.async = false
reqWrapped := wrapperCreateDiskBackupRequest{
CreateDiskBackupRequest: req,
Async: false,
}
url := "/cloudbroker/backup/createDiskBackup"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return nil, err
}
@@ -66,11 +70,14 @@ func (b Backup) CreateDiskBackupAsync(ctx context.Context, req CreateDiskBackupR
}
}
req.async = true
reqWrapped := wrapperCreateDiskBackupRequest{
CreateDiskBackupRequest: req,
Async: true,
}
url := "/cloudbroker/backup/createDiskBackup"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}

View File

@@ -4,8 +4,9 @@ import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
"strings"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
type Disk struct {
@@ -23,12 +24,12 @@ type CreateDisksBackupRequest struct {
// 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"`
type wrapperCreateDisksBackupRequest struct {
CreateDisksBackupRequest
Async bool `url:"async"`
}
// CreateDisksBackup creates disks backup
@@ -40,11 +41,14 @@ func (b Backup) CreateDisksBackup(ctx context.Context, req CreateDisksBackupRequ
}
}
req.async = false
reqWrapped := wrapperCreateDisksBackupRequest{
CreateDisksBackupRequest: req,
Async: false,
}
url := "/cloudbroker/backup/createDisksBackup"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return nil, err
}
@@ -68,11 +72,14 @@ func (b Backup) CreateDisksBackupAsync(ctx context.Context, req CreateDisksBacku
}
}
req.async = true
reqWrapped := wrapperCreateDisksBackupRequest{
CreateDisksBackupRequest: req,
Async: true,
}
url := "/cloudbroker/backup/createDisksBackup"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}

View File

@@ -3,9 +3,10 @@ package backup
import (
"context"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
"strconv"
"strings"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for deleting disk backup
@@ -15,12 +16,12 @@ type DeleteDiskBackupRequest struct {
// 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"`
type wrapperDeleteDiskBackupRequest struct {
DeleteDiskBackupRequest
Async bool `url:"async"`
}
// DeleteDiskBackup deletes disk backup
@@ -32,11 +33,14 @@ func (b Backup) DeleteDiskBackup(ctx context.Context, req DeleteDiskBackupReques
}
}
req.async = false
reqWrapped := wrapperDeleteDiskBackupRequest{
DeleteDiskBackupRequest: req,
Async: false,
}
url := "/cloudbroker/backup/deleteDiskBackup"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return false, err
}
@@ -58,11 +62,14 @@ func (b Backup) DeleteDiskBackupAsync(ctx context.Context, req DeleteDiskBackupR
}
}
req.async = true
reqWrapped := wrapperDeleteDiskBackupRequest{
DeleteDiskBackupRequest: req,
Async: true,
}
url := "/cloudbroker/backup/deleteDiskBackup"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}

View File

@@ -4,8 +4,9 @@ import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
"strings"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for restoring disk from backup
@@ -21,12 +22,12 @@ type RestoreDiskFromBackupRequest struct {
// 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"`
type wrapperRestoreDiskFromBackupRequest struct {
RestoreDiskFromBackupRequest
Async bool `url:"async"`
}
// RestoreDiskFromBackup restores disk from backup
@@ -38,11 +39,14 @@ func (b Backup) RestoreDiskFromBackup(ctx context.Context, req RestoreDiskFromBa
}
}
req.async = false
reqWrapped := wrapperRestoreDiskFromBackupRequest{
RestoreDiskFromBackupRequest: req,
Async: false,
}
url := "/cloudbroker/backup/restoreDiskFromBackup"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return nil, err
}
@@ -66,11 +70,14 @@ func (b Backup) RestoreDiskFromBackupAsync(ctx context.Context, req RestoreDiskF
}
}
req.async = true
reqWrapped := wrapperRestoreDiskFromBackupRequest{
RestoreDiskFromBackupRequest: req,
Async: true,
}
url := "/cloudbroker/backup/restoreDiskFromBackup"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}

View File

@@ -4,8 +4,9 @@ import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
"strings"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
type BackupFile struct {
@@ -26,12 +27,12 @@ type RestoreDisksFromBackupRequest struct {
//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"`
type wrapperRestoreDisksFromBackupRequest struct {
RestoreDisksFromBackupRequest
Async bool `url:"async"`
}
// RestoreDisksFromBackup restores disks from backup
@@ -43,11 +44,14 @@ func (b Backup) RestoreDisksFromBackup(ctx context.Context, req RestoreDisksFrom
}
}
req.async = false
reqWrapped := wrapperRestoreDisksFromBackupRequest{
RestoreDisksFromBackupRequest: req,
Async: false,
}
url := "/cloudbroker/backup/restoreDisksFromBackup"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return nil, err
}
@@ -71,11 +75,14 @@ func (b Backup) RestoreDisksFromBackupAsync(ctx context.Context, req RestoreDisk
}
}
req.async = true
reqWrapped := wrapperRestoreDisksFromBackupRequest{
RestoreDisksFromBackupRequest: req,
Async: true,
}
url := "/cloudbroker/backup/restoreDisksFromBackup"
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := b.client.DecortApiCall(ctx, http.MethodPost, url, reqWrapped)
if err != nil {
return "", err
}