Skip to content
Snippets Groups Projects

Resolve "A SetRequest to change a specific path of an OND only works for paths with string values"

Compare and
7 files
+ 166
76
Compare changes
  • Side-by-side
  • Inline
Files
7
+ 36
2
@@ -32,12 +32,29 @@ POSSIBILITY OF SUCH DAMAGE.
@@ -32,12 +32,29 @@ POSSIBILITY OF SUCH DAMAGE.
package cmd
package cmd
import (
import (
 
"fmt"
 
 
ppb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
"github.com/google/uuid"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"google.golang.org/protobuf/encoding/protojson"
)
)
 
type pathMessage struct {
 
time int64
 
path string
 
updates string
 
}
 
 
func (pm pathMessage) String() string {
 
// TODO: different prints based on typedValue type
 
return fmt.Sprintf("timestamp: %v\npath: %v\nupdates: %v\n}",
 
pm.time,
 
pm.path,
 
pm.updates,
 
)
 
}
 
// deviceGetCmd represents the get command
// deviceGetCmd represents the get command
var deviceGetCmd = &cobra.Command{
var deviceGetCmd = &cobra.Command{
Use: "get [uuid] [path]",
Use: "get [uuid] [path]",
@@ -60,7 +77,24 @@ The device UUID and request path must be specified as a positional arguments.`,
@@ -60,7 +77,24 @@ The device UUID and request path must be specified as a positional arguments.`,
log.Error(err)
log.Error(err)
}
}
log.Info(protojson.Format(message))
resp, ok := message.(*ppb.GetPathResponse)
 
if !ok {
 
log.Fatal(err)
 
}
 
 
for _, d := range resp.Device {
 
pm := pathMessage{
 
time: resp.GetTimestamp(),
 
path: d.Update[0].GetPath().String(),
 
updates: d.Update[0].GetVal().String(),
 
}
 
 
if m := d.Update[0].GetVal().GetJsonIetfVal(); m != nil {
 
pm.updates = string(m)
 
 
}
 
fmt.Println(pm.String())
 
}
},
},
}
}
Loading