We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello,
I created a follow code in go:
package main import ( "context" "fmt" "log" "github.com/openconfig/gnmic/pkg/api" ) type ArpEntry struct { IfName string `json:"if-name"` IpAddr string `json:"if-addr"` MacAddr string `json:"mac-addr"` NiName string `json:"ni-name"` SlotId string `json:"slot-id"` StyleType string `string:"style-type"` WorkIfName string `string:"work-if-name"` } func main() { // Create target target, err := api.NewTarget( api.Name("srl1"), api.Address("10.47.132.21:57400"), api.Username("suporte"), api.Password("vidaloka"), api.Insecure(true), ) if err != nil { log.Fatal(err) } ctx, cancel := context.WithCancel(context.Background()) defer cancel() // Create a gNMI client err = target.CreateGNMIClient(ctx) if err != nil { log.Fatal(err) } defer target.Close() // Create a GetRequest getReq, err := api.NewGetRequest( api.Path("huawei-arp:arp/query-entries"), api.Encoding("json"), ) if err != nil { log.Fatal(err) } getResp, err := target.Get(ctx, getReq) if err != nil { log.Fatal(err) } fmt.Println(getResp) }
The code print message:
notification:{timestamp:1726264121448774000 update:{path:{elem:{name:"huawei-arp:arp"} elem:{name:"query-entries"}} val:{json_val:"{\n\t\"query-entry\":\t[{\n\t\t\t\"ni-name\":\t\"_public_\",\n\t\t\t\"ip-addr\":\t\"179.183.221.121\",\n\t\t\t\"mac-addr\":\t\"28a6-db25-f0fc\",\n\t\t\t\"style-type\":\t\"interface-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet8/0/2\",\n\t\t\t\"slot-id\":\t\"8\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet8/0/2\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"_public_\",\n\t\t\t\"ip-addr\":\t\"179.183.221.125\",\n\t\t\t\"mac-addr\":\t\"28a6-db25-f0fd\",\n\t\t\t\"style-type\":\t\"interface-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet8/0/3\",\n\t\t\t\"slot-id\":\t\"8\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet8/0/3\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"_public_\",\n\t\t\t\"ip-addr\":\t\"177.43.61.181\",\n\t\t\t\"mac-addr\":\t\"28a6-db25-f0fe\",\n\t\t\t\"style-type\":\t\"interface-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet8/0/4\",\n\t\t\t\"slot-id\":\t\"8\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet8/0/4\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"_public_\",\n\t\t\t\"ip-addr\":\t\"179.183.221.119\",\n\t\t\t\"mac-addr\":\t\"28a6-db25-efdc\",\n\t\t\t\"style-type\":\t\"interface-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet7/0/2\",\n\t\t\t\"slot-id\":\t\"7\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet7/0/2\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"_public_\",\n\t\t\t\"ip-addr\":\t\"179.183.221.123\",\n\t\t\t\"mac-addr\":\t\"28a6-db25-efdd\",\n\t\t\t\"style-type\":\t\"interface-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet7/0/3\",\n\t\t\t\"slot-id\":\t\"7\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet7/0/3\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"_public_\",\n\t\t\t\"ip-addr\":\t\"189.59.254.4\",\n\t\t\t\"mac-addr\":\t\"28a6-db25-efe4\",\n\t\t\t\"style-type\":\t\"interface-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet7/0/10\",\n\t\t\t\"slot-id\":\t\"7\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet7/0/10\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"_public_\",\n\t\t\t\"ip-addr\":\t\"189.59.254.5\",\n\t\t\t\"mac-addr\":\t\"28c0-daf3-287c\",\n\t\t\t\"expire-time\":\t6,\n\t\t\t\"style-type\":\t\"dynamic-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet7/0/10\",\n\t\t\t\"slot-id\":\t\"7\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet7/0/10\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"_public_\",\n\t\t\t\"ip-addr\":\t\"177.43.60.18\",\n\t\t\t\"mac-addr\":\t\"6008-1000-02a7\",\n\t\t\t\"style-type\":\t\"interface-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet7/0/1.555\",\n\t\t\t\"slot-id\":\t\"7\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet7/0/1.555\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"_public_\",\n\t\t\t\"ip-addr\":\t\"192.168.150.252\",\n\t\t\t\"mac-addr\":\t\"6008-1000-02a7\",\n\t\t\t\"style-type\":\t\"interface-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet7/0/1.1432\",\n\t\t\t\"slot-id\":\t\"7\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet7/0/1.1432\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"_public_\",\n\t\t\t\"ip-addr\":\t\"177.43.60.20\",\n\t\t\t\"mac-addr\":\t\"28a6-db25-efe5\",\n\t\t\t\"style-type\":\t\"interface-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet7/0/11.555\",\n\t\t\t\"slot-id\":\t\"7\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet7/0/11.555\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"_public_\",\n\t\t\t\"ip-addr\":\t\"192.168.151.252\",\n\t\t\t\"mac-addr\":\t\"28a6-db25-efe5\",\n\t\t\t\"style-type\":\t\"interface-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet7/0/11.1432\",\n\t\t\t\"slot-id\":\t\"7\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet7/0/11.1432\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"GERENCIA\",\n\t\t\t\"ip-addr\":\t\"10.47.132.21\",\n\t\t\t\"mac-addr\":\t\"6008-1000-02a6\",\n\t\t\t\"style-type\":\t\"interface-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet0/0/0\",\n\t\t\t\"slot-id\":\t\"0\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet0/0/0\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"GERENCIA\",\n\t\t\t\"ip-addr\":\t\"10.47.132.61\",\n\t\t\t\"mac-addr\":\t\"a0e0-af64-eee2\",\n\t\t\t\"expire-time\":\t20,\n\t\t\t\"style-type\":\t\"dynamic-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet0/0/0\",\n\t\t\t\"slot-id\":\t\"0\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet0/0/0\"\n\t\t}, {\n\t\t\t\"ni-name\":\t\"GERENCIA\",\n\t\t\t\"ip-addr\":\t\"10.47.132.62\",\n\t\t\t\"mac-addr\":\t\"0000-5e00-01cb\",\n\t\t\t\"expire-time\":\t13,\n\t\t\t\"style-type\":\t\"dynamic-arp\",\n\t\t\t\"if-name\":\t\"GigabitEthernet0/0/0\",\n\t\t\t\"slot-id\":\t\"0\",\n\t\t\t\"work-if-name\":\t\"GigabitEthernet0/0/0\"\n\t\t}]\n}"}}}
I want to unmarshall to json struct.... How I can to do this? In resume I want the same result like gnmic program brings to me.
Tks,
Paulo
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello,
I created a follow code in go:
The code print message:
I want to unmarshall to json struct.... How I can to do this? In resume I want the same result like gnmic program brings to me.
Tks,
Paulo
The text was updated successfully, but these errors were encountered: