Comments (9)
from restconf.
from restconf.
from restconf.
I confirm that master
(3972ca6) fixes this issue (rather than #62 as referenced by the commit message). Thank you!
from restconf.
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.
from restconf.
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.
from restconf.
from restconf.
Related Issues (20)
- when requesting xml, response is a truncated json response HOT 5
- Feature request: Support XMLparsing HOT 1
- Feature request: Support XML output HOT 7
- ServeHTTP in server is not using Request context HOT 2
- Restconf server automatically opens a HTTP server HOT 1
- Feature request: Improve README HOT 1
- Feature request: Improve reflection support HOT 3
- Feature request: Improve error handling HOT 7
- Yang reference needs bump HOT 1
- Response content type not correctly set after XML pull request merge HOT 1
- local.go:ApplyStartupConfigFile function panics instead of returning an error HOT 2
- Restconf does not set the body in the right format (XML) for errors with a body when the accept in the request is XML HOT 2
- Restconf go.mod does not refer to latest freeconf/yang HOT 1
- Content-Type set in util::handle is overwritten by net/http/server.go HOT 1
- Response body for errors not valid in XML HOT 1
- Edit a leaf with `config false` HOT 2
- Question: how to post binary data with JSON HOT 3
- Bug in support for RFC 8525 HOT 3
- Question: how to re-retrieve server configuration HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from restconf.