Skip to content

Commit

Permalink
Support for in-cluster lb
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Jul 20, 2023
1 parent b96adb0 commit 883216f
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions pkg/api/bgp.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package api

import (
"context"
)

type BGPNeigh struct {
// BGP Neighbor IP address
IPAddress string `json:"ipAddress,omitempty"`
// Remote AS number
RemoteAs int64 `json:"remoteAs,omitempty"`
}

type BGPGlobalConfig struct {
// Local AS number
LocalAs int64 `json:"localAs,omitempty"`
// BGP Router ID
RouterID string `json:"routerId,omitempty"`
}

type BGPAPI struct {
resource string
provider string
version string
client *RESTClient
APICommonFunc
}

func newBGPAPI(r *RESTClient) *BGPAPI {
return &BGPAPI{
resource: "config/bgp",
provider: r.provider,
version: r.version,
client: r,
}
}

func (bgpNeighModel *BGPNeigh) GetKeyStruct() LoxiModel {
return bgpNeighModel
}

func (bgpGlobalModel *BGPGlobalConfig) GetKeyStruct() LoxiModel {
return bgpGlobalModel
}

func (b *BGPAPI) CreateGlobalConfig(ctx context.Context, Model LoxiModel) error {
resp := b.client.POST(b.resource + "/global").Body(Model).Do(ctx)
if resp.err != nil {
return resp.err
}
return nil
}

func (b *BGPAPI) CreateNeigh(ctx context.Context, Model LoxiModel) error {
resp := b.client.POST(b.resource + "/neigh").Body(Model).Do(ctx)
if resp.err != nil {
return resp.err
}
return nil
}

0 comments on commit 883216f

Please sign in to comment.