func (h *nodes) RemoveBGPNode(metadata api.NodeMetadata) error {
	_, err := h.c.Backend.Delete(context.Background(), model.BGPNodeKey{Host: metadata.Name}, metadata.GetObjectMetadata().Revision)
	if err != nil {
		if _, ok := err.(errors.ErrorResourceDoesNotExist); !ok {
			log.Errorf("Error removing BGP Node: %v", err)
			return err
		}
	}
	return nil
}
RemoveBGPNode removes all Node specific data from the datastore.
package client
import (
	"context"
	log "github.com/sirupsen/logrus"
	api "github.com/projectcalico/libcalico-go/lib/apis/v1"
	"github.com/projectcalico/libcalico-go/lib/apis/v1/unversioned"
	"github.com/projectcalico/libcalico-go/lib/backend/model"
	"github.com/projectcalico/libcalico-go/lib/errors"
	"github.com/projectcalico/libcalico-go/lib/net"
)
type NodeInterface interface {
	List(api.NodeMetadata) (*api.NodeList, error)
	Get(api.NodeMetadata) (*api.Node, error)
	Create(*api.Node) (*api.Node, error)
	Update(*api.Node) (*api.Node, error)
	Apply(*api.Node) (*api.Node, error)
	Delete(api.NodeMetadata) error
}
type nodes struct {
	c *Client
}
func newNodes(c *Client) NodeInterface {
	return &nodes{c}
}
func (h *nodes) Create(a *api.Node) (*api.Node, error) {
	if err := h.c.EnsureInitialized(); err != nil {
		return nil, err
	}
	return a, h.c.create(*a, h)
}
func (h *nodes) Update(a *api.Node) (*api.Node, error) {
	if err := h.c.EnsureInitialized(); err != nil {
		return nil, err
	}
	return a, h.c.update(*a, h)
}
func (h *nodes) Apply(a *api.Node) (*api.Node, error) {
	if err := h.c.EnsureInitialized(); err != nil {
		return nil, err
	}
	return a, h.c.apply(*a, h)
}
func (h *nodes) Delete(metadata api.NodeMetadata) error {
	if metadata.Name == "" {
		return errors.ErrorInsufficientIdentifiers{Name: "node"}
	}
	log.Debugf("Deleting node: %s", metadata.Name)
	log.Debug("Removing BGP Node data")
	err := h.RemoveBGPNode(metadata)
	if err != nil {
		log.Debugf("Error removing BGP Node data: %v", err)
		if _, ok := err.(errors.ErrorResourceDoesNotExist); ok {
			return err
		}
	}
	return h.c.delete(metadata, h)
}
func (h *nodes) Get(metadata api.NodeMetadata) (*api.Node, error) {
	if a, err := h.c.get(metadata, h); err != nil {
		return nil, err
	} else {
		return a.(*api.Node), nil
	}
}
func (h *nodes) List(metadata api.NodeMetadata) (*api.NodeList, error) {
	l := api.NewNodeList()
	err := h.c.list(metadata, h, l)
	return l, err
}
func (h *nodes) convertMetadataToListInterface(m unversioned.ResourceMetadata) (model.ListInterface, error) {
	nm := m.(api.NodeMetadata)
	l := model.NodeListOptions{
		Hostname: nm.Name,
	}
	return l, nil
}
func (h *nodes) convertMetadataToKey(m unversioned.ResourceMetadata) (model.Key, error) {
	nm := m.(api.NodeMetadata)
	k := model.NodeKey{
		Hostname: nm.Name,
	}
	return k, nil
}
func (h *nodes) convertAPIToKVPair(a unversioned.Resource) (*model.KVPair, error) {
	an := a.(api.Node)
	k, err := h.convertMetadataToKey(an.Metadata)
	if err != nil {
		return nil, err
	}
	v := model.Node{}
	if an.Spec.BGP != nil {
		if an.Spec.BGP.IPv4Address != nil {
			v.BGPIPv4Addr = &net.IP{an.Spec.BGP.IPv4Address.IP}
			v.BGPIPv4Net = an.Spec.BGP.IPv4Address.Network()
		}
		if an.Spec.BGP.IPv6Address != nil {
			v.BGPIPv6Addr = &net.IP{an.Spec.BGP.IPv6Address.IP}
			v.BGPIPv6Net = an.Spec.BGP.IPv6Address.Network()
		}
		v.BGPASNumber = an.Spec.BGP.ASNumber
	}
	for _, orchRef := range an.Spec.OrchRefs {
		v.OrchRefs = append(v.OrchRefs, model.OrchRef{
			Orchestrator: orchRef.Orchestrator,
			NodeName:     orchRef.NodeName,
		})
	}
	return &model.KVPair{Key: k, Value: &v}, nil
}
func (h *nodes) convertKVPairToAPI(d *model.KVPair) (unversioned.Resource, error) {
	bv := d.Value.(*model.Node)
	bk := d.Key.(model.NodeKey)
	apiNode := api.NewNode()
	apiNode.Metadata.Name = bk.Hostname
	if bv.BGPIPv4Addr != nil || bv.BGPIPv6Addr != nil {
		apiNode.Spec.BGP = &api.NodeBGPSpec{
			ASNumber: bv.BGPASNumber,
		}
		if bv.BGPIPv4Addr != nil {
			if bv.BGPIPv4Net != nil {
				apiNode.Spec.BGP.IPv4Address = bv.BGPIPv4Net
				apiNode.Spec.BGP.IPv4Address.IP = bv.BGPIPv4Addr.IP
			} else {
				apiNode.Spec.BGP.IPv4Address = bv.BGPIPv4Addr.Network()
			}
		}
		if bv.BGPIPv6Addr != nil {
			if bv.BGPIPv6Net != nil {
				apiNode.Spec.BGP.IPv6Address = bv.BGPIPv6Net
				apiNode.Spec.BGP.IPv6Address.IP = bv.BGPIPv6Addr.IP
			} else {
				apiNode.Spec.BGP.IPv6Address = bv.BGPIPv6Addr.Network()
			}
		}
	}
	for _, orchref := range bv.OrchRefs {
		apiNode.Spec.OrchRefs = append(apiNode.Spec.OrchRefs, api.OrchRef{
			NodeName:     orchref.NodeName,
			Orchestrator: orchref.Orchestrator,
		})
	}
	return apiNode, nil
}