This commit is contained in:
stSolo
2022-12-22 17:56:47 +03:00
parent 8712561853
commit d4b1ab7133
672 changed files with 28509 additions and 4419 deletions

View File

@@ -7,36 +7,41 @@ import (
"net/http"
)
// Request struct for get detailed information about external network
type GetRequest struct {
// ID of external network
// Required: true
NetID uint64 `url:"net_id"`
}
func (erq GetRequest) Validate() error {
func (erq GetRequest) validate() error {
if erq.NetID == 0 {
return errors.New("validation-error: field NetID can not be empty or equal to 0")
}
return nil
}
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*ExtNetDetailed, error) {
err := req.Validate()
// Get gets detailed information about external network
func (e ExtNet) Get(ctx context.Context, req GetRequest) (*RecordExtNet, error) {
err := req.validate()
if err != nil {
return nil, err
}
url := "/cloudapi/extnet/get"
extnetRaw, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
res, err := e.client.DecortApiCall(ctx, http.MethodPost, url, req)
if err != nil {
return nil, err
}
extnet := &ExtNetDetailed{}
err = json.Unmarshal(extnetRaw, &extnet)
info := RecordExtNet{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return extnet, nil
return &info, nil
}