v1.8.0
This commit is contained in:
47
pkg/cloudbroker/sep/add_pool.go
Normal file
47
pkg/cloudbroker/sep/add_pool.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// AddPoolRequest struct to add pool to storage endpoint (SEP)
|
||||
type AddPoolRequest struct {
|
||||
// ID of SEP to add new pool
|
||||
// Required: true
|
||||
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
|
||||
|
||||
// method Async/Sync
|
||||
// Default: true
|
||||
// Required: false
|
||||
Sync bool `url:"sync" json:"sync"`
|
||||
|
||||
// Pool structure which contains fields such as "name", "types", "accessAccountIds", "accessResGroupIds"
|
||||
// Required: true
|
||||
Pool string `url:"pool" json:"pool" validate:"required"`
|
||||
}
|
||||
|
||||
// AddPool adds pool to SEP
|
||||
func (s SEP) AddPool(ctx context.Context, req AddPoolRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/sep/addPool"
|
||||
|
||||
res, err := s.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
|
||||
}
|
||||
@@ -22,14 +22,14 @@ type CreateRequest struct {
|
||||
// Required: true
|
||||
SEPType string `url:"sep_type" json:"sep_type" validate:"required"`
|
||||
|
||||
// SEP config
|
||||
// Required: true
|
||||
Config string `url:"config" json:"config" validate:"required"`
|
||||
|
||||
// Description
|
||||
// Required: false
|
||||
Description string `url:"description,omitempty" json:"description,omitempty"`
|
||||
|
||||
// SEP config
|
||||
// Required: false
|
||||
Config string `url:"config,omitempty" json:"config,omitempty"`
|
||||
|
||||
// List of provider node IDs
|
||||
// Required: false
|
||||
ProviderNIDs []uint64 `url:"provider_nids,omitempty" json:"provider_nids,omitempty"`
|
||||
|
||||
42
pkg/cloudbroker/sep/del_pool.go
Normal file
42
pkg/cloudbroker/sep/del_pool.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package sep
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// DelPoolRequest struct to delete pool from storage endpoint (SEP)
|
||||
type DelPoolRequest struct {
|
||||
// ID of SEP to delete pool
|
||||
// Required: true
|
||||
SEPID uint64 `url:"sep_id" json:"sep_id" validate:"required"`
|
||||
|
||||
// Name of pool to delete
|
||||
// Required: true
|
||||
PoolName string `url:"pool_name" json:"pool_name" validate:"required"`
|
||||
}
|
||||
|
||||
// DelPool deletes pool from SEP
|
||||
func (s SEP) DelPool(ctx context.Context, req DelPoolRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return false, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/sep/delPool"
|
||||
|
||||
res, err := s.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
|
||||
}
|
||||
@@ -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 SEPs
|
||||
@@ -18,7 +20,7 @@ type ListRequest struct {
|
||||
|
||||
// Find by gId
|
||||
// Required: false
|
||||
GID uint64 `url:"gId,omitempty" json:"gId,omitempty"`
|
||||
GID uint64 `url:"gid,omitempty" json:"gid,omitempty"`
|
||||
|
||||
// Find by sep type
|
||||
// Required: false
|
||||
@@ -36,6 +38,10 @@ type ListRequest struct {
|
||||
// Required: false
|
||||
ConsumedBy uint64 `url:"consumedBy,omitempty" json:"consumedBy,omitempty"`
|
||||
|
||||
// Sort by one of supported fields, format +|-(field)
|
||||
// Required: false
|
||||
SortBy string `url:"sortBy,omitempty" json:"sortBy,omitempty" validate:"omitempty,sortBy"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
@@ -47,6 +53,7 @@ type ListRequest struct {
|
||||
|
||||
// List gets list of SEPs as a ListSEP struct
|
||||
func (s SEP) List(ctx context.Context, req ListRequest) (*ListSEP, error) {
|
||||
|
||||
res, err := s.ListRaw(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -64,6 +71,12 @@ func (s SEP) List(ctx context.Context, req ListRequest) (*ListSEP, error) {
|
||||
|
||||
// ListRaw gets list of SEPs as an array of bytes
|
||||
func (s SEP) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
|
||||
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
return nil, validators.ValidationErrors(validators.GetErrors(err))
|
||||
}
|
||||
|
||||
url := "/cloudbroker/sep/list"
|
||||
|
||||
res, err := s.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
|
||||
Reference in New Issue
Block a user