This commit is contained in:
2023-10-23 12:40:54 +03:00
parent b069c31745
commit b666789c7d
73 changed files with 1134 additions and 641 deletions

View File

@@ -8,25 +8,16 @@ import (
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// Request struct for get information about external network
// GetRequest struct to get information about external network
type GetRequest struct {
// ID of external network
// Required: true
NetID uint64 `url:"net_id" json:"net_id" validate:"required"`
}
// Get gets external network details
// Get gets external network details as a RecordExtNet struct
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error) {
err := validators.ValidateRequest(req)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/extnet/get"
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := e.GetRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -40,3 +31,18 @@ func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error)
return &info, nil
}
// GetRaw gets external network details as an array of bytes
func (e ExtNet) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
for _, validationError := range validators.GetErrors(err) {
return nil, validators.ValidationError(validationError)
}
}
url := "/cloudbroker/extnet/get"
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -6,7 +6,7 @@ import (
"net/http"
)
// Request struct for get list external network
// ListRequest struct to get list of external network
type ListRequest struct {
// Find by account ID
// Required: false
@@ -45,11 +45,9 @@ type ListRequest struct {
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
}
// List gets list all available external networks
// List gets list of all available external networks as a ListExtNet struct
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNet, error) {
url := "/cloudbroker/extnet/list"
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := e.ListRaw(ctx, req)
if err != nil {
return nil, err
}
@@ -63,3 +61,11 @@ func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNet, error)
return &list, nil
}
// ListRaw gets list of all available external networks as an array of bytes
func (e ExtNet) ListRaw(ctx context.Context, req ListRequest) ([]byte, error) {
url := "/cloudbroker/extnet/list"
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
return res, err
}

View File

@@ -127,29 +127,86 @@ type ListExtNet struct {
// Detailed information about external network
type RecordExtNet struct {
// Main information about external network
ItemExtNet
// CKey
CKey string `json:"_ckey"`
// CheckIps
// Meta
Meta []interface{} `json:"_meta"`
// CheckIPs
CheckIPs []string `json:"checkIps"`
// Default
Default bool `json:"default"`
// Default QOS
DefaultQOS QOS `json:"defaultQos"`
// Description
Description string `json:"desc"`
// List DNS
DNS []string `json:"dns"`
// List excludes
Excluded ListReservations `json:"excluded"`
// Free IPs number
FreeIPs uint64 `json:"free_ips"`
// Gateway
Gateway string `json:"gateway"`
// Grid ID
GID uint64 `json:"gid"`
// GUID
GUID uint64 `json:"guid"`
// ID
ID uint64 `json:"id"`
// IPCIDR
IPCIDR string `json:"ipcidr"`
// Milestones
Milestones uint64 `json:"milestones"`
// Name
Name string `json:"name"`
// Network
Network string `json:"network"`
// Network ID
NetworkID uint64 `json:"networkId"`
// OVSBridge
OVSBridge string `json:"ovsBridge"`
// PreReservationsNum
PreReservationsNum uint64 `json:"preReservationsNum"`
// Prefix
Prefix uint64 `json:"prefix"`
// PriVNFDevID
PriVNFDevID uint64 `json:"priVnfDevId"`
// List reservations
Reservations ListReservations `json:"reservations"`
// List of shared with
SharedWith []interface{} `json:"sharedWith"`
// Status
Status string `json:"status"`
// VLAN ID
VLANID uint64 `json:"vlanId"`
// VNFs
VNFs VNFs `json:"vnfs"`
}
// List of static routes