Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow for vrouter partner config in update vxc call #74

Merged
merged 6 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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