func (b *BgpNeighborsEntity) Get(name string) BgpNeighborConfig {
	config, _ := b.GetBlock(`^router bgp .*`)
	return BgpNeighborConfig{
		"peer_group":     b.parsePeerGroup(config, name),
		"remote_as":      b.parseRemoteAS(config, name),
		"send_community": strconv.FormatBool(b.parseSendCommunity(config, name)),
		"shutdown":       strconv.FormatBool(b.parseShutdown(config, name)),
		"description":    b.parseDescription(config, name),
		"next_hop_self":  strconv.FormatBool(b.parseNextHopSelf(config, name)),
		"route_in_map":   b.parseRouteMapIn(config, name),
		"route_out_map":  b.parseRouteMapOut(config, name),
	}
}
Get the BGP Neighbot Config for the current entity.
Returns a BgpNeighborConfig object
package module
import (
	"net"
	"regexp"
	"strconv"
	"github.com/aristanetworks/goeapi"
)
type BgpNetworkEntry map[string]string
type BgpConfig struct {
	asNumber     string
	routerID     string
	shutdown     string
	maxPaths     string
	maxEcmpPaths string
	networks     []BgpNetworkEntry
}
func (b *BgpConfig) BgpAs() string {
	return b.asNumber
}
func (b *BgpConfig) RouterID() string {
	return b.routerID
}
func (b *BgpConfig) Shutdown() string {
	return b.shutdown
}
func (b *BgpConfig) MaximumPaths() string {
	return b.maxPaths
}
func (b *BgpConfig) MaximumEcmpPaths() string {
	return b.maxEcmpPaths
}
func (b *BgpConfig) Networks() []BgpNetworkEntry {
	return b.networks
}
func (b BgpNetworkEntry) Prefix() string {
	return b["prefix"]
}
func (b BgpNetworkEntry) MaskLen() string {
	return b["masklen"]
}
func (b BgpNetworkEntry) RouteMap() string {
	return b["route_map"]
}
type BGPEntity struct {
	neighbors *BgpNeighborsEntity
	*AbstractBaseEntity
}
func Bgp(node *goeapi.Node) *BGPEntity {
	return &BGPEntity{AbstractBaseEntity: &AbstractBaseEntity{node}}
}
func (b *BGPEntity) Get() *BgpConfig {
	config, err := b.GetBlock(`^router bgp .*`)
	if err != nil {
		return nil
	}
	var bgp = new(BgpConfig)
	bgp.asNumber = b.parseAS(config)
	bgp.routerID = b.parseRouterID(config)
	bgp.shutdown = strconv.FormatBool(b.parseShutdown(config))
	bgp.networks = b.parseNetworks(config)
	m := b.parseMaxPaths(config)
	bgp.maxPaths = m["maximum_paths"]
	bgp.maxEcmpPaths = m["maximum_ecmp_paths"]
	return bgp
}
func (b *BGPEntity) Neighbors() *BgpNeighborsEntity {
	if b.neighbors == nil {
		b.neighbors = BgpNeighbors(b.AbstractBaseEntity.node)
	}
	return b.neighbors
}
func (b *BGPEntity) parseAS(config string) string {
	re := regexp.MustCompile(`(?m)^router bgp (\d+)`)
	match := re.FindStringSubmatch(config)
	if match == nil {
		return ""
	}
	return match[1]
}
func (b *BGPEntity) parseRouterID(config string) string {
	re := regexp.MustCompile(`(?m)router-id ([^\s]+)`)
	match := re.FindStringSubmatch(config)
	if match == nil {
		return ""
	}
	return match[1]
}
func (b *BGPEntity) parseMaxPaths(config string) map[string]string {
	var maxPaths string
	var maxEcmp string
	re := regexp.MustCompile(`maximum-paths\s+(\d+)(?:\s+ecmp\s+(\d+))?`)
	if match := re.FindStringSubmatch(config); match != nil {
		maxPaths = match[1]
		maxEcmp = match[2]
	}
	return map[string]string{
		"maximum_paths":      maxPaths,
		"maximum_ecmp_paths": maxEcmp,
	}
}
func (b *BGPEntity) parseShutdown(config string) bool {
	matched, _ := regexp.MatchString(`(?m)no shutdown`, config)
	if matched {
		return false
	}
	return !matched
}
func (b *BGPEntity) parseNetworks(config string) []BgpNetworkEntry {
	reNet := regexp.MustCompile(`(?m)network (.+)/(\d+)(?: route-map (\w+))*`)
	matches := reNet.FindAllStringSubmatch(config, -1)
	if matches == nil {
		return nil
	}
	resource := make([]BgpNetworkEntry, len(matches))
	for idx, line := range matches {
		resource[idx] = BgpNetworkEntry{
			"prefix":    line[1],
			"masklen":   line[2],
			"route_map": line[3],
		}
	}
	return resource
}
func (b *BGPEntity) GetSection() string {
	config, err := b.GetBlock(`^router bgp .*`)
	if err != nil {
		return ""
	}
	return config
}
func (b *BGPEntity) ConfigureBgp(cmd string) bool {
	config := b.Get()
	if config == nil {
		return false
	}
	commands := []string{
		"router bgp " + config.BgpAs(),
		cmd,
	}
	return b.Configure(commands...)
}
func (b *BGPEntity) Create(bgpAS int) bool {
	if !(0 < bgpAS && bgpAS < 65535) {
		return false
	}
	cmd := "router bgp " + strconv.Itoa(bgpAS)
	return b.Configure(cmd)
}
func (b *BGPEntity) Delete() bool {
	config := b.Get()
	if config == nil {
		return true
	}
	cmd := "no router bgp " + config.BgpAs()
	return b.Configure(cmd)
}
func (b *BGPEntity) Default() bool {
	config := b.Get()
	if config == nil {
		return true
	}
	cmd := "default router bgp " + config.BgpAs()
	return b.Configure(cmd)
}
func (b *BGPEntity) SetRouterID(value string) bool {
	if value == "" {
		return b.ConfigureBgp("no router-id")
	}
	return b.ConfigureBgp("router-id " + value)
}
func (b *BGPEntity) SetRouterIDDefault() bool {
	return b.ConfigureBgp("default router-id")
}
func (b *BGPEntity) SetMaximumPaths(maxPath int) bool {
	command := "maximum-paths " + strconv.Itoa(maxPath)
	return b.ConfigureBgp(command)
}
func (b *BGPEntity) SetMaximumPathsWithEcmp(maxPath int, maxEcmp int) bool {
	cmd := "maximum-paths " + strconv.Itoa(maxPath) + " ecmp " + strconv.Itoa(maxEcmp)
	return b.ConfigureBgp(cmd)
}
func (b *BGPEntity) SetMaximumPathsDefault() bool {
	return b.ConfigureBgp("default maximum-paths")
}
func (b *BGPEntity) SetShutdown(enable bool) bool {
	cmd := b.CommandBuilder("shutdown", "", false, enable)
	return b.ConfigureBgp(cmd)
}
func (b *BGPEntity) SetShutdownDefault() bool {
	return b.ConfigureBgp("default shutdown")
}
func (b *BGPEntity) AddNetworkWithRouteMap(prefix string, maskLen string, routeMap string) bool {
	command := "network " + prefix + "/" + maskLen
	if routeMap != "" {
		command = command + " route-map " + routeMap
	}
	return b.ConfigureBgp(command)
}
func (b *BGPEntity) AddNetwork(prefix string, maskLen string) bool {
	return b.AddNetworkWithRouteMap(prefix, maskLen, "")
}
func (b *BGPEntity) RemoveNetworkWithRouteMap(prefix string, maskLen string, routeMap string) bool {
	command := "no network " + prefix + "/" + maskLen
	if routeMap != "" {
		command = command + " route-map " + routeMap
	}
	return b.ConfigureBgp(command)
}
func (b *BGPEntity) RemoveNetwork(prefix string, maskLen string) bool {
	return b.RemoveNetworkWithRouteMap(prefix, maskLen, "")
}
type BgpNeighborConfig map[string]string
type BgpNeighborCollection map[string]BgpNeighborConfig
type BgpNeighborsEntity struct {
	*AbstractBaseEntity
}
func BgpNeighbors(node *goeapi.Node) *BgpNeighborsEntity {
	return &BgpNeighborsEntity{&AbstractBaseEntity{node}}
}