Giter VIP home page Giter VIP logo

Comments (9)

dhubler avatar dhubler commented on June 16, 2024

from restconf.

dhubler avatar dhubler commented on June 16, 2024

from restconf.

dhubler avatar dhubler commented on June 16, 2024

from restconf.

b-kamphorst avatar b-kamphorst commented on June 16, 2024

I confirm that master (3972ca6) fixes this issue (rather than #62 as referenced by the commit message). Thank you!

from restconf.

b-kamphorst avatar b-kamphorst commented on June 16, 2024

Perhaps we are not done entirely. This time, I select and print the value of a leaf after the config change. After that, I don't get the full config again if I print car.Root(). It appears that the root has been changed?

// Courtesy to https://freeconf.org/docs/examples/restconf-client/

package main

import (
	"github.com/freeconf/restconf"
	"github.com/freeconf/restconf/client"
	"github.com/freeconf/yang/nodeutil"
)

func connectClient() {

	// YANG: just need YANG file ietf-yang-library.yang, not the yang of remote system as that will
	// be downloaded as needed
	ypath := restconf.InternalYPath

	// Connect
	proto := client.ProtocolHandler(ypath)
	dev, err := proto("http://localhost:8080/restconf")
	if err != nil {
		panic(err)
	}

	// Get a browser to walk server's management API for car
	car, err := dev.Browser("car")
	if err != nil {
		panic(err)
	}
	root := car.Root()
	defer root.Release()

	actual, err := nodeutil.WritePrettyJSON(car.Root())
	if err != nil {
		panic(err)
	}
	println("========== initial config ==========")
	println(actual)

	n, err := nodeutil.ReadJSON(`{"speed":50}`)
	if err != nil {
		panic(err)
	}

	err = root.UpsertFrom(n)
	if err != nil {
		panic(err)
	}

	actual, err = nodeutil.WritePrettyJSON(car.Root())
	if err != nil {
		panic(err)
	}
	println("========== config after setting speed ==========")
	println(actual)

	speed, err := root.Find("speed")
	if err != nil {
		panic(err)
	}
	speed_json, err := nodeutil.WritePrettyJSON(speed)
	if err != nil {
		panic(err)
	}
	println("========== just showing the value of speed ==========")
	println(speed_json)
        
        actual, err := nodeutil.WritePrettyJSON(car.Root())
	if err != nil {
		panic(err)
	}
	println("========== full config ==========")
	println(actual)
}

func main() {
	connectClient()
}

Output:

========== initial config ==========
{
"speed":1000,
"pollInterval":1000,
... // actual full config
========== config after setting speed ==========
{
"speed":50,
"pollInterval":1000,
... // actual full config
========== just showing the value of speed ==========
{
"speed":50}
========== full config ==========
{
"speed":50}

Not sure whether this is related though, as in the original example I didn't make a call to root.Find.

from restconf.

dhubler avatar dhubler commented on June 16, 2024

from restconf.

b-kamphorst avatar b-kamphorst commented on June 16, 2024

Note: the example runs as expected when I add speed.Release() after println(speed_json). Still, it is counterintuitive to me that root prints only partial information while a reference a speed selection is locked (and why that was locked to begin with).

from restconf.

dhubler avatar dhubler commented on June 16, 2024

from restconf.

b-kamphorst avatar b-kamphorst commented on June 16, 2024

from restconf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.