|
@@ -8,6 +8,13 @@ import (
|
|
"golang.org/x/exp/slog"
|
|
"golang.org/x/exp/slog"
|
|
)
|
|
)
|
|
|
|
|
|
|
|
+type ApiNodeStatus struct {
|
|
|
|
+ ID string `json:"id"`
|
|
|
|
+ IsStatic bool `json:"is_static"`
|
|
|
|
+ IsUserNode bool `json:"is_user_node"`
|
|
|
|
+ Status NodeStatus `json:"status"`
|
|
|
|
+}
|
|
|
|
+
|
|
// ApiNode is a stripped down Node DTO that exposes only required fields to external systems
|
|
// ApiNode is a stripped down Node DTO that exposes only required fields to external systems
|
|
type ApiNode struct {
|
|
type ApiNode struct {
|
|
ID string `json:"id,omitempty" validate:"required,min=5,id_unique"`
|
|
ID string `json:"id,omitempty" validate:"required,min=5,id_unique"`
|
|
@@ -132,6 +139,19 @@ func (a *ApiNode) ConvertToServerNode(currentNode *Node) *Node {
|
|
return &convertedNode
|
|
return &convertedNode
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (nm *Node) ConvertToStatusNode() *ApiNodeStatus {
|
|
|
|
+ apiNode := ApiNodeStatus{}
|
|
|
|
+ if nm.IsStatic {
|
|
|
|
+ apiNode.ID = nm.StaticNode.ClientID
|
|
|
|
+ } else {
|
|
|
|
+ apiNode.ID = nm.ID.String()
|
|
|
|
+ }
|
|
|
|
+ apiNode.IsStatic = nm.IsStatic
|
|
|
|
+ apiNode.IsUserNode = nm.IsUserNode
|
|
|
|
+ apiNode.Status = nm.Status
|
|
|
|
+ return &apiNode
|
|
|
|
+}
|
|
|
|
+
|
|
// Node.ConvertToAPINode - converts a node to an API node
|
|
// Node.ConvertToAPINode - converts a node to an API node
|
|
func (nm *Node) ConvertToAPINode() *ApiNode {
|
|
func (nm *Node) ConvertToAPINode() *ApiNode {
|
|
apiNode := ApiNode{}
|
|
apiNode := ApiNode{}
|