v1.6.6
This commit is contained in:
@@ -8,25 +8,16 @@ import (
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for get detailed information about external network
|
||||
// GetRequest struct to get detailed 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 detailed information about external network
|
||||
// Get gets detailed information about external network 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 := "/cloudapi/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 detailed information about external network 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 := "/cloudapi/extnet/get"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -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 ListExtNets struct
|
||||
func (e ExtNet) List(ctx context.Context, req ListRequest) (*ListExtNets, error) {
|
||||
url := "/cloudapi/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) (*ListExtNets, 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 := "/cloudapi/extnet/list"
|
||||
|
||||
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user