This commit is contained in:
2024-04-16 14:26:06 +03:00
parent bc264c4d90
commit e7c968797b
298 changed files with 11066 additions and 398 deletions

View File

@@ -0,0 +1,42 @@
package grid
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// AddCustomBackupPathRequest struct to add new path to the list of custom backup paths
type AddCustomBackupPathRequest struct {
// ID of the grid
// Required: true
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
// Absolute path
// Required: true
Path string `url:"path" json:"path" validate:"required"`
}
// AddCustomBackupPath add new path to the list of custom backup paths
func (g Grid) AddCustomBackupPath(ctx context.Context, req AddCustomBackupPathRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/grid/addCustomBackupPath"
res, err := g.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
}

View File

@@ -4,6 +4,8 @@ import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// ListRequest struct to get list of locations
@@ -16,6 +18,10 @@ type ListRequest struct {
// Required: false
Name string `url:"name,omitempty" json:"name,omitempty"`
// Sort by one of supported fields, format +|-(field)
// Required: false
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
// Page number
// Required: false
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
@@ -27,6 +33,7 @@ type ListRequest struct {
// List gets list of all locations as a ListGrids struct
func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
res, err := g.ListRaw(ctx, req)
if err != nil {
return nil, err
@@ -44,6 +51,11 @@ func (g Grid) List(ctx context.Context, req ListRequest) (*ListGrids, error) {
// ListRaw gets list of all locations as an array of bytes
func (g Grid) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
if err := validators.ValidateRequest(req); err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/grid/list"
res, err := g.client.DecortApiCall(ctx, http.MethodPost, url, req)

View File

@@ -0,0 +1,42 @@
package grid
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// RemoveCustomBackupPathRequest struct to remove path from the list of custom backup paths
type RemoveCustomBackupPathRequest struct {
// ID of the grid
// Required: true
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
// Absolute path
// Required: true
Path string `url:"path" json:"path" validate:"required"`
}
// RemoveCustomBackupPath remove path from the list of custom backup paths
func (g Grid) RemoveCustomBackupPath(ctx context.Context, req RemoveCustomBackupPathRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/grid/removeCustomBackupPath"
res, err := g.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
}

View File

@@ -16,7 +16,7 @@ type RenameRequest struct {
// New name
// Required: true
Name string `url:"Name" json:"Name" validate:"required"`
Name string `url:"name" json:"name" validate:"required"`
}
// Rename renames a grid

View File

@@ -0,0 +1,58 @@
package grid
import (
"context"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// SetPasswordPolicyRequest struct to set password policy for a grid
type SetPasswordPolicyRequest struct {
// ID of the grid
// Required: true
GID uint64 `url:"gridId" json:"gridId" validate:"required"`
// Available numbers in the password
// Default value : true
// Required: true
Digits bool `url:"digits" json:"digits"`
// Available special characters in the password
// Default value : false
// Required: true
SpecialSymbols bool `url:"specialSymbols" json:"specialSymbols"`
// Number of characters in the password
// Default value : 9
// Required: true
PasswordLength uint64 `url:"passwordLength" json:"passwordLength" validate:"required"`
// Capital letters in the password are available
// Default value : true
// Required: true
Uppercase bool `url:"uppercase" json:"uppercase"`
}
// RemoveCustomBackupPath set set password policy for a grid
func (g Grid) SetPasswordPolicy(ctx context.Context, req SetPasswordPolicyRequest) (bool, error) {
err := validators.ValidateRequest(req)
if err != nil {
return false, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/cloudbroker/grid/setPasswordPolicy"
res, err := g.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
}