goeapi icon indicating copy to clipboard operation
goeapi copied to clipboard

VRF Type has ASN as int64 type but EAPI returns a string type

Open jhgiii opened this issue 3 years ago • 1 comments

package main

import ( "fmt"

"github.com/aristanetworks/goeapi"
"github.com/aristanetworks/goeapi/module"

)

func main() { node, err := goeapi.ConnectTo("sp1") if err != nil { panic(err) } s := module.Show(node) showData, err := s.ShowIPBGPSummary() if err != nil { fmt.Println(err) } fmt.Printf("%v", showData.VRFs) }

When running I received the following error:

1 error(s) decoding:

  • 'VRFs[default].asn' expected type 'int64', got unconvertible type 'string', value: '65001'

Looking through the code base, I see the following struct:

type VRF struct { RouterID string json:"routerId" Peers map[string]BGPNeighborSummary json:"peers" VRF string json:"vrf" ASN int64 json:"asn" }

It may be safer to expect a string type

jhgiii avatar Sep 08 '22 03:09 jhgiii

package main

import (
	"fmt"

	"github.com/aristanetworks/goeapi"
	"github.com/aristanetworks/goeapi/module"
)

type VRF struct {
	RouterID string                           `json:"routerId"`
	Peers    map[string]module.BGPNeighborSummary `json:"peers"`
	VRF      string                           `json:"vrf"`
	ASN      interface{}                      `json:"asn"`
}

func main() {
	node, err := goeapi.ConnectTo("sp1")
	if err != nil {
		panic(err)
	}
	s := module.Show(node)
	showData, err := s.ShowIPBGPSummary()
	if err != nil {
		fmt.Println(err)
	}
	fmt.Printf("%v", showData.VRFs)
}

ljluestc avatar Aug 27 '23 06:08 ljluestc