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.
|
|
|
package node
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"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"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|