aristanetworks / goeapi

Go library for Arista's eAPI command API implementation
BSD 3-Clause "New" or "Revised" License
46 stars 31 forks source link

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

Open jhgiii opened 2 years ago

jhgiii commented 2 years ago

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:

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

ljluestc commented 1 year ago
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)
}