package node import ( "context" "encoding/json" "net/http" "repository.basistech.ru/BASIS/dynamix-standart-go-sdk/internal/constants" "repository.basistech.ru/BASIS/dynamix-standart-go-sdk/internal/validators" "repository.basistech.ru/BASIS/dynamix-standart-go-sdk/pkg/node/models" "repository.basistech.ru/BASIS/dynamix-standart-go-sdk/pkg/node/requests" ) // Returns a list of nodes for a specific node func (n Node) List(ctx context.Context, req requests.ListNodesRequest) (*models.ListNodeResponse, error) { res, err := n.ListRaw(ctx, req) if err != nil { return nil, err } list := models.ListNodeResponse{} err = json.Unmarshal(res, &list) if err != nil { return nil, err } return &list, nil } // ListRaw gets a list of all nodes as an array of bytes func (n Node) ListRaw(ctx context.Context, req requests.ListNodesRequest) ([]byte, error) { if err := validators.ValidateRequest(req); err != nil { return nil, validators.ValidationErrors(validators.GetErrors(err)) } url := constants.APIv0 + "/node" res, err := n.client.ApiCall(ctx, http.MethodGet, url, req) return res, err }