Skip to content

Commit

Permalink
fix: only allow aend or vrouter partner config for aend and only vrou…
Browse files Browse the repository at this point in the history
…ter for bend in vxc updates
  • Loading branch information
MegaportPhilipBrowne committed Sep 26, 2024
1 parent 9054191 commit 3441f70
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
6 changes: 6 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,9 @@ var ErrCostCentreTooLong = errors.New("cost centre must be less than 255 charact

// ErrManagedAccountNotFound is returned when a managed account can't be found
var ErrManagedAccountNotFound = errors.New("managed account not found")

// ErrInvalidVXCAEndPartnerConfig is returned when an invalid VXC A-End partner config is provided
var ErrInvalidVXCAEndPartnerConfig = errors.New("invalid vxc a-end partner config")

// ErrInvalidVXCBEndPartnerConfig is returned when an invalid VXC B-End partner config is provided
var ErrInvalidVXCBEndPartnerConfig = errors.New("invalid vxc b-end partner config")
28 changes: 21 additions & 7 deletions vxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,27 @@ func (svc *VXCServiceOp) UpdateVXC(ctx context.Context, id string, req *UpdateVX
url := svc.Client.BaseURL.JoinPath(path).String()

update := &VXCUpdate{
RateLimit: req.RateLimit,
AEndVLAN: req.AEndVLAN,
BEndVLAN: req.BEndVLAN,
Term: req.Term,
Shutdown: req.Shutdown,
AEndPartnerConfig: req.AEndPartnerConfig,
BEndPartnerConfig: req.BEndPartnerConfig,
RateLimit: req.RateLimit,
AEndVLAN: req.AEndVLAN,
BEndVLAN: req.BEndVLAN,
Term: req.Term,
Shutdown: req.Shutdown,
}

// Only allow AENdPartnerConfig or VROUTER Partner Config for AEndPartnerConfig in VXC Updates
switch req.AEndPartnerConfig.(type) {
case VXCPartnerConfiguration, VXCOrderVrouterPartnerConfig:
update.AEndPartnerConfig = req.AEndPartnerConfig
default:
return nil, ErrInvalidVXCAEndPartnerConfig
}

// Only allow Vrouter Partner Config for BEndPartnerConfig in VXC Updates
switch req.BEndPartnerConfig.(type) {
case VXCOrderVrouterPartnerConfig:
update.BEndPartnerConfig = req.BEndPartnerConfig
default:
return nil, ErrInvalidVXCBEndPartnerConfig
}

if req.Name != nil {
Expand Down

0 comments on commit 3441f70

Please sign in to comment.