You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1 KiB

4 months ago
package node
import (
"context"
"encoding/json"
"net/http"
4 months ago
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/internal/constants"
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/internal/validators"
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/pkg/node/models"
"repository.basistech.ru/BASIS/dynamix-standard-go-sdk/pkg/node/requests"
4 months ago
)
// 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
}