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
6 files
+ 124
42
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 35
2
@@ -32,12 +32,29 @@ POSSIBILITY OF SUCH DAMAGE.
package cmd
import (
"fmt"
ppb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
"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
var deviceGetCmd = &cobra.Command{
Use: "get [uuid] [path]",
@@ -60,7 +77,23 @@ The device UUID and request path must be specified as a positional arguments.`,
log.Error(err)
}
log.Info(protojson.Format(message))
resp, ok := message.(*ppb.GetPathResponse)
if !ok {
log.Fatal(err)
}
pm := pathMessage{
time: resp.GetTimestamp(),
path: resp.Device[0].Update[0].GetPath().String(),
updates: resp.Device[0].Update[0].GetVal().String(),
}
if m := resp.Device[0].Update[0].GetVal().GetJsonIetfVal(); m != nil {
pm.updates = string(m)
}
log.Info(pm.String())
},
}
Loading