This commit is contained in:
2023-03-24 17:09:30 +03:00
parent 437841c8dd
commit 84b64b7d80
433 changed files with 4246 additions and 6516 deletions

View File

@@ -2,39 +2,31 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for grant access to SEP
type AccessGrantRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Account ID to grant access to the specified SEP. If 0,
// the SEP will be available for all accounts with no exceptions
// Required: true
AccountID uint64 `url:"account_id" json:"account_id"`
}
func (srq AccessGrantRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if srq.AccountID == 0 {
return errors.New("validation-error: field AccountID must be set")
}
return nil
AccountID uint64 `url:"account_id" json:"account_id" validate:"required"`
}
// AccessGrant grant access to SEP
func (s SEP) AccessGrant(ctx context.Context, req AccessGrantRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/accessGrant"

View File

@@ -2,20 +2,21 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for grant access to pool SEP
type AccessGrantToPoolRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Pool name
// Required: true
PoolName string `url:"pool_name" json:"pool_name"`
PoolName string `url:"pool_name" json:"pool_name" validate:"required"`
// Account ID to grant access to the specified pool SEP
// Required: false
@@ -26,22 +27,13 @@ type AccessGrantToPoolRequest struct {
RGID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"`
}
func (srq AccessGrantToPoolRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if srq.PoolName == "" {
return errors.New("validation-error: field PoolName must be set")
}
return nil
}
// AccessGrantToPool grant access to pool SEP
func (s SEP) AccessGrantToPool(ctx context.Context, req AccessGrantToPoolRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/accessGrantToPool"

View File

@@ -2,38 +2,30 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for revoke access to SEP
type AccessRevokeRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Account ID to revoke access to the specified SEP
// Required: true
AccountID uint64 `url:"account_id" json:"account_id"`
}
func (srq AccessRevokeRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if srq.AccountID == 0 {
return errors.New("validation-error: field AccountID must be set")
}
return nil
AccountID uint64 `url:"account_id" json:"account_id" validate:"required"`
}
// AccessRevoke revoke access to SEP
func (s SEP) AccessRevoke(ctx context.Context, req AccessRevokeRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/accessRevoke"

View File

@@ -2,20 +2,21 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for revoke access to pool SEP
type AccessRevokeToPoolRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Pool name
// Required: true
PoolName string `url:"pool_name" json:"pool_name"`
PoolName string `url:"pool_name" json:"pool_name" validate:"required"`
// Account ID to grant access to the specified pool SEP
// Required: false
@@ -26,22 +27,13 @@ type AccessRevokeToPoolRequest struct {
RGID uint64 `url:"resgroup_id,omitempty" json:"resgroup_id,omitempty"`
}
func (srq AccessRevokeToPoolRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if srq.PoolName == "" {
return errors.New("validation-error: field PoolName must be set")
}
return nil
}
// AccessRevokeToPool revoke access to pool SEP
func (s SEP) AccessRevokeToPool(ctx context.Context, req AccessRevokeToPoolRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/accessRevokeToPool"

View File

@@ -2,38 +2,30 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for add consumer nodes
type AddConsumerNodesRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// List of nodes IDs
// Required: true
ConsumerNIDs []uint64 `url:"consumer_nids" json:"consumer_nids"`
}
func (srq AddConsumerNodesRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if len(srq.ConsumerNIDs) == 0 {
return errors.New("validation-error: field ConsumerNIDs must be set")
}
return nil
ConsumerNIDs []uint64 `url:"consumer_nids" json:"consumer_nids" validate:"min=1"`
}
// AddConsumerNodes add consumer nodes to SEP parameters
func (s SEP) AddConsumerNodes(ctx context.Context, req AddConsumerNodesRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/addConsumerNodes"

View File

@@ -2,38 +2,30 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for add provider nodes
type AddProviderNodesRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// List of node IDs
// Required: true
ProviderNIDs []uint64 `url:"provider_nids" json:"provider_nids"`
}
func (srq AddProviderNodesRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if len(srq.ProviderNIDs) == 0 {
return errors.New("validation-error: field ProviderNIDs must be set")
}
return nil
ProviderNIDs []uint64 `url:"provider_nids" json:"provider_nids" validate:"min=1"`
}
// AddProviderNodes add provider nodes to SEP parameters
func (s SEP) AddProviderNodes(ctx context.Context, req AddProviderNodesRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/addProviderNodes"

View File

@@ -2,7 +2,6 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
@@ -13,15 +12,15 @@ import (
type ConfigFieldEditRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Field name
// Required: true
FieldName string `url:"field_name" json:"field_name"`
FieldName string `url:"field_name" json:"field_name" validate:"required"`
// Field value
// Required: true
FieldValue string `url:"field_value" json:"field_value"`
FieldValue string `url:"field_value" json:"field_value" validate:"required"`
// Field type
// Should be one of:
@@ -31,35 +30,16 @@ type ConfigFieldEditRequest struct {
// - list
// - dict
// Required: true
FieldType string `url:"field_type" json:"field_type"`
}
func (srq ConfigFieldEditRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if srq.FieldName == "" {
return errors.New("validation-error: field FieldName must be set")
}
if srq.FieldValue == "" {
return errors.New("validation-error: field FieldValue must be set")
}
if srq.FieldType == "" {
return errors.New("validation-error: field FieldType must be set")
}
validate := validators.StringInSlice(srq.FieldType, []string{"int", "str", "bool", "list", "dict"})
if !validate {
return errors.New("validation-error: field FieldType must be one of int, str, bool, list, dict")
}
return nil
FieldType string `url:"field_type" json:"field_type" validate:"sepFieldType"`
}
// ConfigFieldEdit edit SEP config field value
func (s SEP) ConfigFieldEdit(ctx context.Context, req ConfigFieldEditRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/configFieldEdit"

View File

@@ -2,38 +2,30 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for insert config
type ConfigInsertRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Storage provider config
// Required: true
Config string `url:"config" json:"config"`
}
func (srq ConfigInsertRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if srq.Config == "" {
return errors.New("validation-error: feold Config must be set")
}
return nil
Config string `url:"config" json:"config" validate:"required"`
}
// ConfigInsert insert config to SEP
func (s SEP) ConfigInsert(ctx context.Context, req ConfigInsertRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/configInsert"

View File

@@ -2,38 +2,30 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for validate config
type ConfigValidateRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Storage provider config
// Required: true
Config string `url:"config" json:"config"`
}
func (srq ConfigValidateRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if srq.Config == "" {
return errors.New("validation-error: feold Config must be set")
}
return nil
Config string `url:"config" json:"config" validate:"required"`
}
// ConfigValidate verify config for the SEP
func (s SEP) ConfigValidate(ctx context.Context, req ConfigValidateRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/configValidate"

View File

@@ -3,30 +3,25 @@ package sep
import (
"context"
"encoding/json"
"errors"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for get consumption info
type ConsumptionRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
}
func (srq ConsumptionRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
return nil
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
}
// Consumption get SEP consumption info
func (s SEP) Consumption(ctx context.Context, req ConsumptionRequest) (*RecordConsumption, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return nil, err
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/consumption"

View File

@@ -2,24 +2,25 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for create SEP object
type CreateRequest struct {
// Grid ID
// Required: true
GID uint64 `url:"gid" json:"gid"`
GID uint64 `url:"gid" json:"gid" validate:"required"`
// SEP name
// Required: true
Name string `url:"name" json:"name"`
Name string `url:"name" json:"name" validate:"required"`
// Type of storage
// Required: true
SEPType string `url:"sep_type" json:"sep_type"`
SEPType string `url:"sep_type" json:"sep_type" validate:"required"`
// Description
// Required: false
@@ -42,25 +43,13 @@ type CreateRequest struct {
Enable bool `url:"enable,omitempty" json:"enable,omitempty"`
}
func (srq CreateRequest) validate() error {
if srq.GID == 0 {
return errors.New("validation-error: field GID must be set")
}
if srq.Name == "" {
return errors.New("validation-error: field Name must be set")
}
if srq.SEPType == "" {
return errors.New("validation-error: field SEPType must be set")
}
return nil
}
// Create creates SEP object
func (s SEP) Create(ctx context.Context, req CreateRequest) (uint64, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return 0, err
for _, validationError := range validators.GetErrors(err) {
return 0, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/create"

View File

@@ -2,35 +2,30 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for decommission
type DecommissionRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Clear disks and images physically
// Required: false
ClearPhisically bool `url:"clear_physically,omitempty" json:"clear_physically,omitempty"`
}
func (srq DecommissionRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
return nil
}
// Decommission unlink everything that exists from SEP
func (s SEP) Decommission(ctx context.Context, req DecommissionRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/decommission"

View File

@@ -2,38 +2,30 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for exclude consumer nodes
type DelConsumerNodesRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// List of consumer node IDs
// Required: true
ConsumerNIDs []uint64 `url:"consumer_nids" json:"consumer_nids"`
}
func (srq DelConsumerNodesRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if len(srq.ConsumerNIDs) == 0 {
return errors.New("validation-error: field ConsumerNIDs must be set")
}
return nil
ConsumerNIDs []uint64 `url:"consumer_nids" json:"consumer_nids" validate:"min=1"`
}
// DelConsumerNodes exclude consumer nodes from SEP parameters
func (s SEP) DelConsumerNodes(ctx context.Context, req DelConsumerNodesRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/delConsumerNodes"

View File

@@ -2,31 +2,26 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for delete SEP
type DeleteRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
}
func (srq DeleteRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
return nil
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
}
// Delete deletes SEP by ID
func (s SEP) Delete(ctx context.Context, req DeleteRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/delete"

View File

@@ -2,31 +2,26 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for disable SEP
type DisableRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
}
func (srq DisableRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
return nil
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
}
// Disable disables SEP by ID
func (s SEP) Disable(ctx context.Context, req DisableRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/disable"

View File

@@ -3,34 +3,29 @@ package sep
import (
"context"
"encoding/json"
"errors"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for get list of disk IDs
type DiskListRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Pool name
// Required: false
PoolName string `url:"pool_name,omitempty" json:"pool_name,omitempty"`
}
func (srq DiskListRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
return nil
}
// DiskList get list of disk IDs, who use this SEP and pool (if provided)
func (s SEP) DiskList(ctx context.Context, req DiskListRequest) ([]uint64, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return nil, err
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/diskList"

View File

@@ -2,31 +2,26 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for enable SEP
type EnableRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
}
func (srq EnableRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
return nil
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
}
// Enable enables SEP by ID
func (s SEP) Enable(ctx context.Context, req EnableRequest) (bool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return false, err
for _, validationError := range validators.GetErrors(err) {
return false, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/enable"

View File

@@ -3,30 +3,25 @@ package sep
import (
"context"
"encoding/json"
"errors"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for get SEP parameters
type GetRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
}
func (srq GetRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
return nil
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
}
// Get gets SEP parameters
func (s SEP) Get(ctx context.Context, req GetRequest) (*RecordSEP, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return nil, err
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/get"

View File

@@ -3,30 +3,25 @@ package sep
import (
"context"
"encoding/json"
"errors"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for get SEP config
type GetConfigRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
}
func (srq GetConfigRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
return nil
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
}
// GetConfig gets SEP config
func (s SEP) GetConfig(ctx context.Context, req GetConfigRequest) (*SEPConfig, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return nil, err
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/getConfig"

View File

@@ -3,37 +3,29 @@ package sep
import (
"context"
"encoding/json"
"errors"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for get SEP pool config by name
type GetPoolRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
// Pool name
// Required: true
PoolName string `url:"pool_name" json:"pool_name"`
}
func (srq GetPoolRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
if srq.PoolName == "" {
return errors.New("validation-error: PoolName must be set")
}
return nil
PoolName string `url:"pool_name" json:"pool_name" validate:"required"`
}
// GetPool gets SEP pool config by name
func (s SEP) GetPool(ctx context.Context, req GetPoolRequest) (*RecordPool, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return nil, err
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/getPool"

View File

@@ -2,31 +2,26 @@ package sep
import (
"context"
"errors"
"net/http"
"strconv"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for update capacity limits
type UpdateCapacityLimitRequest struct {
// Storage endpoint provider ID
// Required: true
SEPID uint64 `url:"sep_id" json:"sep_id"`
}
func (srq UpdateCapacityLimitRequest) validate() error {
if srq.SEPID == 0 {
return errors.New("validation-error: field SEPID must be set")
}
return nil
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
}
// UpdateCapacityLimit updates SEP capacity limit
func (s SEP) UpdateCapacityLimit(ctx context.Context, req UpdateCapacityLimitRequest) (uint64, error) {
err := req.validate()
err := validators.ValidateRequest(req)
if err != nil {
return 0, err
for _, validationError := range validators.GetErrors(err) {
return 0, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/sep/updateCapacityLimit"