This commit is contained in:
2026-06-19 17:37:20 +03:00
parent b897b3447a
commit f679261f74
1513 changed files with 107093 additions and 1 deletions

47
pkg/sdn/routers/get.go Normal file
View File

@@ -0,0 +1,47 @@
package routers
import (
"context"
"encoding/json"
"net/http"
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
)
// GetRequest struct to get information about router
type GetRequest struct {
// ID
// Required: true
ID string `url:"router_id" json:"router_id" validate:"required"`
}
// Get gets routers details as a RoutersModel struct
func (a Routers) Get(ctx context.Context, req GetRequest) (*RoutersModel, error) {
res, err := a.GetRaw(ctx, req)
if err != nil {
return nil, err
}
info := RoutersModel{}
err = json.Unmarshal(res, &info)
if err != nil {
return nil, err
}
return &info, nil
}
// GetRaw gets routers details as an array of bytes
func (a Routers) GetRaw(ctx context.Context, req GetRequest) ([]byte, error) {
err := validators.ValidateRequest(req)
if err != nil {
return nil, validators.ValidationErrors(validators.GetErrors(err))
}
url := "/sdn/router/get"
res, err := a.client.DecortApiCall(ctx, http.MethodGet, url, req)
return res, err
}