Skip to content

Commit

Permalink
Merge pull request #74 from megaport/feat/vxc-partnerConfig-updates
Browse files Browse the repository at this point in the history
feat: allow for vrouter partner config in update vxc call
  • Loading branch information
MegaportPhilipBrowne authored Oct 1, 2024
2 parents 0decef3 + 508032b commit 3178fa7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,9 @@ var ErrManagedAccountNotFound = errors.New("managed account not found")

// ErrInvalidVLAN is returned when a VLAN is invalid
var ErrInvalidVLAN = errors.New("invalid VLAN, must be between 0 and 4094")

// 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")
23 changes: 23 additions & 0 deletions vxc.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ type UpdateVXCRequest struct {
AEndInnerVLAN *int
BEndInnerVLAN *int

AEndPartnerConfig VXCPartnerConfiguration
BEndPartnerConfig VXCPartnerConfiguration

WaitForUpdate bool // Wait until the VXC updates before returning
WaitForTime time.Duration // How long to wait for the VXC to update if WaitForUpdate is true (default is 5 minutes)
}
Expand Down Expand Up @@ -267,6 +270,26 @@ func (svc *VXCServiceOp) UpdateVXC(ctx context.Context, id string, req *UpdateVX
Shutdown: req.Shutdown,
}

if req.AEndPartnerConfig != nil {
// 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
}
}

if req.BEndPartnerConfig != nil {
// 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 {
update.Name = *req.Name
}
Expand Down
3 changes: 3 additions & 0 deletions vxc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ type VXCUpdate struct {
AEndProductUID string `json:"aEndProductUid,omitempty"`
BEndProductUID string `json:"bEndProductUid,omitempty"`
Term *int `json:"term,omitempty"`

AEndPartnerConfig VXCPartnerConfiguration `json:"aEndConfig,omitempty"`
BEndPartnerConfig VXCPartnerConfiguration `json:"bEndConfig,omitempty"`
}

// VXCOrderResponse represents the response from the VXC Order API.
Expand Down

0 comments on commit 3178fa7

Please sign in to comment.