-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b96adb0
commit 883216f
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |